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

Add MarkerClusterer support #24

Closed RubenRocha closed 8 years ago

RubenRocha commented 8 years ago

Although, this uses cloudflare CDN for the JS as it's the only place it's available, not even google links to it directly.

The images have to be added to our flask app's static/ folder, under the subfolder "images/", or, just specify cluster_imagepath="folder/image_prefix" (so it would look for image_prefix1,2,3...) when you're creating the GoogleMaps() object.

They can be downloaded Here (images are named m1-5.png)

rochacbruno commented 8 years ago

Wow.. this is very nice PR!

Can you please add an example of clustered map in example app

Or maybe we can promote examples to a directory and include app with static, templates and also static in there?

RubenRocha commented 8 years ago

@rochacbruno Thank you! Absolutely, I will do that first thing when I wake up tomorrow. I could also try find the needed files on google's server like you do for the pin icons, however I don't think they'd like people using this to always be hotlinking to their servers.

I also have a suggestion, currently you loop over the markers in the template itself, which generates alot of unneeded var marker_1, var_marker_2, I suggest to just add the markers from the python code into a javascript array, and then just looping over that array like so: for (var i = 0; i < markers.length; i++) { markers[i].setMap(map); }

EDIT: I've added the example and moved things as you said, there is also now a cluster_gridsize= option, for controlling how close things should be before clustering them, Google sets this at 60, so it's the default here too.

rochacbruno commented 8 years ago

Thank you! @RubenRocha