TECMap can save and reload all its data in a simple text file, it includes not only the component's settings and views but also map data overlays
Alternatively, you can import/export your data in GPX, WKT, KML and GeoJSON formats but only geographical data are exploited.
Save / Load
function SaveToFile(const filename:string):boolean;Saves the map to a text file.
Use the .gpx , .wkt, .kml, .geojson and .json to specify a format, otherwise it is the internal format of ECMap that will be used
function LoadFromFile(const filename:string):boolean;Load the map with a text file
Use the .gpx , .kml , .wkt, .geojson and .json to specify a format, otherwise it is the internal format of ECMap that will be used
LoadFromFile can download files on internet
1property toGPX : string;
Property read/write which gives access to the data of the map in GPX format.
property toWKT : string;Property read/write which gives access to the data of the map in a WKT format.
property toTxt : string;Property read/write which gives access to the data of the map in a text format.
This property is used by SaveToFile, LoadFromFile.
property ToKml : string;Property in read / write which returns the overlays (all except the Labels) in Kml format
EarthView allows import/export KML in a larger format
property ToGeoJSON : string;Property in read / write which returns / import overlays (just the markers, the polylines, polygons, circles and rectangles) to GeoJSON format
The affection of a value to toTxt, ToKml, ToWKT, ToGpx, ToGeoJSON or the loading of a file with LoadFromFile causes events OnBeforeChangeToTxt and OnAfterChangeToTxt.
OnLoadOverlay is also raised after the addition of each overlay (marker, polyline, polygon,...) that may allow you to adjust properties while loading data.
You can stop the load by switching StopLoadOverlay to true
//
procedure TFormDemoECMap.mapLoadOverlay(sender: TObject; const Index: Integer; const OverlayType: TOverlayType);
begin
case OverlayType of
ovMarker : begin
// override data marker
map.markers[index].name := 'your data';
end;
ovLine : begin
// override data Polyline
map.Polylines[index].Color := clBlue;
map.Polylines[index].Update;
end;
...
end;
// stop if too many markers
map.StopLoadOverlay := map.Markers.Count>3000;
end;
Backup / Restore
Property read / write which provides access to map data in text format.
This property is used by SaveToFile, LoadFromFile.
Read-only property that returns overlays (all but Labels) in kml format
This property is used by SaveToKmlFile
EarthView allows import / export KML
Property in read / write which provides access to overlays (just the markers, polylines, polygons, circles and rectangles) in GeoJSON format
The affection of a value to toTxt causes and events OnBeforeChangeToTxt and OnAfterChangeToTxt the first place just before the change in fair value and the second after.
Setup import / export
When you import / export in text format, by default all the data are, whether the card settings (such as API, position etc.) or overlays ( markers , circles, roads etc.).
Just as when importing the old overlays are replaced by new.
Property ToTxtType offers some control.
// Delphi
map component ECMap
// valeur par défaut,
// importe/exporte tout
(map+overlay)
// remplace l'ancien contenu par le
nouveau
map.toTxtType := [ttaMap,ttaOverlays,ttaReplace];
// importe/exporte tout
(map+overlay)
// ajoute les nouveaux overlays à
ceux déjà existant
map.toTxtType := [ttaMap,ttaOverlays];
// importe/exporte uniquement les
paramètres de la carte
map.toTxtType := [ttaMap];
// importe/exporte uniquement les
overlays
map.toTxtType := [ttaOverlays];
text format
each part is divided into section, data are named and need not be in any particular order.
Overlays for each line corresponds to a data element (a marker, a circle etc.)
Example map
Import / Export overlays
Overlays have also toTxt property allowing the importation and exportation, either in their list ( Markers , Routes etc.) than the item itself.In terms of import lists is necessarily an addition, it is not considered property toTxtType which is supported at the global level.
FPanoramioLayer :=
TPanoramioLayer.create;
...
// connect TECMap component for
show Panoramio layer
FPanoramioLayer.Map := map;
// deconnect layer
FPanoramioLayer.Map := nil
When using overlays toTxt you should not give section, all properties are not necessary.
1