Overlays are all the items based on geographical points that you can embed on your cards, they descend from the class TECMapItem.
TECMapItem
procedure SetPosition(const dLatitude, dLongitude: double);property Id: integer;
property ItemType : TOverlayType ;
ovCircle, ovRectangle, ovLabel, ovGlobe, ovKml, ovFusion, ovGroundOverlay,
ovWeather);
property Group : TECMapItemGroup;
Liste d'overlays
Each type is managed in a separate list, you can add, delete, import / export your items
The lists are accessible through the properties:
- tmBicycling
- tmDriving
- tmWalking
they are manipulated through methods and properties similar, only setting up the add function differs.
function Add:integer;
function Add(const dLatitude,dLongitude:double):integer;
function Add(const Url:string;const dLatitude,dLongitude:double):integer;
function Add(const Url:string):integer;
function Add(const sName:string;const dStartLatitude,dStartLongitude,dEndLatitude,dEndLongitude:double;const OptimizeWaypoints:boolean=false;const WayPoints:TLatLngList=nil):integer;
Add back in all cases the index number of the added element
17// Delphi
map component ECMap
// add circle at center of
map
id := map.Circles.add(map.latitude,map.longitude);
// fix radius to 500
meters
map.Circles[id].Radius := 500;
procedure Clear;
function Count:integer;
procedure Delete(index:integer);
property ToTxt : string
The import works as an addition, the pre-existing elements are preserved, if you want to replace them before it is imported to use Clear
18property ToKml : string
The labels are not exported to KML
6TECMapOverlay
The circles, rectangles, polylines, polygons and the type TECMapOverlay groundOverlays down, TECMap has a property of this type named EditOverlay.
By assigning a consistent overlay (circle, rectangle, polyline, polygon or GroundOverlay), you can change the mouse position and size directly from your card.
To do this you must switch EditMode property to True.
EditOverlay has the property OverlayType type of TOverlayType that lets you know the type of overlay
EditOverlay also a property
Id integer that gives you the index
number of your overlay in its list.// Delphi map component ECMap
// add circle at center of
map
id := map.Circles.add(map.latitude,map.longitude);
// fix radius to 500
meters
map.Circles[id].Radius := 500;
// edit overlay with
mouse
map.EditOverlay := map.Circles[id];
// map.EditOverlay.OverlayType =
ovCircle
// map.EditOverlay.Id =
id
Methods & Common Properties
This type of overlay sharing propertiesIndex number of the InfoWindow associated, -1 if no
When clicked on the overlay if InfoWindow is defined it will be open
Not available CloudMade
4When you change the properties Color, Opacity, Weight ZIndex or you must explicitly make a call to redraw the procedure for this to be taken into account
7// Delphi
map component ECMap
map.Polylines[0].Color :=
clRed;
map.Polylines[0].Weight :=
5;
// change property
map.Polylines[0].reDraw;
The circles, rectangles and polygons have more properties
Area : double
Polylines also have ownership Distance
19TLatLngList
Polylines and polygons have a Path property type TLatLngList, list of points comprising the figure, the following main features.Calculates the elevations of points, you can pass a procedure type TOnGetAltitude to display a progress bar (see demoOverlay and DemoRoute)
//
Delphi map component ECMap
// calcul altitude for all
point of polyline 0
// you can pass nil if you
don't show a progressbar
map.Polyline[0].Path.GetAltitudes(doGetAltitude);
...
{*
event fired by getAltitudes
@param Sender TLatLngList
@param Total number of altitude's point
calculated
@cancel flag for abort calcul
}
procedure
TFDemoRoute.doOnGetAltitude(Sender:
TLatLngList;const
Total:integer;var
cancel:boolean);
begin
ProgressAltitude.Position := total;
// cancel if press
button
cancel := btAbortAlt.tag = -1;
end;
You can directly create a TLatLngList and fill it with your points to get their altitude without having to go through a Polyline.
3Calculates the latitude and longitude of a point on the polyline / polygon depending on its distance in meters, returns True if we found a point
SensStartEnd direction of travel, true to start -> finish
lMeter the distance in meters
dLatitude,dLongitude type variables double who will receive the latitude and longitude
idPoint a variable that will contain the index in the table Point where is the point, the calculation returns an approximation because your polyline / polygon does not contain all the real points
Heading a variable to hold the angle of the point from the north ( 0 to 360°)
bEnd indicates whether it has exceeded or reaches the end of the polyline / polygon (or early depending on the direction)
The routes have the same function
20Example of handling a Polyline
// Delphi map component
ECMap
// add new polyline
id := map.Polylines.add;
// IMPORTANT for more speed
!
map.Polylines[id].Path.BeginUpdate;
// add points to polyline
id
map.Polylines[id].Path.Add(37.772323, -122.214897);
map.Polylines[id].Path.Add(21.291982, -157.821856);
map.Polylines[id].Path.Add(-18.142599, 178.431);
map.Polylines[id].Path.Add(-27.46758, 153.027892);
// update data
map.Polylines[id].Path.EndUpdate;
Events
The circles, rectangles, polylines, polygons and meet the following events groundoverlaysindex is the index of the overlay in its list
dLatitude,dLongitude geographical coordinates of the click
OverlayType the type of overlay (ovCircle, ovRectangle, ovLine, ovPolygone,ovLabel ou ovGroundOverlay)
index is the index of the overlay in its list
dLatitude,dLongitude the geographical coordinates of the click
OverlayType the type of overlay (ovMarker,ovCircle, ovRectangle, ovLine, ovPolygone,ovLabel ou ovGroundOverlay)
The markers meet this event !
21index is the index of the overlay in its list
dLatitude,dLongitude the geographical coordinates of the click
OverlayType the type of overlay (ovMarker,ovCircle, ovRectangle, ovLine, ovPolygone,ovLabel ou ovGroundOverlay)
The markers meet this event !
22CloudMade does not respond to events OnOverlayMouseDown and OnOverlayMouseUp
5CloudMade does not support right click, Alt + click trigger event (as in Google Map)
8Under Google Map you can drag and drop to move the overlay pointed by EditOverlay, but under CloudMade you must first do a CTRL + click on the map, then move the mouse while holding down CTRL to move your item (also works with Google Map)
9PathIndex indicates the index in Path
Markers Interactive
The interactive overlay markers assigned to EditOverlay also trigger eventsBy default interactive markers are represented by , you can change the icon through the Propertie IconOverlay type String, image may be a remote image on the Internet or a local file.
//
Delphi map component ECMap
// red marker
map.IconOverlay := 'http://maps.google.com/mapfiles/ms/micons/red-pushpin.png';
If you change the icon you may also need to edit the properties
Demonstration
The program DemoOverlay shows you how to easily manipulate all these elementsAll the concepts related to overlays are employed, creation, Publishing, deletion, the import / export of your card , including export to Google Earth .