ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or site / Controls, windows and pages / Controls: Available types / Map control
  • Overview
  • Initializing a map
  • Displaying a map
  • Managing advanced parameters (WEBDEV)
  • The following functions can be used with the Map controls
  • 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 handle a Map control through programming. 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 handle a Map control through programming.
Remark: Several WLanguage functions are specific to the management of Map controls. For more details, see Map control functions.
Initializing a map

Displaying a map

When the 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 display the last position: you just need to select "Remember last position displayed" in the "General" tab of the Map control description window. In this case, the last position is displayed with the same zoom level.
To display a map corresponding to a specific location, use:
  • the <Map>.DisplayPosition function: This function can be used with a specific position (geoPosition variable), or on a town or a monument.
    For example:
    // Centers the map displayed by the "MAP_Position" control
    // on a geographical location
    MyPosition is geoPosition
    MAP_Position.DisplayPosition(MyPosition)
     
    // Centers the map displayed by the "MAP_Position" control on a city
    // from its name
    MAP_Position.DisplayPosition("Montpellier, France")
     
    // Centers the map displayed by the "MAP_Position" control on a monument
    // from its name
    MAP_Position.DisplayPosition("Eiffel Tower")
  • a direct assign command with a specific position. In this case, the position is displayed without any animation.
    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 Several settings are available for the Map control found in WEBDEV. WEBDEV gives you the ability to use additional parameters, available in the Google API for map management.
To do so, two functions are available:
  • MapConfigureGglAPI (that can be used in server code) allows you to specify the additional parameters that will be managed on the Map control. These parameters are global to the project.
  • <Map>.GetJSObject (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 load 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 = MAP_Browser.GetJSObject()
    // 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);
    }
The following functions can be used with the Map controls
The WLanguage functions that can be used with the Map controls can be classified in several categories:
  • The functions used to manage the positions on the map:
    <Map>.DisplayPositionCenters the map displayed in a Map control on a geographical position or on a specific location.
    <Map>.GetPositionReturns the geographical position of the point located in the center of the map currently displayed in a Map control.
    <Map>.InfoPositionReturns the coordinates (in pixels) of the point corresponding to a geographical position (latitude and longitude).
    <Map>.InfoXYReturns the geographical position (latitude and longitude) corresponding to a point in a Map control.
  • The functions used to follow the movements of the device:
    <Map>.EndOfMoveStops following the device movement in a Map control.
    <Map>.FollowMovementDisplays the current location of the device in a Map control and updates the location as it moves.
  • The functions used to manage the markers on the map. These functions use the Marker variables to define the characteristics of these markers.
    <Map>.AddMarkerAdds a new marker onto a map displayed in a Map control.
    <Map>.DeleteAllDeletes the following from a Map control:
    • all markers,
    • all shapes,
    • all images.
    <Map>.DeleteMarkerDeletes a marker from a map displayed by a Map control.
    <Map>.ModifyMarkerModifies a marker displayed in a Map control.
  • The functions used to manage the itineraries on the map.
    <Map>.AddItineraryAdds an itinerary onto a Map control.
    <Map>.DeleteItineraryDeletes an itinerary from a Map control.
  • The functions used to handle the additional options of the Google API for map management:
    MapConfigureGglAPIDeclares additional parameters for the Map control that will be transmitted to the Google API.
    <Map>.ExecuteJSRuns the native code of Google Maps API in a Map control in JavaScript.
    <Map>.GetJSObjectReturns 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 identifier required for using a Map control with the Google Map API for Work option. For more details, check the user license of Google Maps API.
    WEBDEV - Server code You also have the ability to enter the "Google Maps API" license in the description window of project ("Advanced" tab).
  • Universal Windows 10 App MapLicenseBing is used to specify the Bing key required for using the Map control in an application in Universal Windows 10 app mode.
Properties specific to Map controls
The following properties are used to manage a Map control through programming:
MapModeReturns or modifies the display mode of the map in the Map control.
ValueUsed to center the map on the position corresponding to the specified geoPosition variable.
ZoomReturns or modifies the zoom level used to display the map.

For a complete list of WLanguage properties that can be used with a Map control, see Properties associated with Map controls.
Minimum version required
  • Version 23
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help