flask-extensions / Flask-GoogleMaps

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

marker #39

Closed enigmista91 closed 8 years ago

enigmista91 commented 8 years ago

Hi,

in fullmap I want pass a series of markers lat long extract from mydatabase, but I don't understand How can I pass the list of dict.

like for m in lista_co: appo=[ { 'icon': '//maps.google.com/mapfiles/ms/icons/green-dot.png', 'lat': m['lat'], 'lng': m['long'], 'infobox': "Questo e' un marker di prova" }] markers.append(appo) I want pass markers to Map ()...

rochacbruno commented 8 years ago

Use a list-comprehension


map = Map(
    ...
    markers=[
        {
            'icon': icons.dots.green, 
            'lat': item['lat'], 
            'lng': item['lng'], 
            'infobox': "This is the box for item %s" % item
        } for item in lista_co
    ]
    ...    
)

or

map = Map(...)
map.build_markers(markers)

or

map = Map(...)
for m in lista_co:
    map.add_marker(m['lat'], m['lng'])
enigmista91 commented 8 years ago

many thanks