google.maps.InfoWindow is not a constructor

3,861 views
Skip to first unread message

dsloan

unread,
Jan 25, 2011, 11:12:49 AM1/25/11
to google-map...@googlegroups.com
My Google maps code works fine until I introduce the line "var iw = new google.maps.InfoWindow();" as seen below. It says it's not a constructor, but the documentation and other examples I've seen clearly show that it is. Do I need to load another library or something? The markers, controls, are all created ok, just the InfoWindow which causes the problem. I've left out code to actually do anything with this info window just yet, just need to get past the constructor problem.
 
function initialize() {
        if(GBrowserIsCompatible()) {
          var map = new GMap2(document.getElementById('map'));
          map.setCenter(new GLatLng(39.91, 116.38), 2);
          map.addControl(new GLargeMapControl());
          var icon = new GIcon(G_DEFAULT_ICON);
          var markers = [];
          for (var i = 0; i < 100; ++i) {
            var latlng = new GLatLng(data.photos[i].latitude, data.photos[i].longitude);
            var marker = new GMarker(latlng, {icon: icon});
          var iw = new google.maps.InfoWindow(); 
            markers.push(marker);
          }
        }
      }

geoco...@gmail.com

unread,
Jan 25, 2011, 11:45:27 AM1/25/11
to Google Maps JavaScript API v3
That is v2 code. The v2 group is:
http://groups.google.com/group/google-maps-api

v2 doesn't have an google.maps.InfoWindow constructor. See the v2
documentation for the v2 function and Mike Williams' tutorial for how
to use them.
(links to all of the above in the v2 group)

-- Larry

dsloan

unread,
Jan 25, 2011, 12:18:22 PM1/25/11
to google-map...@googlegroups.com
Thanks Larry! Sorted.

dsloan

unread,
Jan 25, 2011, 6:21:37 AM1/25/11
to Google Maps JavaScript API v3
I have code working plotting markers on the map, but when I try to add
info windows to these markers I am getting the error
"google.maps.InfoWindow is not a contructor". The other objects GMap2,
GIcon, etc. are all working fine. Do I need to include an additional
library or something to use InfoWindow?

I have cut the code back to the bare bones to try to isolate the
problem. The window isn't even being triggered here, I just want to
get past the constructor problem. If I remove that "var iw=" line then
all works fine again.
Reply all
Reply to author
Forward
0 new messages