FlowingCode / GoogleMapsAddon

Vaadin Addon based on Google Maps Web Component
https://www.flowingcode.com/en/open-source/
Apache License 2.0
20 stars 7 forks source link

Implement drag listener on map #66

Closed redsilver closed 2 years ago

redsilver commented 2 years ago

I have to add markers programmatically when the users drag the map. Is possible to implement the drag listener of the map to achieve this? Thank you!

paodb commented 2 years ago

Hello. It's not clear if this issue is a question or a feature request. At the moment the addon does not implement a drag listener. I think that what you're trying to achieve can be done with something similar to this:

googlemap.setDraggable(true);
googlemap.getElement().setProperty("dragEvents", true);
googlemap.getElement().addEventListener("google-map-dragend", event -> {          
     googlemap.addMarker( "newMarker", googlemap.getCenter(), true, Markers.BLUE); 
});

If you need to add the markers in a position that is different to the center of the map then I think you you need to use addClickListener that is already present in the components API.

paodb commented 2 years ago

I'm closing this ticket as there was no answer. Please feel free to comment/re-open if still valid.