I'm trying to place markers based on the latitude and longitude stored in a model on a Google Map using the API and HTML5 geolocation.
The issue is how to loop through the lat/lon info for each object stored in the database within JavaScript tags using template keywords, which I'm not sure can be done in Django.
I found a similar question which I mildly modified and placed within a template – not a separate script file – but it doesn't seem to work:
function loadMarkers(){
{% for story in stories %}
var point = new google.maps.LatLng({{story.latitude}},{{story.longitude}});
var marker = new google.maps.Marker({
position: point,
map: map
});
{% endfor %}
}
Any insight on how to properly loop through items in a stored Django object with lat, lon info and place these on a Google Map using the API would be very appreciated.