Composant Delphi / Google Maps / OpenStreetMap / Leaflet  / Mappilary / Native Maps 100% Delphi 0% WebBrowser 0% Javascript

Overlays

you are here :TECMap

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);
The geographical position of the element
procedure AddToGroup(const GroupName:string);
Adds the item in a Group

property Id: integer;

Index of the element in its list

property ItemType : TOverlayType ;

TOverlayType = (ovNone, ovMarker, ovRoute, ovLine, ovPolygone, ovMap,
ovCircle, ovRectangle, ovLabel, ovGlobe, ovKml, ovFusion, ovGroundOverlay,
ovWeather);

property Group : TECMapItemGroup;

Indicates the group to which the element belongs, position at Nil to the element of the Group

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;

Pour les Polylines, Polygones et Labels

function Add(const dLatitude,dLongitude:double):integer;

Pour les Markers, Circles et Rectangles

function Add(const Url:string;const dLatitude,dLongitude:double):integer;

Pour les GroundOverlays, l'url pointant une image

function Add(const Url:string):integer;

Pour les KmlLayers, l'url pointant un fichier Kml

function Add(const sName:string;const dStartLatitude,dStartLongitude,dEndLatitude,dEndLongitude:double;const OptimizeWaypoints:boolean=false;const WayPoints:TLatLngList=nil):integer;

For Routes

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;

removes all elements

function Count:integer;

returns the element number

procedure Delete(index:integer);

remove the element number index

property ToTxt : string

property read / write to export / import format text all the elements

 

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

18

property ToKml : string

Export kml of all elements

The labels are not exported to KML

6

TECMapOverlay

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

TOverlayType = (ovNone, ovMarker, ovRoute, ovLine, ovPolygone, ovMap, ovCircle, ovRectangle, ovLabel, ovGlobe, ovKml, ovGroundOverlay);

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 properties
Color : TColor
Line Color outside
Clickable : boolean
Whether to allow the element to react to mouse click, if False the overlay will not switch to edit mode even if EditMode is True.
Geodesic : boolean
Make each edge as a geodesic (a segment of a "great circle"). A geodesic is the shortest path between two points along the surface of the Earth.
Id : integer
Index number of the overlay in its list
InfoWindow : integer

Index number of the InfoWindow associated, -1 if no

When clicked on the overlay if InfoWindow is defined it will be open

Not available CloudMade

4
Opacity : double
Percentage of opacity of the color
Visible : boolean
Visible or not
Weight : integer
Line thickness
ZIndex : integer
Index of depth compared to other overlays to determine if an overlay is "above" another
ToTxt : string
Property read / write to export / import format text all the properties of the overlay
Tag : integer
You can use this property as seems

When 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
Surface m²
Distance : double
Distance from the periphery in mètre
FillColor : TColor
Interior Color
FillOpacity : double
Percentage of opacity of the color of interior

Polylines also have ownership Distance

19
The circles have the properties
Center : TLatLng
Coordinates of the center of the circle
Radius : Integer
Radius in meters
The rectangles have the properties
Height : double
Height in meters
Width : double
Width in meters

TLatLngList

Polylines and polygons have a Path property type TLatLngList, list of points comprising the figure, the following main features.
function Add(const dLatitude,dLongitude:double):integer;
Add a dot at the end of list
procedure Insert(const index:integer;const dLatitude,dLongitude:double);
Insert point index
procedure BeginUpdate;
IMPORTANT : before adding a series of points made a call to BeginUpdate for triggering the reconstruction once all items inserted.
procedure Clear;
Clears all points
function Count:integer;
Returns the number of points
procedure Delete(index:integer);
Clears the index point
procedure EndUpdate;
IMPORTANT: At the end of a series of addition or insertion, made a call to EndUpdate To reflect the changes
procedure PanToBounds;
Drag the map so that the figure is fully visible
function getAdress(const index:integer):string;
Returns the address of the point index
procedure getAltitudes(Event:TOnGetAltitude=nil);

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.

3
property Point[index:integer]:TLatLng read getPoint; default;
Returns TLatLng corresponding to Index
function getLatLngFromMeter(const SensStartEnd:boolean;const lMeter:longint;var dLatitude,dLongitude:double;var idPoint:integer;var heading:integer;var bEnd:boolean):boolean;

Calculates 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

20

Example 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 groundoverlays
OnOverlayClick(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
simple click on an overlay

index 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)
OnOverlayMouseDown(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
the left mouse button is pressed on an overlay

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 !

21
OnOverlayMouseUp(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
the left button of the mouse is found on an overlay

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 !

22

CloudMade does not respond to events OnOverlayMouseDown and OnOverlayMouseUp

5
OnOverlayDblClick(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
Double click on an overlay
OnOverlayRightClick(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
Right click on an overlay

CloudMade does not support right click, Alt + click trigger event (as in Google Map)

8
OnOverlayMove(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
Triggered when moving an overlay, by code or mouse

Under 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)

9
OnOverlayMouseOut(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
The mouse leaves an overlay
OnOverlayMouseOver(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double;const OverlayType:TOverlayType)
Mouse over an overlay
OnOverlayChange(sender: Tobject;const Index:integer;const OverlayType:TOverlayType)
Triggered when any change on an overlay (color, point ...)
OnOverlayPathChange(sender: Tobject;const Index:integer;const OverlayType:TOverlayType;const PathIndex:integer)
Triggered when one of the points defining the overlay changes

PathIndex indicates the index in Path

Markers Interactive

The interactive overlay markers assigned to EditOverlay also trigger events
OnEditOverlayPointClick(sender:TObject; const Index:integer)
Click on the marker that represents the Index point in Path
OnEditOverlayPointDragEnd(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double)
Point displacement Index on Path and its new coordinates
OnEditOverlayPointRClick(sender:TObject; const Index:integer)
Click on the marker that represents the Index point in Path

By 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

IconSizeOverlay : TPoint
Width and Image Height
IconOriginOverlay : TPoint
Original X and Y displayed area extracted from the image (same image can contain multiple icons)
IconAnchorOverlay : TPoint
X and Y point in the area that will match the latitude and longitude

Fig. 35 Polygon editing mode

Demonstration

The program DemoOverlay shows you how to easily manipulate all these elements
Fig. 36 DemoOverlay
Fig. 36 DemoOverlay

All the concepts related to overlays are employed, creation, Publishing, deletion, the import / export of your card , including export to Google Earth .

go to page
© 2016 ESCOT-SEP Christophe - Made width Help&Web - RSS - Google+