Knowledge Base
Published May 27, 2026

How to Disable the Draggable Marker in a Geolocation Map Display

Written By

Jose L. Bango

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Issue

  • When using a Geolocation field in a Web Content Structure and displaying it from the template on a page using the map-display tag, the location marker is draggable by end-users.

  • You must make the marker static and prevent visitors from moving it.

Environment

  • Liferay DXP 2025.Q1

Resolution

The ability for users to drag the marker is the default and expected behavior for both OpenStreetMaps and Google Maps, as the draggable attribute is set to true in the component's implementation. To override this functionality and disable dragging for an OpenStreetMap marker, you can implement a custom JavaScript workaround. Complete the following steps:

  1. Identify the map's name in your template (e.g., contactGeolocation).

  2. Add the following proof-of-concept script to the page or theme to disable dragging:

    (function() {
        var mapDiv = document.querySelector('[id$="contactGeolocationMap"]');
        if (!mapDiv) {
            console.log('[disable-marker-dragging] Map div not found');
            return;
        }
        var registeredName = mapDiv.id.slice(0, -3); // remove the final 'Map'
        Liferay.componentReady(registeredName).then(function(map) {
            console.log('[map-disable-dragging] Component ready');
            map.on('positionChange', function onReady() {
                console.log('[disable-marker-dragging] positionChange fired');
                map.off('positionChange', onReady);
                var marker = map._geolocationMarker && map._geolocationMarker._nativeMarker;
                if (!marker) {
                    console.log('[disable-marker-dragging] nativeMarker not found');
                    return;
                }
                marker.dragging.disable();
                console.log('[disable-marker-dragging] Dragging disabled');
            });
        });
    })();
Note: This script is provided as a proof-of-concept. Custom JavaScript implementations and further modifications fall outside the scope of Liferay Support.
Did this article resolve your issue ?

Knowledge Base