flask-extensions / Flask-GoogleMaps

Easy way to add GoogleMaps to Flask applications. maintainer: @getcake
https://flask-googlemaps.com
MIT License
647 stars 196 forks source link

Create a marker click listener for the map #149

Closed gferioli0418 closed 3 years ago

gferioli0418 commented 3 years ago

I changed init.py and gmapjs.html in order to add functionality for a click listener to the marker. I fixed up the code as well to include the missing comma in file gmapjs.html in line 35 causing users to not see the map loaded up. I also added a property called {{gmap.varname}}_clickedMarker to the map in order to see the lat and lng of the last clicked marker.

Podolyan98 commented 3 years ago

@gferioli0418 Hello. Can you please tell me how to use the map click listener?

gferioli0418 commented 3 years ago

@podolyan98 Hi, It is very similar to the report_clickpos feature. First, make report_markerClickPos = True then select the URL in markerClickPos_uri. Then the code should make a post request to the URI you specified whenever a marker is clicked. Also the {{gmap.varname}}_clickedMarker is a variable that you can use that tells you which marker you just clicked.

Podolyan98 commented 3 years ago

@gferioli0418 Thank you! Can I move a marker on the map using coordinates from report_clickpos?

gferioli0418 commented 3 years ago

@Podolyan98 yes you can. There is an example of it in the example folder.