Skip to main content

 

 

 

 
 
Applies only to Mobile Apps and Reactive Web Apps
Service Studio version:
 
 
OutSystems

How to get draggable marker coordinates

Template:OutSystems/Documentation_KB/ContentCollaboration
  • Edit
    Collaborate with us
    Edit this page on GitHub
  • Prerequisites

    This example demonstrates how to change the location of a map marker and get the coordinates of the new location.

    1. In Service Studio, in the Toolbox, search for Map.

      The Map widget is displayed.

      Map in the Service Studio toolbar

      If the UI widget does not display, it may be because you used a ready-made app, which deletes unused widgets from the module. To make additional widgets available in your app:

      a. Go to Module > Manage dependencies.

      b. Search for and select the relevant Producer, for example OutSystemsUI. Ensure Show All is selected.

      c. On the Public elements for the selected Producer displayed on the right, ensure Show All is selected.

      d. Search for and select the element you want to add, and click Apply.

      e. In Service Studio, in the Toolbox, search for the widget again.

    2. From the Toolbox, drag the Map widget into the Main Content area of your application's screen.

      Drag Map widget onto the screen

    3. On the Properties tab, enter an API key so that the "For development purposes" watermark is removed.

      Enter API key

    4. From the Toolbox, drag the Marker block onto the Drag markers here screen area.

      Drag Marker block onto the screen

    5. On the Properties tab, define the Marker's initial coordinates in the Position property.

      Define the Marker's coordinates

    6. To allow users to move a marker, expand the OptionalConfigs and set AllowDrag to True.

      Define the Marker's coordinates

    7. To get the new marker coordinates, drag the Marker Event block inside the MarkerEvents placeholder and on the Properties tab, set the EventName property as DragEnd.

      Get new coordinates

    8. Create two new local variables (Latitude and Longitude) to store the new coordinate values.

      Create local variables

    9. Create a handler for the event and assign the new marker coordinates to the variables.

      Create handler

    10. Add two expression widgets to the screen with the Latitude and Longitude variables to display the marker coordinates in your application.

      Add expressions to display new coordinates

    11. On the Properties tab, set the new variables Default value to the Boston US office (Latitude: 42.351657835 Longitude: -71.046881100).

      Set variable default value

    After following these steps and publishing the module, you can test the component in your app.

    Result

    Result

    • Was this article helpful?