title: Add multiple markers to google maps from json
body: <p>I am trying to build a web app that pulls data from server and adds multiple markers to the google map from the JSON response. This is how the JSON response looks like: </p>
  
  <pre><code>{"key":[{"Latitude":"60.186518","Longitude":"24.950575"}...]}
  </code></pre>
  
  <p>I tried to implement the code from <a href="https://stackoverflow.com/questions/7366861/plotting-latlng-coordinates-from-json-array-on-google-map-the-markers-all-st">this post</a> but I can't get it to work.</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>    function success(position) {
    var mapcanvas = document.createElement('div');
    mapcanvas.id = 'mapcontainer';
    mapcanvas.style.height = '600px';
  
    document.querySelector('article').appendChild(mapcanvas);
    var coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    var options = {
      zoom: 15,
      center: coords,
        panControl: false,
    zoomControl: false,
    mapTypeControl: false,
    scaleControl: false,
    streetViewControl: false,
    overviewMapControl: true,
  
      navigationControlOptions: {
        style: google.maps.NavigationControlStyle.SMALL
      },
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("mapcontainer"), options);
    var marker = new google.maps.Marker({
        position: coords,
        map: map,
        title:"You are here!"});
  
   function getLocations() {
  
      $.getJSON("http://myurl.com/jsonresponse", function (json) {
  
          var location;
  
  
          $.each(json.key, function (i, item) {
              addMarker(item.Latitude,item.Longitude);
          });
  
      });
  }
  
  function addMarker(lat,lng) {
          marker = new google.maps.Marker({
              position: new google.maps.LatLng(lat,lng),
              map: map,
          });
          markersArray.push(marker);
  }
  
  }
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(success);
  } else {
    error('Geo Location is not supported');
  }
  </code></pre>