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

Markers

you are here :TECMap > Overlays

The markers are managed by a list of type TECMapMarkers accessible through the property Markers of TECMap


TECMapMarkers

This list has the following methods and properties :

function Add(const dLatitude,dLongitude:double):integer;
Adds a marker at the point Latitude, Longitude and returns its index in the list.

You can also add a marker with the function AddMarker of TECMap

4

// Delphi map component ECMap

// add marker at center of map
id := map.AdMarker(map.latitude,map.longitude);
// set title to this marker
map.Markers[id].title := 'my first marker!';

function ByLatLng(const dLatitude,dLongitude:double):TECMapMarker;
Returns the marker positioned at Latitude, Longitude
function ByName(const value:string):TECMapMarker;
Returns the marker based on its name (Property Name)
procedure Clear;
Deletes all markers
procedure Delete(index:integer);
Removes the marker which we pass the index
function IndexOf(const value:TECMapMarker):integer;
Returns the index of the marker in the list
property Cluster:boolean;
Property read / write, includes the markers according to their position and according to the zoom

Fig. 37 Combination of markers of activation

Inactive under CloudMade

6
property Count:integer;
Returns the number of marker in the list
procedure fitBounds
Adjusts the zoom of the map to display all of the markers
property Marker[index:integer]:TECMapMarker;
Table that allows access to markers is the default property so you can access it directly by map.Markers [index] instead of map.Markers.Marker [index]
property ToKml : string;
Read-only property that returns a string in kml format containing the list of markers
property ToTxt : string;
Property read / write which gives access to the list of markers in a text format.

In writing there is an addition and not a replacement, if you do not want to keep the old values before making a Clear adding

23
Example of use

// Delphi map component ECMap

// add marker at center of map
id := map.Markers.add(map.latitude,map.longitude);
// set title to this marker
map.Markers[id].title := 'my first marker!';

TECMapMarker

This class manages a marker, it has the following methods and properties :
procedure setPosition(const dLatitude,dLongitude:double);
Moves the marker in Latitude, Longitude, triggers the event OnMarkerMove
procedure PanTo;
Move the map so that its center coincides with the marker, triggers the event OnMapMove

The movement will be smoother if the move does not exceed half the height or width of the card.

24
procedure CopyImage(const Source:TECMapMarker);
Copy the image options the marker passed as a parameter
procedure setImage(const _Icon:string;Size,Origin,Anchor:TPoint);
_Icon contains the name of the source image file, local or internet see Icon
Size defined the width and height, see IconSize
Origin set the X and Y from the origin of the image in the source image, see IconOrigin
Anchor set the X and Y point corresponding to the Latitude and Longitude, see IconAnchor
procedure setImageShadow(const _Icon:string;Size,Origin,Anchor:TPoint);
Change options for the shadow image
procedure setShape;
Zone enforcement clickage the marker, see property Shape
property Adress : string;
Property read / write, can get the address of the marker or set it to an address, triggers the event OnMarkerAdress

To avoid multiple connections to the server address is cached, a new connection will be made only if the marker is moved

25
property Animation : string;
Property read / written values available are listed in the property MarkerAnimations type TStringList of TECMap

With the Google API you 'BOUNCE' and 'DROP', put an empty string to stop the animation

26

Inactive under CloudMade

7
property Altitude : double ;
Property read / written, the value is cached to avoid multiple connections to the server, a new connection will be made only if the position of marker exchange.
property Cursor : string;
Property read / written, set the mouse cursor when hovering, the values are listed in the property Cursors type TStringList de TECMap

Inactive sous CloudMade

8
property Clickable : boolean;
Property read / written, defined if the marker receives the click of the mouse or not
property Draggable : boolean;
Property read / written, defined if the marker is moved to the mouse.

Even if a marker is not moved with the mouse you can change its position through setPosition code or properties Latitude and Longitude

27
property Dragging : boolean;
Indicates whether the marker is about to be moved
property Flat : boolean;
Property read / written, defined if the marker has a shadow
property Heading : integer;
Indicates the angle relative to north
property Icon : string;
Property read / written, defined the image of the marker, this can be either a local file or a URL of a file on the Internet, see also setImage

With Google Maps you can also use a Symbol

5
// Delphi map component ECMap

// set vector icon
map.Markers[0].Icon := '{path: google.maps.SymbolPath.CIRCLE,scale: 3,strokeColor: "#393"}';
property Shadow : string;
Property read / written, defined the image of the shadow of the marker, this can be either a local file or a URL of a file on the Internet, see also setImageShadow
property IconSize : TPoint;
set the Width and Height of the image
property IconOrigin : TPoint;
set the X and Y from the origin of the image in the source file
property IConAnchor : TPoint;
set the X and Y in the image of the point corresponding to the Latitude and Longitude
property Index;
Index marker in the list of markers
property InfoWindow : integer;

Index of InfoWindow associated marker in the list of InfoWindow

When clicked on the marker if InfoWindow is defined, it will open

property Name : string;
Property read / written, set the name of your marker, see ByName
property Latitude : double;
Property read / written, defining the latitude of the marker triggers the event OnMarkerMove
property Longitude : double;
Property read / written, defining the longitude of the marker triggers the event OnMarkerMove
property Tag :integer;
Property read / written, you can use it freely for whatever you want stoker
property Title : string;
Property read / written, defining the title of your marker, it appears as a tooltip when hovering the cursor
property Visible : boolean;
Property read / written to display or not the marker
property Zindex : integer;
Property read / written, a priority key attribute for displaying the marker, a marker with a higher zIndex will be displayed on top of that having a lower zIndex
property ShowOnMap : boolean;
Read-whether the position marker is in the visible portion of the map
property Shape : TECMapShape;
Used to define the clickable area of the marker.

// Delphi map component ECMap


// fix shape rectangle
map.Markers[0].shape.stype := 'rect';
// fix coord
map.Markers[0].shape.Coord.add([10,10,25,30]);
// set shape
map.Markers[0].setShape;

With SType 'circle', 'poly' or 'rect'
See google documentation

Inactive under CloudMade

9
property ToTxt : string;
Property read / write accesses the marker in the form of a text string
property ToKml : string;
Read-only property that returns the marker as a string in kml format

Events

You can connect the component to receive events TECMap but you can also be connected directly from a marker for a specific response, in which case the event overall TECMap will not be called

6

The markers trigger events:

OnMarkerMove(sender: Tobject;const Index:integer;var dLatitude,dLongitude:double)
Triggered when moving a marker, by code or mouse

Index is the index of the list marker Markers

dLatitude and dLongitude the new position

You can change it in the event

7
OnMarkerClick(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double)
Triggered when a click on the marker

Index is the index of the list marker Markers

dLatitude and dLongitude position of marker
OnMarkerRightClick(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double)
Raised in a right click on the marker

Index is the index of the list marker Markers

dLatitude and dLongitude position of marker
OnMarkerDblClick(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double)
Triggered when double click on the marker

Index is the index of the list marker Markers

dLatitude and dLongitude position of marker
OnMarkerDrag(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double)
Triggered when moving the mouse of a marker

Index is the index of the list marker Markers

dLatitude and dLongitude position of marker
OnMarkerDragStart(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double)
Triggered initially moving the mouse of a marker

Index is the index of the list marker Markers

dLatitude and dLongitude position of marker
OnMarkerDragEnd(sender: Tobject;const Index:integer;const dLatitude,dLongitude:double)
Triggered at the end of the mouse to move a marker

Index is the index of the list marker Markers

dLatitude and dLongitude position du marker
OnMarkerAdress(sender: Tobject;const sAdresses:string;var Index:integer;const IndexMarker:integer)
Triggered by assigning an address to the marker

sAdresses contain all addresses, separated by #13#10 can match your query.

Index contain the index of the selected address, default 0, you can change it in this event.

IndexMarker index marker in the list of Markers

Output from this event the marker is positioned on the address selected

The markers also meet events OnOverlayMouseDown and OnOverlayMouseUp

28

Set a marker on a path

function MoveMarkerOnRouteToMeter(const iNumMarker,iNumRoute:integer;
const RouteType: TOverlayType;
const Direction:TDirectionSens;
const lMeter:longint):integer;

This feature allows you to place a marker on a path (road, polyline or polygon) based on a direction and distance in meters.

iNumMarker is the index marker in the list Markers

iNumRoute is the index of the path in Routes, Polylines ou Polygones

RouteType determines the type of path, ovRoute, ovLine ou ovPolygone

Direction is the direction of travel is dsStartEnd or dsEndStart

lMeter the distance in meters

 

In the next chapter you'll find other features to make your mobile markers simply

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