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

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)

// Delphi map component ECMap
var lat,lng:double;
begin
// get center of map
lat := map.Latitude;
lng := map.Longitude;
// move center of map
map.setCenter(lat+0.001,lng);

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.

4

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.

// Delphi map component ECMap
// altitude of map's center
map.Altitude;
// altitude at latitude 48, longitude 0.7
map.GetAltitudeAtLatLng(48,0.7);


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

5

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

// Delphi map component TECNativeMap

// save map to bmp file
map.Screenshot.SaveTofile('c:\mymap.bmp');

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

6

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

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+