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.
getBounds() in Google Maps API v3 But in API v3 you will get “bounds is undefined” error. So to get our latitude and longitude we need to move getBounds(), to some event listener. Description of bounds_changed in documentation is: “This event is fired when the viewport bounds have changed.”
Static Maps images can be returned in any size up to 640 x 640 pixels. If you need images with sizes larger than 640 x 640 pixels (or 640 x 640640 x 640 pixels with a scale value of 2), follow these steps.
Sets the viewport to contain the given bounds. Note: When the map is set to display: none , the fitBounds function reads the map's size as 0x0, and therefore does not do anything. To change the viewport while the map is hidden, set the map to visibility: hidden , thereby ensuring the map div has an actual size.
maps) {...} will give you a reference error if google is undefined (i.e. if the API didn't load). Instead, use if (typeof google === 'object' && typeof google. maps === 'object') {...} to check if it loaded successfully.
GBrowserIsCompatibile 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With