Google maps API V3 code to V2 help.

Posted by abemonkey on Stack Overflow See other posts from Stack Overflow or by abemonkey
Published on 2010-05-01T00:20:04Z Indexed on 2010/05/01 0:27 UTC
Read the original article Hit count: 645

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>

© Stack Overflow or respective owner

Related posts about google-maps-api

Related posts about jQuery