[OutSystems Maps] Dragg Marker Event
Forge component by OutSystems R&D
Application Type
Reactive

I'm trying to set a draggend event to my marker but it seem to be impossible, what I need is to get the new location as Text value after moving my marker on the map.

I've tried with javascript using addListener but it doesn't work.


Any help?

Solution

Hello @Iván Rodríguez ,

Are you trying to achieve something like this?


In order to do this, you need to define the AdvancedFormat of the Marker with:

"{draggable: true, markerEvents: ['mouseup']}"

Then, you need to use the event Markers_EventTriggered and, with the MapId and the MarkerId, you can use the Google Maps API to get the marker coordinates:

var position = osGoogleMap.getMarker($parameters.mapID,$parameters.markerID).position;

$parameters.Lat = position.lat();

$parameters.Lng = position.lng();


In attachment you have a sample module.

Please try it and let us know if it helped.

Bruno Martinho

MapsDrag.oml

Thank you, it works as I need!

mvp_badge
MVP

Hi Ivan,

For future reference, since the input parameter Markers in the Map is DEPRECATED, will leave you here the documentation on how to do exactly this use case, but in the new way.

https://outsystemsui.outsystems.com/OutSystemsMapsSample/GetDraggableMarkerCoordinates

Hope this helps you,

Cheers,
RG

What about getting the full address of the marker location?

mvp_badge
MVP

Can you explain what do you mean?

I mean, the coordinates represent a location in real world, but I don't know how to get a physical address for example: "55 Thomson Place, 2nd Floor, Boston, MA 02210"

mvp_badge
MVP

Unfortunately the google API, only returns the coordinates. To have the address, you are requires to use (and pay) yet another API.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.