Graham
Graham

Reputation: 275

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

Upvotes: 5

Views: 8430

Answers (1)

Graham
Graham

Reputation: 275

OK worked it out:

google.maps.event.addListener( map, 'maptypeid_changed', function() { 
    document.getElementById( "maptype" ).value = map.getMapTypeId();
} );

Upvotes: 21

Related Questions