Question

I have a div containing a google map and another div containing a set of entries with a scroll bar. I want to be able to click on a marker that appears on the map, and have the set of entries scroll to the entry associated with the clicked marker.

However, I keep getting an o is undefined error. I'm not sure how to do it another way besides the following:

I tried doing it this way:

$('.an_entry').each(function() {
  var id = $(this).attr('id');
  var lat = $(this).attr('lat');
  var lng = $(this).attr('lng');
  latlng = new google.maps.LatLng(lat, lng)
  $('#map').gmap('addMarker', {'position': latlng, 'bounds':true})
    .click(function() {
      $('#sideBar').scrollTo('#'+id);
    });
  });
Was it helpful?

Solution

I see that lat_pt and lng_pt are not defined. Should be lat and lng.

latlng = new google.maps.LatLng(lat, lng)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top