title: Django Looping Through Objects to Place Object Markers on Google Maps
body: <blockquote>
    <p>I cannot figure out how to get checkmark pins to show up on google maps I have tried to loop this several different ways. When I take the function out the map shows back up. I am wondering if it is possible to do on Django in this manner. Thank you for any help. </p>
  </blockquote>
  
  <pre><code>{% extends 'maps/base.html' %}
  {% block body %}
  
      &lt;head&gt;
      &lt;style&gt;
        #map {
          height: 50%;
          width:50%
        }
        html, body {
          height: 100%;
          margin: 0;
          padding: 0;
        }
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="map"&gt;&lt;/div&gt;
      &lt;script&gt;
        var map;
        function initMap() {
          map = new google.maps.Map(document.getElementById('map'), {
            zoom: 2,
            center: new google.maps.LatLng(2.8,-187.3),
            mapTypeId: 'terrain'
          });
        // Loop through the results array and place a marker for each
        // set of coordinates.
  
             function loadMarkers(){
                {% for object in object_list %}
                    var point = new google.maps.LatLng({{object.latitude}},{{object.longitude}});
                    var marker = new google.maps.Marker({
                    position: point,
                    map: map
                });
                {% endfor %} 
  
  
      &lt;/script&gt;
      &lt;script async defer
      src="https://maps.googleapis.com/maps/api/js?key=APIKEY&amp;callback=initMap"&gt;
      &lt;/script&gt;
    &lt;/body&gt;
  </code></pre>
  
  <p>Views:</p>
  
  <pre><code>class TestView(generic.ListView):
      template_name = 'maps/bbjecttest.html'
  
      def get_queryset(self):
          return Location.objects.all()
  
      context_object_name = 'location'
  </code></pre>