ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Map control
  • Overview
  • Initializing a map
  • Displaying a map
  • Managing advanced parameters (WEBDEV)
  • Map control functions
  • Remarks
  • Properties specific to Map controls
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
WINDEV, WEBDEV and WINDEV Mobile allow you to programmatically manipulate Map controls. To do so, use the variable of the Map control in the code.
The variable of the Map control corresponds to the name of the Map control.
This help page explains how to programmatically manipulate Map controls.
Remark: There are multiple WLanguage functions specific to Map controls. For more details, see Map control functions.
Initializing a map

Displaying a map

When a window containing a Map control is opened, a world map is automatically displayed: the map is centered on Europe, with minimum zoom level.
You can view the last location on the map: you just need to select "Remember last position displayed" in the "General" tab of the Map control description window. In this case, the last location is displayed with the same zoom level.
To show a specific location on the map, use:
  • the MapDisplayPosition function: This function can be used to show a specific location (geoPosition variable), a town or a monument.
    For example:
    // Centers the map displayed by the "MAP_Position" control
    // on a geographical location
    MyPosition is géoPosition
    MapDisplayPosition(MAP_Position, MyPosition)

    // Centers the map displayed by the "MAP_Position" control on a city
    // from its name
    MapDisplayPosition(MAP_Position, "Montpellier, France")

    // Centers the map displayed by the "MAP_Position" control on a monument
    // from its name
    MapDisplayPosition(MAP_Position, "Eiffel Tower")
  • a direct assign command with a specific location. In this case, the location is displayed without animations.
    Example:
    // Centers the map displayed by the "MAP_Position" control
    // on a geographical location
    MyPosition is geoPosition
    MAP_Position = MyPosition
Managing advanced parameters (WEBDEV)
WEBDEV - Server codeWEBDEV - Browser code WEBDEV allows you to define several options for Map controls. However, you can also specify additional parameters using the Google Maps API.
To do so, you can use the following functions:
  • MapConfigureGglAPI (that can be used in server code) allows you to specify additional parameters for the Map control. These parameters are global to the project.
  • MapGetJSObject (that can be used in browser code) allows you to retrieve the map and its options in a dynamic object in order to handle the control in JavaScript code.
Example:
  • Declaring the libraries to be loaded in server code:
    // Server code
    MapConfigureGglAPI("libraries=geometry,places","language=fr")
  • Retrieving the dynamic object in browser code:
    // Browser code
    MyMap is object dynamic
    MyMap = MapGetJSObject(MAP_Browser)
    // Call to the JavaScript function
    FindAddress()
  • JavaScript function used to handle the Map control:
    // JavaScript function that uses the dynamic object
    function FindAddress()
    {
    var infowindow;
    // Rome: 41.873144, 12.480391
    var pyrmont = new google.maps.LatLng(41.873144, 12.480391);
    var request = {
    location: pyrmont,
    radius: 500,
    types: ['store']
    };
    infowindow = new google.maps.InfoWindow();
    var service = new google.maps.places.PlacesService(MyMap);
    service.nearbySearch(request, ReturnAddress_WB);
    }
Map control functions
The WLanguage functions used with Map controls can be classified into several categories:
  • Functions for getting locations on the map:
    MapDisplayPositionCenters the map displayed in a Map control on a geographical position or on a specific location.
    MapGetPositionReturns the geographical position of the point located in the center of the map currently displayed in a Map control.
    MapInfoPositionReturns the coordinates (in pixels) of the point corresponding to a geographical position (latitude and longitude).
    MapInfoXYReturns the geographical position (latitude and longitude) corresponding to a point in a Map control.
  • Functions for tracking the device:
    MapEndOfMoveStops following the device movement in a Map control.
    MapFollowMovementDisplays the current location of the device in a Map control and updates the location as it moves.
  • Functions for handling markers on the map. These functions use Marker variables to define all marker characteristics.
    MapAddMarkerAdds a new marker onto a map displayed in a Map control.
    MapDeleteAllDeletes the following from a Map control:
    • all markers,
    • all shapes,
    • all images.
    MapDeleteMarkerDeletes a marker from a map displayed by a Map control.
    MapModifyMarkerModifies a marker displayed in a Map control.
  • Functions for handling routes on the map.
    MapAddItineraryAdds an itinerary onto a Map control.
    MapDeleteItineraryDeletes an itinerary from a Map control.
  • Functions for additional Google Maps API options:
    MapConfigureGglAPIDeclares additional parameters for the Map control that will be transmitted to the Google API.
    MapExecuteJSRuns the native code of Google Maps API in a Map control in JavaScript.
    MapGetJSObjectReturns the instance of the API of Map control.

Remarks

  • AndroidiPhone/iPad geoRunApp is used to start the device's native maps application.
  • WINDEVWEBDEV - Server code MapLicenseGgl allows you to specify the Google ID required when using a Map control with the Google Maps API for Work. For more details, see the Google Maps APIs terms of service.
    WEBDEV - Server code You can also specify the Google Maps API key in the project description window ("Advanced" tab).
  • Universal Windows 10 App MapLicenseBing allows you to specify the Bing key required for using a Map control in a Universal Windows Platform application.
Properties specific to Map controls
Use the following properties to programmatically manipulate Map controls:
MapModeGets or sets the map display mode in the Map control.
ValueCenters the view at the position specified by the geoPosition variable.
ZoomGets or sets the initial zoom level of the map.

For a complete list of WLanguage properties that can be used with Map controls, see Map control properties.
Minimum version required
  • Version 17
This page is also available for…
Comments
Errors that may occur in Maps not working:
A) in the Google developer environment, a valid credit/debit card must be registered in the billing method of payment. If you do not have a card that has valid usage data, it may also give an error.
B) environment changes may be necessary to create new api key.
C) the api is not ok, because for the maps it has a
Different web and mobile apis, minus watching an updated tutorial.
D) ocorre erro também quando o WX (Windev, Webdev e Windev Mobile) esta desatualizado e usando a versão antiga do internet explorer. Solução mudei pra o google/edge.
E) informeo apikey válido do googlemaps.
Boller
30 Aug. 2023

Last update: 08/29/2023

Send a report | Local help