开发者

this.grid_ is undefined with MarkerManager and Google Maps v3

开发者 https://www.devze.com 2023-01-26 03:39 出处:网络
I am updating a maps page to v3 and I am getting the following error from markermanager.js this.grid_ is undefined - var grid = this.grid_[z]; which is on line 529

I am updating a maps page to v3 and I am getting the following error from markermanager.js

this.grid_ is undefined - var grid = this.grid_[z]; which is on line 529

This is caused by the following code MarkerManager.addMarker(marker);

I am creating a lot of markers and most of them are added no problem however there are a few that throw this error. On first glance all of the maker ob开发者_StackOverflow中文版jects appear similar enough to make it work.

Any thoughts?


You may also get this error if you add markers to the manager using an array, if you set a max zoom level that's not appropriate.

eg.:

markermgr.addMarkers(markerArray,6,20);

where 6 is the minzoom and 20 is the maxzoom.

The maxzoom level used to be 17, but you can now zoom in to 20+ in some urban areas.


It turns out that this error occurs when you try to add markers to markerManager before it is loaded. To avoid this error you have to add an event listener after the markerManager is created like so...

google.maps.event.addListener(markerManager, 'loaded', function() {

   //add ajax call or any other code here

});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号