admin管理员组文章数量:1357225
I'm updating some older code that used the v2 API for Google Maps. On domready, it would use a statement like
if(google.maps.BrowserIsCompatible()){
// load the map
}
Now that I'm loading the Google Maps API v3, I get an error
google.maps.BrowserIsCompatible is not a function
I've read a ton of threads in the Google v3 api groups, but haven't found a clear answer of what the new function is called or how to reference it.
I'm updating some older code that used the v2 API for Google Maps. On domready, it would use a statement like
if(google.maps.BrowserIsCompatible()){
// load the map
}
Now that I'm loading the Google Maps API v3, I get an error
google.maps.BrowserIsCompatible is not a function
I've read a ton of threads in the Google v3 api groups, but haven't found a clear answer of what the new function is called or how to reference it.
Share Improve this question edited Nov 25, 2011 at 20:42 skaffman 404k96 gold badges824 silver badges775 bronze badges asked Aug 18, 2010 at 23:15 juliojulio 6,76815 gold badges65 silver badges82 bronze badges2 Answers
Reset to default 6GBrowserIsCompatibile didn't make it into the version three API, so you will have to write this code yourself.
Here is a list of the browsers supported by v3.
There is no equivalent of this method in V3 as of Google's V2 to V3 migration doc.
Instead, an efficient way to achieve this test is:
if (window.JSON) {
// load google maps api async (so google.maps object is available for further use)
}
That's because all the browsers that Google Maps API V3 support share that same particularity : they are the first versions (by their vendor) that supports JSON natively. See this screenshot taken from caniuse.:
Exceptions:
Firefox 3.0 and BlackBerry Browser 6 don't support JSON but are supported by Google Maps API. So the rule above will exclude both, which is an acceptable drawback for such a simple test (pared to a user-agent-sniffing-based code)
Notice:
this test doesn't apply to 'google.maps' object but at script load time. This prevents cases (e.g IE6) when the script is successfully loaded but 'google.maps' object unusable.
本文标签: javascriptGoogle Maps API v3 BrowserIsCompatibleStack Overflow
版权声明:本文标题:javascript - Google Maps API v3 BrowserIsCompatible - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744067780a2585323.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论