PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Example for displaying the position on a map with a marker
MapDisplayPosition (Example)
Example for displaying the position on a map with a marker
WINDEVAndroidiPhone/iPad This example is used to display an address on a Map control, with a zoom defined at street level. A marker is added to the position specified by the address.
addrCustomer is Address
// Address to display
addrCustomer..Street = "3 Puech Villa Street"
addrCustomer..ZipCode = "34090"
addrCustomer..City = "Montpellier"
addrCustomer..Country = "FRANCE"
 
// Zoom at street level
MAP_Customer..Zoom = 16
 
// According to the platform
<COMPILE IF ConfigurationType=WindowsApplication>
// Coordinates of the address
Coord is gglCoordinate = GglAddressToCoordinates(addrCustomer..Street + ", "+
addrCustomer..ZipCode + " " + addrCustomer..City + " " + addrCustomer..Country)
// Retrieves the longitude and latitude and updates the address
addrCustomer..Position..Latitude = Coord..Latitude
addrCustomer..Position..Longitude = Coord..Longitude
<END>
<COMPILE IF ConfigurationType=Android OR ConfigurationType=iOS>
// Updates the address with the latitude and longitude
addrCustomer= geoGetAddress(addrCustomer..Street + ", " + addrCustomer..ZipCode +
" " + addrCustomer..City + " " + addrCustomer..Country)
<END>
 
// Is there a latitude and a longitude for the address?
IF addrCustomer<>Null _AND_ addrCustomer..Position..Latitude <> 0 _AND_
addrCustomer..Position..Longitude <> 0 THEN
AddressMarker is Marker
AddressMarker..Position = addrCustomer..Position
AddressMarker..Name = "Customer address"
AddressMarker..Image = "house.gif"
AddressMarker..ActionClick = ClickOnAddress
 
// Adds a marker on the position
MapAddMarker(MAP_Customer, AddressMarker)
// Centers the map on the position
IF NOT MapDisplayPosition(MAP_Customer, addrCustomer..Position) THEN
Error("Unable to display this position", ErrorInfo())
END
ELSE
// Centers the map on the address but without marker
// because the position was not defined
IF NOT MapDisplayPosition(MAP_Customer, addrCustomer) THEN
Error("Unable to display this address", ErrorInfo())
ELSE
Info("Approximate position")
END
END
 
INTERNAL PROCEDURE ClickOnAddress(MapMarker is Marker)
ToastDisplay(StringBuild("%1, position: %2 N, %3 E ",
MapMarker..Name, MapMarker..Position..Latitude,
MapMarker..Position..Longitude))
END
Minimum version required
  • Version 17
This page is also available for…
Comments
Click [Add] to post a comment