Delphi, C++ Builder & .NET Part of sgcUI

sgcMaps, Native Maps for Delphi, C++ Builder & .NET

Put a real map in your application without a browser control or a line of JavaScript. sgcMaps draws raster and vector tiles itself, adds layers from WMS and WMTS servers, shows thousands of clustered markers, routes and zones, geocodes addresses, and keeps working offline with local tiles and an offline router.

VCL, FireMonkey, Lazarus, WinForms, WPF, AvaloniaNo browser control, no JavaScriptFree .NET Community editionIncluded in sgcUI Enterprise
TsgcVCLMap showing central Madrid from vector tiles with red and blue location markers

Everything a Map Application Needs

Eighteen features, each with the real API and the help topic behind it.

Tiles and map data

The map control draws every tile itself, from a tile server, a WMS or WMTS service, a vector source or files on disk.

A real map in your form, no browser inside

Tiles and map data

A real map in your form, no browser inside

Most map components wrap a web view and a JavaScript library, so your desktop application ends up shipping a browser. sgcMaps does not. TsgcVCLMap and TsgcFMXMap download, cache and draw the tiles on their own canvas, handle mouse wheel zoom and drag to pan, and raise normal Delphi events. Your map is a native control like any other: it docks, it themes with the form and it debugs like the rest of your code. There is no extra process to deploy or to secure, and the map behaves the same on every machine your application runs on.

  • The Layers collection holds one or more TsgcMapLayer items, each with its own TileSourceType
  • TsgcFMXMap runs on Windows from Delphi XE6, and on macOS, iOS and Android from Delphi 10.4
  • A Lazarus LCL control shows tiles from disk
  • In .NET, SgcMapControl for WinForms, TsgcWpfMap for WPF, TsgcAvaloniaMap for Avalonia 12 and the headless MapView share one engine
  • Right to left for Arabic and Hebrew: the zoom buttons, layer switcher, compass, scale bar and attribution move to the opposite side, while the map keeps its geographic orientation
Read the help topic
Pick a tile provider with one property

Tiles and map data

Pick a tile provider with one property

Choosing a base map should not mean reading tile server documentation. Set Provider on a layer and call sgcMapApplyProvider: the layer gets the URL template, the maximum zoom and the attribution text of that provider. OpenStreetMap, OpenTopoMap, Esri World Imagery and Esri World Street work without a key. MapTiler, Thunderforest and Stadia take your own API key. Your own tile server is one URL template away. Each layer has its own provider, so a satellite layer and a street layer can sit in the same map and the user switches between them on the map itself.

  • Keyless: mtpOpenStreetMap, mtpOpenTopoMap, mtpEsriWorldImagery, mtpEsriWorldStreet
  • With your key: mtpMapTilerStreets, mtpMapTilerSatellite, mtpThunderforestCycle, mtpThunderforestTransport, mtpStadiaAlidadeSmooth
  • mtpCustom with URLTemplate reads any {z}/{x}/{y} server
  • The attribution of the provider is drawn on the map for you
  • ShowLayerSwitcher puts a layer button on the map
Read the help topic
Vector tiles that stay sharp at any size

Tiles and map data

Vector tiles that stay sharp at any size

Raster tiles blur when you scale them, and every style change means new images from the server. With vector tiles the control receives the geometry and draws roads, water, buildings and labels itself, so text stays crisp on high DPI screens and in exported images. Point a layer at a Mapbox Vector Tile server and leave VectorStyleFile empty to use the built in style, or load a MapLibre or Mapbox GL style file to match your brand. Vector layers work in the VCL and the FireMonkey control alike.

  • mtsVectorHTTP reads a vector tile server, from Delphi XE2
  • mtsVectorMBTiles reads a local vector MBTiles file (offline pack)
  • mtsVectorPMTiles reads vector tiles from a PMTiles archive, a local file or a URL (offline pack)
  • TsgcMapVectorStyle loads a style with LoadFromFile or LoadFromJSON
  • Decoding and drawing live in TsgcMapTileSource_MVT, in plain Delphi code
Read the help topic

Tiles and map data

Layers from your WMS and WMTS servers

Cities, utilities and mapping agencies publish land use, cadastre and orthophotos as OGC web services rather than as z/x/y tiles. Set TileSourceType to mtsWMS or mtsWMTS and the layer requests its images from the service, as a transparent overlay on a base map or as the base map itself. The capabilities readers list the layers a service offers and configure the layer for you, so your users pick a layer by its title instead of typing request parameters.

  • mtsWMS sends WMS 1.3.0 or 1.1.1 GetMap requests, with Layers, Styles, ImageFormat and Transparent in the WMS options of the layer
  • mtsWMTS reads KVP and REST services through the WMTS options of the layer
  • TsgcMapWMSCapabilities and TsgcMapWMTSCapabilities load the capabilities document, and ApplyToLayer sets up a layer from it
  • An exception document from the server reaches OnTileError with its text
  • In .NET, TileSourceType.Wms and TileSourceType.Wmts, with WmsCapabilities and WmtsCapabilities

In every edition, the free Community edition included, from Delphi 2009. The map stays in Web Mercator: WMS layers are requested in EPSG:3857, WMTS layers need a Web Mercator tile matrix set such as GoogleMapsCompatible, and GetFeatureInfo is not supported.

Read the help topic

Tiles and map data Registered only

Keep working when the network is gone

A field technician in a basement, a vessel at sea or a plant floor network cannot depend on a tile server. sgcMaps reads tiles from disk exactly as it reads them from the web. Give a layer a CacheFolder and every tile it fetches is kept for the next run. For a complete offline pack, TsgcMapTileDownloader fetches an area and a zoom range ahead of time into a folder or an MBTiles file.

  • mtsFolder reads a z/x/y folder of PNG or JPEG tiles
  • mtsMBTiles reads a raster MBTiles file, from Delphi XE7 (FireDAC SQLite)
  • CountTiles tells you the size of a download before you start it; DelayMS and OnProgress keep it polite and visible
  • Bulk downloads must respect the terms of the provider: OpenStreetMap tiles are for interactive viewing only

Community reads z/x/y tile folders and keeps the per layer CacheFolder. The tile downloader, MBTiles and PMTiles files belong to the offline pack.

Read the help topic

Tiles and map data Registered only

A whole region in one PMTiles file

A PMTiles archive holds a complete tile pyramid in a single file that you copy to a laptop or put on any static web server, with no tile server to run. sgcMaps reads the archive from a local file, or straight from a web server with HTTP range requests, and keeps the directories it has read in a cache, so only the tiles in view travel over the network.

  • mtsPMTiles for PNG and JPEG raster archives, mtsVectorPMTiles for Mapbox Vector Tile archives
  • TileSourcePath takes a file name or an http or https URL
  • TsgcMapTileSource_PMTiles reports the zoom range, the bounds, the centre and the metadata of the archive
  • PMTiles version 3; archives with WebP tiles are reported as unsupported
  • From Delphi XE2, and in the Registered esegece.sgcMaps package for .NET

PMTiles belongs to the offline pack, like MBTiles, so it is in the Registered edition and not in the free Community edition.

Read the help topic

Markers, shapes and geometry

Put your own data on the map, keep it readable at every zoom level and do the math behind it.

Markers, shapes and geometry

Thousands of markers, still readable

A fleet, a store network or a sensor grid quickly turns into a cloud of overlapping pins. Turn on clustering and nearby markers merge into one numbered bubble that splits again as the user zooms in, recomputed at every zoom level. Each marker carries its own popup, tooltip and icon, and clicks, drags and cluster clicks arrive as events, so the map becomes part of your workflow instead of a picture. Markers can be added in a loop from your data or imported from GeoJSON, GPX and KML files, and ClearMarkers resets them in one call.

  • MarkerOptions.Clustering with GridSize, MinClusterSize and ZoomOnClick
  • PopupText, TooltipText and IconBitmap per marker
  • OnMarkerClick, OnClusterClick and OnMarkerDragEnd events
  • BeginUpdate and EndUpdate around bulk loads; FitToMarkers frames them all
  • MarkerAtScreen and ClusterAtScreen hit test any pixel
Read the help topic
Routes, zones and heatmaps on one map

Markers, shapes and geometry

Routes, zones and heatmaps on one map

Most map screens need more than pins: the planned delivery route, the area a depot serves, a radius around a customer, where the orders come from. sgcMaps draws all of them as items of the map model, in the same coordinates as your markers. Shapes can be made editable, so a user can drag the vertices of a zone with the mouse and your code is told when the edit ends. Labels place text at a coordinate with their own font, color and background, which keeps zone names and route numbers attached to the map.

  • AddPolyline with Dashed and Geodesic lines
  • AddPolygon with AddHole, plus AddRectangle, AddCircle (RadiusMeters) and AddLabel
  • Editable shapes report changes through OnShapeEdited
  • TsgcMapHeatmap takes weighted points with AddPoint and a MaxIntensity
Read the help topic

Markers, shapes and geometry

The geo math is already written

Is this vehicle inside the zone? How far is the nearest depot? Which point of the route is closest to the customer? These questions come up in every map application and are easy to get wrong near the poles or across long distances. The geometry unit answers them on the WGS84 sphere with plain functions you can also call from a service with no map at all. The functions take plain TsgcMapCoord records, and sgcMapLatLonToPixel and sgcMapPixelToLatLon convert between screen and world coordinates when you draw your own overlays.

  • sgcMapDistance in meters, sgcMapInitialBearing and sgcMapDestinationPoint
  • sgcMapPointInPolygon and sgcMapPointInPolygonWithHoles for geofences
  • sgcMapNearestPointOnPolyline snaps a position to a route
  • sgcMapGeodesicInterpolate and sgcMapSimplify for smooth, light lines
Read the help topic

Search and routing

Find addresses and plan routes with online providers, or fully offline with no API key.

Search and routing

Geocoding, directions and places behind one API

Every geocoding and routing provider has its own REST format, keys and quirks. The service components hide them: you pick a provider, set your key when it needs one and call the same methods, synchronously or async. Switching from one provider to another is a property change, not a rewrite, and results come back as Delphi objects ready to put on the map. Every component shares the TsgcMapService base class, so ApiKey, UserAgent and LastError work the same way for every provider.

  • TsgcMapGeocoder: Nominatim, Google, HERE, Azure Maps, Mapbox, OpenRouteService and Geoapify
  • TsgcMapDirections: OSRM, OpenRouteService, Google Routes, HERE, Azure Maps, Mapbox and Geoapify
  • TsgcMapPlaces for address autocomplete, TsgcMapElevation and TsgcMapTimeZone
  • GeocodeAsync, GetRouteAsync and SuggestAsync keep the UI responsive; errors arrive in OnError
Read the help topic

Search and routing Registered only

Routes and address search with no internet and no key

Online routing fails exactly where field apps are used, and every request may cost money. The offline router computes car, bike and foot routes on the device from a route graph built once from an OpenStreetMap extract. The offline geocoder searches place names and reverse geocodes a click from a GeoNames index in SQLite. Both run with no network, no account and no per request fee. The router and the geocoder are non visual components, so a Windows service or a console tool can answer route and address requests with no map on screen.

  • TsgcMapOfflineRouter answers GetRoute from a graph built by TsgcMapRouteGraphBuilder from .osm.pbf
  • sgcMapAddRouteToPolylines draws the result on the map
  • TsgcMapOfflineGeocoder with ReverseGeocode, over an index from TsgcMapGeoIndexBuilder
  • Command line builders for the graph and the index are in the Tools folder

Community uses the online services; the offline router and geocoder belong to the offline pack.

Read the help topic

Files, rendering and mobile

Exchange geodata with other tools, render maps where there is no screen, and take the map to a phone, a WPF window or an Avalonia window.

Files, rendering and mobile

Open the files your users already have

Customers send tracks from a GPS watch, zones drawn in a GIS tool or a KML from another system. sgcMaps reads and writes GeoJSON, GPX and KML straight into the map model, so an import is one call and an export is another. GPX tracks come with their statistics and can be colored by elevation, and a streaming reader walks large OpenStreetMap extracts without loading them into memory. Exports use the same functions in reverse, so zones a user drew on the map can be saved as GeoJSON or KML and opened in other GIS tools.

  • sgcMapLoadGeoJSONFile and sgcMapSaveGeoJSONFile, from Delphi XE6
  • TsgcMapGPX with TrackStats (TotalAscent, TotalDescent) and ColorByElevation
  • sgcMapLoadKMLFile and sgcMapSaveKMLFile
  • The OpenStreetMap reader streams .osm.pbf and XML files through events
  • sgcMapGeoJSONAsText returns the GeoJSON of the map as a string
Read the help topic

Files, rendering and mobile

Shapefiles and WKT from any GIS

Public geodata still ships as Esri shapefiles, and spatial databases exchange geometry as Well Known Text. TsgcMapShapefile imports the points, lines and polygons of a shapefile together with its attribute table, so every marker can show the record it came from. WKT and the EWKT written by PostGIS are read and written, which is the simplest way to move a zone between the map and a geometry column of your database.

  • LoadFromFile reads the .shp with its .shx, .dbf, .prj and .cpg files; OnItem receives each attribute row and LabelField sets the popup text of the points
  • A .prj in WGS84, ETRS89 or NAD83 degrees, or in Web Mercator, loads directly, and a file with no .prj is read as WGS84
  • Any other projection raises a clear error, unless your OnTransform handler converts the coordinates
  • sgcMapLoadWKT and TsgcMapWKT read POINT, LINESTRING, POLYGON, their MULTI forms and GEOMETRYCOLLECTION, in degrees or Web Mercator metres, and AsText writes the map back
  • In every edition from Delphi 7; in .NET, ShapefileFormat and WktFormat with a Transform callback
Read the help topic
Render map images on a server

Files, rendering and mobile

Render map images on a server

Delivery notes with the route, a daily report with today's incidents, a thumbnail for a web page: many maps are never shown in a window. The same control renders to a PNG or a bitmap without being visible, from a console application or a Windows service. You can check whether every tile arrived before you send the image, so a slow tile server never ends up as a grey square in a customer document. Server side rendering uses the same layers, markers and shapes as the interactive control, so a map designed on screen looks the same in the PNG.

  • SaveToPNG and SaveToPNGFile, from Delphi 2009
  • RenderToBitmap and SaveToBMPFile for your own pipeline
  • LastRenderMissingTiles reports tiles that were not available
  • In .NET, MapView.RenderToPng also runs on Linux
Read the help topic

Files, rendering and mobile

The same map on desktop and mobile

A dispatcher plans on a Windows desktop and the driver follows the plan on a phone. TsgcFMXMap brings the same model, layers, markers, shapes and services to FireMonkey on Windows, macOS, iOS and Android, so the code you wrote for the VCL map carries over. TsgcMapLocation reads the position of the device, so the map can center on the user and follow them. The per layer tile cache works on mobile too, so a phone keeps showing the areas it has already loaded.

  • TsgcFMXMap on Windows from Delphi XE6, and on macOS, iOS and Android from Delphi 10.4 (macOS ARM from Delphi 11), with the same collections as TsgcVCLMap
  • TsgcMapLocation on Windows, Android, iOS and macOS
  • The FMX demo shows tiles, markers and location in one form, and the FMX Mobile demo is laid out for phones and tablets
  • The framework neutral core also compiles for Linux 64 bit from Delphi 10.4, for console and server applications that use the tile sources, the file formats and the offline data
  • Three runtime packages, sgcMaps (the core), sgcMapsVCL and sgcMapsFMX, so a FireMonkey application no longer loads the VCL packages
  • Per feature minimum Delphi versions are listed in the installation topic
Read the help topic

Files, rendering and mobile

The map in WPF and Avalonia, declared in XAML

TsgcWpfMap and TsgcAvaloniaMap bring the .NET map engine to WPF and to Avalonia 12 with the features of the WinForms control: pan and zoom with the mouse, touch and keyboard, layers, markers, shapes, printing, PDF export and UI Automation. Layers and markers are declared in XAML under the sgc prefix, and a collection of your view model becomes markers through ItemsSource, so adding a store to the collection puts it on the map and dragging its marker writes the new position back.

  • LatitudeMember, LongitudeMember, TooltipMember, PopupMember, ColorMember and DraggableMember map your properties to markers
  • SelectedItem, Zoom, Bearing, CenterLatitude and CenterLongitude bind two way
  • Colors are written in XAML as #AARRGGBB or #RRGGBB text
  • NuGet esegece.sgcMaps.Wpf (net8.0-windows to net10.0-windows) and esegece.sgcMaps.Avalonia (net8.0 to net10.0), both with a free Community package
  • The WpfDemo and AvaloniaDemo projects show the same window in both frameworks
Read the help topic

Accessibility

UI Automation for screen readers and the keyboard, with no setup.

Accessibility

A map that the keyboard can reach and UI Automation exposes

sgcMaps exposes the map to Microsoft UI Automation with a text alternative, the markers as a list and the layers as a list, where each layer reports whether it is visible. The markers can be reached with the keyboard.

  • Arrows pan the map, the plus and minus keys zoom, and Home returns to the start view
  • Page Up and Page Down move to the previous or next marker, Enter activates the focused marker and Esc clears the marker focus
  • The map shows a visible focus ring while it has the focus
  • In .NET, the WinForms, WPF and Avalonia map controls expose the same UI Automation structure and keyboard

Accessibility is on by default in every edition, the free Community edition included, on VCL in every Delphi and C++Builder version from Delphi 7 to Delphi 13, on FireMonkey on Windows, and on WinForms, WPF and Avalonia. In Delphi and C++Builder, AccessibleName and AccessibleDescription set the name and the description exposed to UI Automation, and in .NET the standard accessible name and help text of each framework do the same. See the accessibility conformance reports, which do not cover the new WPF and Avalonia map controls yet. The map image is described by its centre and zoom only, and the map renderer does not follow Windows high contrast, because the map image is tile imagery from the provider.

Read the help topic

See sgcMaps in action

sgcMaps inside the sgcUI suite demos: complete applications that run offline with built-in simulated data.

Who Builds with sgcMaps

Field service and logistics

Technicians and drivers need the map where coverage is poor. Prepare the tiles of a region ahead of time, compute car routes on the device with the offline router and find addresses with the offline geocoder. Back at the office, the same code draws the planned routes and delivery zones, and renders a PNG of each route for the delivery note.

  • Works offline
  • Offline routing
  • Routes and zones
  • Map images
Run the OfflineServices demo

Asset and fleet tracking

A control room watches hundreds of vehicles, machines or sensors at once. Clustering keeps the map readable at country level and splits into single pins at street level. A heatmap shows where incidents concentrate, geofence checks with point in polygon raise alerts, and marker click events open the record of the asset in your own forms.

  • Clustering
  • Heatmaps
  • Geometry
  • Events
Run the MapFeatures demo

Light GIS and outdoor apps

Planning tools, sports apps and survey software live on GPX tracks, KML layers and GeoJSON zones. sgcMaps imports and exports all three, shows track statistics and elevation colors, and puts the result on a topographic base map. The FireMonkey control takes the same features to a tablet or a phone in the field. Track statistics give the total ascent and descent of a route at a glance.

  • GeoJSON, GPX, KML and shapefiles
  • Topographic tiles
  • FireMonkey
Run the OfflineMap demo

A Map in a Few Lines

The same API in Delphi, C++ Builder and C#: OpenStreetMap tiles, three markers, a geodesic line and a radius, fitted to the markers and saved as PNG.

A VCL map built in code: a cached OpenStreetMap layer, markers, a geodesic line and a circle, then a PNG of the result.

uses
  SysUtils, Controls, Graphics, sgcMaps_Classes, sgcMaps_Providers,
  sgcMaps_Geometry, sgcMaps_VCL;

// OpenStreetMap with cached tiles, three capitals, a geodesic flight line
// and a 300 km radius, fitted to the markers and saved as PNG.
procedure BuildMap(aOwner: TWinControl);
var
  oMap: TsgcVCLMap;
  oLayer: TsgcMapLayer;
  oLine: TsgcMapPolyline;
begin
  oMap := TsgcVCLMap.Create(aOwner);
  oMap.Parent := aOwner;
  oMap.Align := alClient;

  oLayer := oMap.Layers.Add;
  oLayer.Name := 'OpenStreetMap';
  oLayer.Provider := mtpOpenStreetMap;
  sgcMapApplyProvider(oLayer);
  oLayer.CacheFolder := ExtractFilePath(ParamStr(0)) + 'tile_cache';

  oMap.AddMarker(48.8566, 2.3522, 'Paris', 'France');
  oMap.AddMarker(52.5200, 13.4050, 'Berlin', 'Germany');
  oMap.AddMarker(41.9028, 12.4964, 'Rome', 'Italy');
  oMap.MarkerOptions.Clustering.Enabled := True;

  oLine := oMap.AddPolyline;
  oLine.Geodesic := True;
  oLine.Dashed := True;
  oLine.Color := clRed;
  oLine.AddPoint(48.8566, 2.3522);
  oLine.AddPoint(52.5200, 13.4050);

  oMap.AddCircle(48.8566, 2.3522, 300000).FillOpacity := 0.15;
  oMap.FitToMarkers(40);
  oMap.AddLabel(50.7, 8, Format('Paris to Berlin: %.0f km',
    [sgcMapDistance(48.8566, 2.3522, 52.52, 13.405) / 1000]));
  oMap.SaveToPNG('europe.png', 1200, 800);
end;

Read the help topic →

The same map in C++ Builder with the generated sgcMaps headers.

#include <vcl.h>
#include "sgcMaps_Classes.hpp"
#include "sgcMaps_Providers.hpp"
#include "sgcMaps_Geometry.hpp"
#include "sgcMaps_VCL.hpp"

// OpenStreetMap with cached tiles, three capitals, a geodesic flight line
// and a 300 km radius, fitted to the markers and saved as PNG.
void BuildMap(TWinControl *aOwner)
{
  TsgcVCLMap *oMap = new TsgcVCLMap(aOwner);
  oMap->Parent = aOwner;
  oMap->Align = alClient;

  TsgcMapLayer *oLayer = oMap->Layers->Add();
  oLayer->Name = "OpenStreetMap";
  oLayer->Provider = mtpOpenStreetMap;
  sgcMapApplyProvider(oLayer);
  oLayer->CacheFolder = ExtractFilePath(ParamStr(0)) + "tile_cache";

  oMap->AddMarker(48.8566, 2.3522, "Paris", "France");
  oMap->AddMarker(52.5200, 13.4050, "Berlin", "Germany");
  oMap->AddMarker(41.9028, 12.4964, "Rome", "Italy");
  oMap->MarkerOptions->Clustering->Enabled = true;

  TsgcMapPolyline *oLine = oMap->AddPolyline();
  oLine->Geodesic = true;
  oLine->Dashed = true;
  oLine->Color = clRed;
  oLine->AddPoint(48.8566, 2.3522);
  oLine->AddPoint(52.5200, 13.4050);

  oMap->AddCircle(48.8566, 2.3522, 300000)->FillOpacity = 0.15;
  oMap->FitToMarkers(40);
  int iKm = (int)(sgcMapDistance(48.8566, 2.3522, 52.52, 13.405) / 1000);
  oMap->AddLabel(50.7, 8, "Paris to Berlin: " + IntToStr(iKm) + " km");
  oMap->SaveToPNG("europe.png", 1200, 800, false);
}

Read the help topic →

The headless MapView renders the same map to a PNG file, on Windows or Linux.

using System;
using System.IO;
using esegece.sgcMaps;
using esegece.sgcMaps.Rendering;

// OpenStreetMap with cached tiles, three capitals, a geodesic flight line
// and a 300 km radius, fitted to the markers and saved as PNG (no window).
public static class EuropeMap
{
    public static void Render()
    {
        var oMap = new MapView();

        Layer oLayer = oMap.Layers.Add();
        oLayer.Name = "OpenStreetMap";
        oLayer.Provider = TileProvider.OpenStreetMap;
        MapProviders.ApplyProvider(oLayer);
        oLayer.CacheFolder = Path.Combine(AppContext.BaseDirectory, "tile_cache");

        oMap.AddMarker(48.8566, 2.3522, "Paris", "France");
        oMap.AddMarker(52.5200, 13.4050, "Berlin", "Germany");
        oMap.AddMarker(41.9028, 12.4964, "Rome", "Italy");
        oMap.MarkerOptions.Clustering.Enabled = true;

        Polyline oLine = oMap.AddPolyline();
        oLine.Geodesic = true;
        oLine.Dashed = true;
        oLine.Color = MapColors.Red;
        oLine.AddPoint(48.8566, 2.3522);
        oLine.AddPoint(52.5200, 13.4050);

        oMap.AddCircle(48.8566, 2.3522, 300000).FillOpacity = 0.15;
        oMap.FitToMarkers(40);
        double vKm = MapGeometry.Distance(48.8566, 2.3522, 52.52, 13.405) / 1000;
        oMap.AddLabel(50.7, 8, $"Paris to Berlin: {vKm:F0} km");
        oMap.RenderToPng("europe.png", 1200, 800);
    }
}
dotnet add package esegece.sgcMaps.Rendering

Read the help topic →

WMS Layers, Shapefiles and the Map in WPF

A WMS overlay and a shapefile import with its attributes in Delphi, and a WPF window with the map, a layer and a marker declared in XAML.

A transparent WMS overlay with its own tile cache, and a shapefile whose parks are filled in green from the attribute table. Both work in every edition.

uses
  Classes, SysUtils, Graphics, sgcMaps_Classes, sgcMaps_VCL, sgcMaps_Shapefile;

procedure TForm2.AddWMSLayer;
var
  oLayer: TsgcMapLayer;
begin
  // an overlay drawn by a WMS server
  oLayer := sgcVCLMap1.Layers.Add;
  oLayer.Name := 'Land use';
  oLayer.TileSourceType := mtsWMS;
  oLayer.URLTemplate := 'https://maps.example.com/geoserver/wms';
  oLayer.WMS.Layers := 'landuse,rivers';
  oLayer.WMS.Version := mwv130;
  oLayer.WMS.ImageFormat := 'image/png';
  oLayer.WMS.Transparent := True;
  oLayer.IsBaseLayer := False;
  oLayer.Opacity := 0.7;
  oLayer.CacheFolder := ExtractFilePath(ParamStr(0)) + 'cache\landuse';
end;

procedure TForm2.ImportLandUse;
var
  oShp: TsgcMapShapefile;
begin
  oShp := TsgcMapShapefile.Create;
  try
    // points get the NAME field as popup text (the field must exist)
    oShp.LabelField := 'NAME';
    oShp.OnItem := ShapefileItem;
    // reads landuse.shx, .dbf, .prj and .cpg next to the .shp
    oShp.LoadFromFile('C:\Data\landuse.shp', sgcVCLMap1.Markers,
      sgcVCLMap1.Polylines, sgcVCLMap1.Polygons);
    memoLog.Lines.Add(Format('%d records, %d skipped, fields: %s',
      [oShp.RecordCount, oShp.SkippedCount, oShp.Fields.CommaText]));
  finally
    oShp.Free;
  end;
end;

procedure TForm2.ShapefileItem(Sender: TObject; aRecord: Integer;
  aAttributes: TStrings; aItem: TCollectionItem);
begin
  // aAttributes holds the .dbf row as Name=Value lines
  if (aItem is TsgcMapPolygon) and (aAttributes.Values['USE'] = 'PARK') then
    TsgcMapPolygon(aItem).FillColor := clGreen;
end;

Read the WMS topic → Read the shapefile topic →

The layers and markers of a TsgcWpfMap are declared in XAML under the sgc prefix. The code behind adds a tile cache, a line and three events.

<Window x:Class="MapQuickStartWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sgc="https://www.esegece.com/sgcui"
        Title="sgcMaps WPF Quick Start" Width="1000" Height="700">
  <sgc:TsgcWpfMap x:Name="MainMap" CenterLatitude="40.4168" CenterLongitude="-3.7038" Zoom="14">
    <sgc:TsgcWpfMap.Layers>
      <sgc:Layer Name="OpenStreetMap" Provider="OpenStreetMap" />
    </sgc:TsgcWpfMap.Layers>
    <sgc:TsgcWpfMap.Markers>
      <sgc:Marker Latitude="40.4168" Longitude="-3.7038" PopupText="Puerta del Sol"
                  TooltipText="Drag me" Draggable="True" Color="#FFE53935" />
    </sgc:TsgcWpfMap.Markers>
  </sgc:TsgcWpfMap>
</Window>
using System;
using System.IO;
using System.Windows;
using esegece.sgcMaps;

namespace MapQuickStartWpf
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            // cache the tiles of the layer declared in XAML
            MainMap.Layers[0].CacheFolder = Path.Combine(AppContext.BaseDirectory, "tile_cache");

            // a line from Puerta del Sol to Retiro Park
            Polyline line = MainMap.Map.AddPolyline();
            line.AddPoint(40.4168, -3.7038);
            line.AddPoint(40.4153, -3.6844);
            line.Color = MapColors.Blue;
            line.Width = 4;

            MainMap.MapClick += (s, e) => Title = $"Click at {e.Latitude:F5}, {e.Longitude:F5}";
            MainMap.MarkerDragEnd += (s, e) => Title = $"Dropped at {e.Item.Latitude:F5}, {e.Item.Longitude:F5}";
            MainMap.TileError += (s, e) => Title = $"Tile {e.Zoom}/{e.X}/{e.Y}: {e.Error}";
        }
    }
}
dotnet add package esegece.sgcMaps.Wpf

Read the help topic →

Run the sgcMaps Demos

Eleven Delphi demos and eight .NET demos ship with sgcMaps. There are no C++ Builder demo projects.

Registered only OfflineMap

Folder, MBTiles and online tiles, markers and shapes, plus GeoJSON, GPX and KML import.

MapFeatures

Providers and API keys, marker clustering, shape editing, heatmaps and image export.

Services

Place search, geocoding, directions, elevation, time zones and device location with the online providers. Delphi XE8 and later.

Registered only OfflineServices

Build a GeoNames index and an OpenStreetMap route graph, then search places and route a car, bike or walk with no network.

StaticRender

StaticRender

A console program that renders a map to a PNG or BMP file with no window.

FMX

The FireMonkey map with tiles, markers and device location, for Windows, macOS, iOS and Android. Delphi XE6 and later.

VectorTiles

VectorTiles

A vector tile server drawn with the built in style or a style file of your own, with crisp labels at every zoom.

FMXMobile

The FireMonkey map made for phones and tablets: one finger pan, pinch zoom, big zoom buttons, your position with an accuracy circle and a list of places. Delphi 10.4 and later.

OGCServices

Loads a WMS or WMTS capabilities document from a URL or a file, lists the layers and adds the one you pick as an overlay on OpenStreetMap, with an opacity slider. Delphi 2009 and later.

Registered only PMTiles

Opens a raster or vector PMTiles archive from a file or a URL, shows its header and metadata, and adds it as a layer centred on the archive. Delphi XE2 and later.

ShapefileWKT

Imports a shapefile with its attribute table, shows the record of a clicked marker, and imports and exports WKT.

WinFormsDemo

The .NET SgcMapControl in a WinForms window with providers, markers and shapes.

WpfDemo

The WPF map declared in XAML: base layers and markers in markup, stores bound as markers with ItemsSource, zoom and bearing sliders, printing and PDF export.

AvaloniaDemo

The same window with the Avalonia 12 map control and compiled bindings.

OgcServicesDemo

The WinForms map control with an OpenStreetMap base layer and one overlay from a WMS or WMTS service: loads a capabilities document from a URL or a file, lists the layers, adds the one you pick with an opacity slider and shows tile errors.

Registered only PMTilesDemo

The WinForms map control with a layer from a raster or vector PMTiles archive, opened from a file or a URL, with its header and metadata and the map centred on the archive.

ShapefileWktDemo

The WinForms map control importing a shapefile with its attribute table and the record of a clicked marker, plus WKT import and export of the overlays.

Registered only OfflineDemo

The .NET offline package: offline tiles, routing and geocoding from local data files.

ConsoleRenderDemo

ConsoleRenderDemo

A .NET console that renders a map to PNG with the headless MapView, on Windows or Linux.

Compiled demos

Ready to run executables of every sgcUI product, nothing to install.

Download sgcUI_bin.zip →

Getting Started guide

Five QuickStart demos for Delphi (VCL) ship in Demos\Maps\00.QuickStart. The PDF guide walks through them step by step: a first map with markers, markers and labels added in code, shapes, the map events, and a store locator.

Download the guide (PDF) →

Where sgcMaps Is Included

sgcMaps is part of sgcUI Enterprise, and it is also sold on its own. sgcMaps is also included in the All-Access bundle.

sgcMaps single package

€149 / developer, full source code, 1 year of updates.

Buy sgcMaps → See pricing →

sgcUI Enterprise

All 17 sgcUI products, from €699.

See Enterprise →

The free .NET Community edition (NuGet esegece.sgcMaps.Community, esegece.sgcMaps.Rendering.Community, esegece.sgcMaps.WinForms.Community, esegece.sgcMaps.Wpf.Community, esegece.sgcMaps.Avalonia.Community) has every feature except the offline pack. The esegece.sgcMaps.Offline package is Registered only. A project references either the Community or the Registered packages, never both.

FeatureCommunity (free)Registered
VCL, FireMonkey, WinForms, WPF and Avalonia map controls✓✓
Tile providers, HTTP and vector tile servers✓✓
WMS and WMTS layers✓✓
z/x/y tile folders and the per layer tile cache✓✓
Markers, clustering, shapes, labels and heatmaps✓✓
Geometry functions✓✓
GeoJSON, GPX and KML import and export✓✓
Shapefile import, WKT import and export✓✓
Online geocoding, directions, places, elevation and time zones✓✓
Static rendering to PNG✓✓
Tile downloader for offline packs−✓
MBTiles and PMTiles files (raster and vector)−✓
Offline router and offline geocoder−✓

Supported Frameworks and Platforms

Components in sgcMaps

TsgcVCLMap and TsgcFMXMap

The map controls for VCL and FireMonkey, plus a Lazarus LCL control that reads tiles from disk.

Model collections

Layers, Markers, Polylines, Polygons, Rectangles, Circles, Labels and Heatmaps, shared by every framework.

Online services

TsgcMapGeocoder, TsgcMapDirections, TsgcMapPlaces, TsgcMapElevation and TsgcMapTimeZone.

Offline tools

TsgcMapRouteCalculator, TsgcMapOfflineRouter, TsgcMapOfflineGeocoder, TsgcMapGeoIndexBuilder and TsgcMapTileDownloader.

GIS formats and OGC services

TsgcMapShapefile, TsgcMapWKT, TsgcMapWMSCapabilities, TsgcMapWMTSCapabilities and TsgcMapTileSource_PMTiles.

TsgcMapLocation and geometry helpers

Device location, and sgcMapDistance, bearing, destination point, geodesic interpolation, point in polygon and line simplification.

.NET maps

SgcMapControl for WinForms, TsgcWpfMap for WPF, TsgcAvaloniaMap for Avalonia 12, and MapView, the headless engine that renders to PNG, also on Linux.

TargetComponentPlatforms
Delphi 7 to 13, VCLTsgcVCLMap and the modelWin32, Win64 from XE2, and ARM64EC in Delphi 13
Delphi XE6 to 13, FireMonkeyTsgcFMXMapWindows from XE6; macOS, iOS and Android from Delphi 10.4 (macOS ARM from Delphi 11); device location on Windows, Android, iOS and macOS
Delphi 10.4 to 13, Linux 64 bitThe framework neutral core, no map controlTile sources, services, file formats and offline data in console and server applications
C++ Builder 2007 to 13TsgcVCLMap, TsgcFMXMap from XE6, and the modelWindows only: Win32, Win64 from XE3 and Win64x in C++ Builder 13, with generated .hpp headers and static libraries
LazarusLCL map controlTiles from disk only, it cannot download tiles
.NET 8, 9 and 10SgcMapControl, TsgcWpfMap, TsgcAvaloniaMap, MapViewWinForms and WPF (net8.0-windows, net9.0-windows, net10.0-windows), Avalonia 12 (net8.0, net9.0, net10.0), headless PNG on Windows and Linux

Delphi packages: sgcMaps holds the framework neutral core, sgcMapsVCL the VCL map and sgcMapsFMX the FireMonkey map, with the design-time packages dclsgcMaps and dclsgcMapsFMX. A project built with runtime packages that lists sgcMaps adds sgcMapsVCL or sgcMapsFMX. See Packages and Platforms.

Frequently Asked Questions

No. The tiles, markers and shapes are drawn natively by the control, so there is no web view, no JavaScript library and no browser runtime to deploy.

Not for OpenStreetMap, OpenTopoMap and the Esri tiles, and not for the offline router and geocoder. MapTiler, Thunderforest and Stadia tiles, and the commercial geocoding and routing providers, use your own key. Every provider keeps its own usage terms, which your application has to respect.

Yes. Tiles can come from z/x/y folders, a per layer cache, MBTiles files or PMTiles archives, routes from TsgcMapOfflineRouter and address search from TsgcMapOfflineGeocoder. MBTiles, PMTiles, the tile downloader and the offline router and geocoder are part of the offline pack of the Registered edition.

GeoJSON, GPX, KML and WKT with EWKT, for import and export, and Esri shapefiles with their attributes for import, with GPX track statistics and elevation colors. A streaming reader also processes OpenStreetMap .osm.pbf and XML files, which is how the offline route graph is built. See File Formats, Shapefile and WKT.

The model, the VCL control, shapefiles and WKT work from Delphi 7 and C++ Builder 2007. Some features have a higher minimum: PNG output, tile servers, WMS and WMTS from Delphi 2009, vector tiles, PMTiles and the offline router from XE2, FireMonkey on Windows and GeoJSON from XE6, MBTiles and the offline geocoder from XE7, online services from XE8. FireMonkey on macOS, iOS and Android, and the core units on Linux 64 bit, need Delphi 10.4 or later.

Yes. A layer with TileSourceType mtsWMS or mtsWMTS requests its images from a WMS 1.1.1 or 1.3.0 service, or from a WMTS service in KVP or REST encoding, and the capabilities readers set the layer up from the service description. The map is Web Mercator, so WMS layers are requested in EPSG:3857 and WMTS services need a Web Mercator tile matrix set. WMS and WMTS are in every edition, Community included. See WMS and WMTS.

Yes. TsgcWpfMap (NuGet esegece.sgcMaps.Wpf) and TsgcAvaloniaMap (esegece.sgcMaps.Avalonia, Avalonia 12) host the same engine as the WinForms SgcMapControl. Layers and markers can be declared in XAML, markers bound to a collection with ItemsSource, and the view bound two way. Both are in the free Community edition too. See Quick Start WPF and Quick Start Avalonia.

The demo projects are Delphi only, but the components install in C++ Builder 2007 to 13 and work the same way. The C++ Builder tab in the code section above shows the same map built with the generated headers.

Yes. The Community edition is free for individuals and organizations under EUR 1M annual gross revenue with no more than 5 developers. It has every feature except the offline pack. On .NET the packages are esegece.sgcMaps.Community, esegece.sgcMaps.Rendering.Community, esegece.sgcMaps.WinForms.Community, esegece.sgcMaps.Wpf.Community and esegece.sgcMaps.Avalonia.Community. WMS, WMTS, shapefiles, WKT and the WPF and Avalonia controls are in Community too. Larger organizations need a Registered license.

sgcMaps Help

3,000+Developers
20+Years
761+Components
30+API Integrations
5Platforms
30-Day Money-Back GuaranteeNot satisfied? Request a full refund within 30 days of purchase. See refund policy

Try sgcMaps Today

The sgcUI trial includes sgcMaps with the offline pack and every other sgcUI product. The .NET Community edition is free on NuGet.