Map
TsgcHTMLComponent_Map — render an interactive Leaflet.js map with OpenStreetMap or CartoDB tiles and your own markers, popups and tooltips, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Map — render an interactive Leaflet.js map with OpenStreetMap or CartoDB tiles and your own markers, popups and tooltips, in Delphi, C++ Builder and .NET.
A mapping component that emits a Leaflet.js map container plus the script that initialises it. Set the centre, zoom and tile provider, add markers, then read the HTML property.
TsgcHTMLComponent_Map
Leaflet.js map + tile layer
Delphi, C++ Builder, .NET
Set CenterLatitude, CenterLongitude and Zoom, pick the TileProvider, call AddMarker for each point, then read HTML.
uses
sgcHTML_Enums, sgcHTML_Component_Map;
var
oMap: TsgcHTMLComponent_Map;
begin
oMap := TsgcHTMLComponent_Map.Create(nil);
try
oMap.CenterLatitude := 40.4168;
oMap.CenterLongitude := -3.7038;
oMap.Zoom := 12;
oMap.Height := '420px';
oMap.TileProvider := mtCartoDB;
oMap.AddMarker(40.4168, -3.7038, 'Madrid', 'Head office');
oMap.AddMarker(41.3851, 2.1734, 'Barcelona');
WebModule.Response := oMap.HTML; // Leaflet map + markers
finally
oMap.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Map.hpp
TsgcHTMLComponent_Map *oMap = new TsgcHTMLComponent_Map(NULL);
try
{
oMap->CenterLatitude = 40.4168;
oMap->CenterLongitude = -3.7038;
oMap->Zoom = 12;
oMap->Height = "420px";
oMap->TileProvider = mtCartoDB;
oMap->AddMarker(40.4168, -3.7038, "Madrid", "Head office");
oMap->AddMarker(41.3851, 2.1734, "Barcelona");
String html = oMap->HTML; // Leaflet map + markers
}
__finally
{
delete oMap;
}
using esegece.sgcWebSockets;
var map = new TsgcHTMLComponent_Map();
map.CenterLatitude = 40.4168;
map.CenterLongitude = -3.7038;
map.Zoom = 12;
map.Height = "420px";
map.TileProvider = TsgcHTMLMapTileProvider.mtCartoDB;
map.AddMarker(40.4168, -3.7038, "Madrid", "Head office");
map.AddMarker(41.3851, 2.1734, "Barcelona");
string html = map.HTML; // Leaflet map + markers
The members you reach for most often.
CenterLatitude and CenterLongitude (Double) set the initial view; Zoom (default 13) sets the zoom level.
TileProvider (TsgcHTMLMapTileProvider) selects mtOpenStreetMap, mtCartoDB (light) or mtCartoDBDark.
Markers (TsgcHTMLMapMarkers) holds the pins; each TsgcHTMLMapMarker has Latitude, Longitude, PopupText, TooltipText and Color.
AddMarker(aLat, aLng, aPopup, aTooltip) drops a pin; the popup opens on click and the tooltip shows on hover.
Height (a CSS length such as '420px') controls the map height; MapID sets the container's element id.
HTML returns the Leaflet stylesheet link, the map <div> and the init script — serve it, or assign it to a page template's BodyContent.