ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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: Many WLanguage functions are specific to Map control management.. 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 a minimum zoom level.
The last memorized position can be displayed by selecting the "Remember last position displayed" option 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:
  • or the MapDisplayPosition function: This function can be used with a specific position (geoPosition type variable) or on a town or monument..
    For example:
    // Centre la carte affichée par le champ "CARTE_Position" 
    // sur une position géographique 
    MaPosition is geoPosition
    MapDisplayPosition(CARTE_Position, MaPosition)
    
    // Centre la carte affichée par le champ "CARTE_Position" sur une ville 
    // à partir de son nom
    MapDisplayPosition(CARTE_Position, "Montpellier, France")
    
    // Centre la carte affichée par le champ "CARTE_Position" sur un monument 
    // à partir de son nom
    MapDisplayPosition(CARTE_Position, "Tour Eiffel")
  • a direct assign command with a specific location. In this case, the location is displayed without animations.
    Example:
    // Centre la carte affichée par le champ "CARTE_Position" 
    // sur une position géographique
    MaPosition is geoPosition
    CARTE_Position = MaPosition
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:
    // Code serveur
    MapConfigureGglAPI("libraries=geometry,places","language=fr")
  • Retrieving the dynamic object in browser code:
    // Code navigateur
    MaCarte is object dynamic
    MaCarte = MapGetJSObject(CARTE_Navigateur)
    // Appel de la fonction Javascript
    RechercheAdresse()
  • JavaScript function used to handle the Map control:
    // Fonction Javascript utilisant l'objet dynamique
    function RechercheAdresse()
    {
    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(MaCarte);
    service.nearbySearch(request, RetourAdresse_WB);
    }
Map control functions
The WLanguage functions used with Map controls can be classified into several categories:
  • The functions used to manage the positions 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.
  • The functions used to follow the movements of 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,
    • use any shape you want,
    • 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).
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: 09/18/2024

Send a report | Local help