I can see that marker has draggable property by default. But I can not drag the marker on the map. Even the marker on the demo is not draggable even though the draggable parameter is set to true. How to enable the draggable feature for the marker? Thanks
Hello. I did a quick test an indeed, this feature is not working. I created this [issue]
(https://github.com/FlowingCode/GoogleMapsAddon/issues/33) to keep track and currently working on the fix. We’ll let you know when a new release including it is out.
Regards.
Hello. Fix is now available in the latest release, 1.3.0. Can you give it a try?
Regards.
Hello,
It works, thanks for the update. However I would like to know how to retrieve the new (after dragend) LAT and LON values since I cannot retrieve them with the following.
addMarker.setDraggable(true);
addMarker.getElement().setProperty("dragEvents", true);
addMarker.getElement().addEventListener("google-map-marker-dragend", l -> {
Notification.show(addMarker.getPosition().toString());
});
The listener does fire but I get the old LON and LAT results.
Thanks in advance :)
Hi José, you can obtain the latitude/longitude by adding an event to the listener like this:
addMarker.setDraggable(true);
addMarker.getElement().setProperty("dragEvents", true);
addMarker.getElement().addEventListener("google-map-marker-dragend", event -> {
JsonObject eventData = event.getEventData();
JsonObject latLng = eventData.getObject("event.detail.latLng");
Notification.show("Lat: " + latLng.getNumber("lat") + " - Lng: " + latLng.getNumber("lng"));
}).addEventData("event.detail.latLng");
That works okay but I also created [this issue]
(https://github.com/FlowingCode/GoogleMapsAddon/issues/40) so we can add the event to GoogleMapMarker class so the call to get the new position is simplified by just calling a listener.
Let us know how it goes and don’t hesitate to contact us if you run into any other issue.
Regards.
Hi José. DragEndEvent was added to the Marker’s API in the latest release of the component, 1.4.0.