30
Views
3
Comments
Solved
[OutSystems Maps] How to prevent user to drag the direction set on leaflet map.
outsystems-maps
Reactive icon
Forge asset by OutSystems
Application Type
Reactive

I have a an OS Maps that shows two points. 

  • This is using a Leaflet map with LoadLeafletDirectionsPlugin and OSRM provider to user SetDirections.
  • Maps is showing the correct value but user can drag the location. 

Is there a way to prevent user from dragging the direction set?

2026-01-08 17-20-06
David Lourenço
Staff
Solution

Hello @Win Signo.

I was able to replicate the use case you mentioned, and it's by design.

As a workaround, you can add a JavaScript Node to disable the possibility of dragging the route and creating new markers.

For that, place a JavaScript Node after the LoadLeafletDirectionsPlugin 

In the JavaScript Node, place the following:

OutSystems.Maps.MapAPI.MapManager.GetActiveMap().features.directions._directionsRenderer.options.lineOptions = { addWaypoints: false }


2025-02-21 07-07-34
Rishabh Tailor

Hi @Win Signo ,

If you are using OS Maps and the markers in them,. Then there is an option "AllowDrag" which if you set it to false. It will prevent the marker from being dragged. 

Check OML for reference to above given image.

If you are using external JS to define the direction set, then you should try the handlers of the markers given in the Leaflet documentation here.

Some more links : 

https://stackoverflow.com/questions/22671733/why-doesnt-marker-dragging-disable-work


Chat.oml
2025-10-14 07-47-46
Win Signo

Hi @Rishabh Tailor 

The issue that I have is the usage of the destination on leaflet, on my example i have 2 marker and I use SetDirections and the red lines would appear. The issue that I'm facing it that I can prevent the user from moving my 2 markers, but once they click the red line, it will automatically create a new marker once i set it. You can look at example i have, first I have A-B marker which is the solid red line, but when i click that red line and drag it, it would create a new B marker which will show with the break line, it sort of a new waypoint being added. 

First I have two points A-B, these marker are not draggable, and I trigger the SetDirection to create a path from A-B

Next, I hold the line created and dragged it. (This is the part that I want to remove, which is allowing the user to drag the line and create a new marker)

Once I placed down, the map would tag the newly drop point as a new marker.


2026-01-08 17-20-06
David Lourenço
Staff
Solution

Hello @Win Signo.

I was able to replicate the use case you mentioned, and it's by design.

As a workaround, you can add a JavaScript Node to disable the possibility of dragging the route and creating new markers.

For that, place a JavaScript Node after the LoadLeafletDirectionsPlugin 

In the JavaScript Node, place the following:

OutSystems.Maps.MapAPI.MapManager.GetActiveMap().features.directions._directionsRenderer.options.lineOptions = { addWaypoints: false }


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