views:

36

answers:

0

I've started working on a project to inject markers into a map with jQuery by looping through rows on a table in the page. After getting it working I realized that I was accessing the V3 API and using V3 syntax. I've been beating my head against a wall trying to get this working in google maps API V2. If someone could please take a look at my code and help that would be great! Thanks! You can see my little test in action at www.axtsweapons.com/maptest.html. Here is the JS code:

<script type="text/javascript">
$(function() {
var latlng = new google.maps.LatLng(45.440000,-122.630000);
var settings = {
  zoom: 12,
  center: latlng,
  disableDefaultUI: false,
  mapTypeControl:false,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("map_canvas"), settings);

  $('tr').each(function(i) {

     var the_marker = new google.maps.Marker({
        title: $(this).find('.views-field-title').text(),
        map: map,
        clickable: true,
        position: new google.maps.LatLng(
           parseFloat($(this).find('.views-field-latitude').text()),
           parseFloat($(this).find('.views-field-longitude').text())
        )
     });
      var bounds = new google.maps.LatLngBounds();


     var infowindow = new google.maps.InfoWindow({
        content:  $(this).find('.views-field-title').text() +
                  $(this).find('.adr').text()
     });

     new google.maps.event.addListener(the_marker, 'click', function() {
        infowindow.close();
        infowindow.open(map, the_marker);
     });
  });
});


</script>