SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Location
    Poole, Dorset, United Kingdom
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE Null Error on Google Map API

    Hi all
    Getting a error message 'markers[...].1 is a null or not an object.
    Cant seem to fix it works fine in Firefox etc
    Any help would be great

    function initializeMaps() {
    var myOptions = {

    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
    var infowindow = new google.maps.InfoWindow();
    var marker, i;

    var bounds = new google.maps.LatLngBounds();

    for (i = 0; i < markers.length; i++) {
    var pos = new google.maps.LatLng(markers[i][1], markers[i][2]);
    bounds.extend(pos);
    marker = new google.maps.Marker({
    position: pos,
    map: map

    });
    google.maps.event.addListener(marker, 'click', (function(marker, i) {
    return function() {
    infowindow.setContent(markers[i][0]);
    infowindow.open(map, marker);
    }
    })(marker, i));
    }
    map.fitBounds(bounds);
    var listener = google.maps.event.addListener(map, "idle", function() {
    if (map.getZoom() > 16) map.setZoom(16);
    google.maps.event.removeListener(listener);
    });
    }

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,189
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Where is your markers variable been set as I don't see it anywhere in your above code snippet.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •