Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map API V3.0 - How to Detect MapTypeId Change

To add a listener to detect a zoom change works with the following:

google.maps.event.addListener(map,'zoom_changed',function())

What is the code to detect a change in the map type from ROADMAP to another view like SATELLITE? I can get the value:

val myMapType = map.getMapTypeId();

but do not know how to detect the change in view.

I am using the Google Map API V3.0

like image 884
Graham Avatar asked Jun 30 '10 23:06

Graham


People also ask

How do I know my Google map API key is working?

Go to the Credentials section, which can be accessed from the left side bar under Google Maps Platform > Credentials. Check that the API key you currently use on your website is listed.

How do you get bounds on Google Maps?

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.”

What is used to calculate the viewport of the Google Maps?

Latitude + (result. Span. Latitude/2); double swLon = result.


1 Answers

OK worked it out:

google.maps.event.addListener( map, 'maptypeid_changed', function() { 
    document.getElementById( "maptype" ).value = map.getMapTypeId();
} );
like image 162
Graham Avatar answered Oct 26 '22 16:10

Graham