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

Positioning

you are here :TECMap

We will discover the methods, properties and events related to all that appeal to the geographical position of a point.

Placement on map

You can determine the coordinates of the center of the map through the Latitude and Longitude properties, they are double and read / write

You can directly edit the details through the procedure setCenter(const dlatitude,dlongitude:double)

program demomap;

uses

ceflib,sysutils,
Forms,
UMainDemoMap in 'UMainDemoMap.pas' ;

{$R *.RES}


begin

CefLibrary := expandfilename('.\bin\win32\libcef.dll');


Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormDemoECMap, FormDemoECMap);
Application.Run;

end.

The procedure PanTo(const dLatitude,dLongitude:double) also offers the possibility to change the positioning.

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

7

Mouse position

The latitude and longitude of the point under the mouse cursor are returned by properties MouseLatitude and MouseLongitude

You can tune into the event OnMapMouseMove to know your position in real time


Coping with change of position

When the center of the map is moved, either by code or directly to the mouse, the event OnMapMove(sender: Tobject;const dLatitude,dLongitude:double) is triggered

Sender ECMap represents the component that has been modified, and dLatitude dLongitude the new coordinates, which are also available through Latitude and Longitude.

When the card begins to move OnMapDragStart event is triggered, then OnMapDrag during displacement and OnMapDragEnd at the end .

You can also respond when moving the mouse by logging on OnMapMouseMove

Altitude

You get the altitude of the center of the map through the Altitude property, it is double and accessible only by reading.

Function GetAltitudeAtLatLng(const dLatitude,dLongitude:double):double gives you the elevation of any point.

program demomap;

uses

ceflib,sysutils,
Forms,
UMainDemoMap in 'UMainDemoMap.pas' ;

{$R *.RES}


begin

CefLibrary := expandfilename('.\bin\win32\libcef.dll');


Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormDemoECMap, FormDemoECMap);
Application.Run;

end.


Polylines have a special method for the calculation of the altitude of all their points .

Area displayed

You can determine the coordinates of the northeast (upper right) and point southwest (lower left) of the area displayed by the component properties through ECMap NorthEastLatitude, NorthEastLongitude, SouthWestLatitude SouthWestLongitude accessible only by reading.

The procedure PanToBounds(const dLatlo,dLnglo,dLathi,dLnghi:double) you can change the view from the new coordinates of the low point (South West) and high (North East).

The procedure fitBounds(const dLatlo,dLnglo,dLathi,dLnghi:double) allows you to adjust the view to the coordinates passed.

fitBounds works also with Google Earth

8

Function ContainsLatLng(var dLatitude,dLongitude:double):boolean tells you if the item in dLatitude, dLongitude is in the visible portion of the card.

As soon as the view changes OnChangeMapBounds event (sender: TObject) is triggered.

The ScreenShot property returns a TBitmap containing the map image

program demomap;

uses

ceflib,sysutils,
Forms,
UMainDemoMap in 'UMainDemoMap.pas' ;

{$R *.RES}


begin

CefLibrary := expandfilename('.\bin\win32\libcef.dll');


Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormDemoECMap, FormDemoECMap);
Application.Run;

end.

Zoom

The Zoom property allows you to control the definition of your card, it is of type integer and is read / write

Using a Google map type you have access also to the property and maxZoom minZoom that allow you to determine the limits of the zoom

9

The change triggers the zoom event OnChangeMapZoom(sender: TObject)

Url

The Url property returns / accepts a string in the format '#zoom/Latitude/Longitude'


// zoom 18 latitude 48.856527 longitude 2.352104
// welcome to Paris !
map.Url := '#18/48.856527/2.352104';

Assigning a value to this property raises the event OnBeforeUrl(sender : TObject; var Url:string) that can allow you to change the url, and even to cancel the change by returning an empty string.

You can pass a such link in a InfoWindow



// welcome to Paris !
map.Shapes.InfoWindows[0].Content := 'Go to <a href="#18/48.856527/2.352104">Paris !</a>';

Fig. 16 Url Link

If you pass a 'classical' url it will open in your default browser.

1

Distance

Function DistanceFrom(const dLatitudeStart,dLongitudeStart,dLatitudeEnd,dLongitudeEnd:double):double calculates the distance between 2 points, the result is in meters.

Angle with respect to North

Function HeadingFrom(const dLatitudeStart,dLongitudeStart,dLatitudeEnd,dLongitudeEnd:double):integer gives you the angle from 0 ° to 360 °, the direction from the point dLatitudeStart,dLongitudeStart to point dLatitudeEnd,dLongitudeEnd

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