Google Maps API Tutorial© 2007, 2009 Mike Williams |
Translate this page: |
Alternative Map Type ControlsNew formats for the map type controls were introduced in v2.93 and v2.94. These new formats can be useful in situations where you have a large number of custom map types, causing the normal GMapTypeControl to become cumbersome.
The GMenuMapTypeControl() displays all the map types in a drop-down menu.
The GHeirarchicalMapTypeControl() lists "child" map types below their "parent" map type if that parent is active. GHeirarchicalMapTypeControl() has three Methods for managing parent and child map type relationships: GHierarchicalMapTypeControl.addRelationship(parent, child, name, isDefault) adds a parent/child map type relationship. The parameters are 1. parent GMapType 2. child GMapType 3. (optional) Name for child 4. (optional) isDefault booleanGHierarchicalMapTypeControl.removeRelationship(child) removes a parent/child map type relationship. The parameter is the child GMapType. GHierarchicalMapTypeControl.clearRelationships() removes all relationships. Here's an example of a map with seven map types showing all possible map type controls. Click the buttons to display the different controls. Here's an example that sets the map type controls to look exactly like the v2.94 maps.google.com controls. The Terrain map type is added. Hybrid is underneath Satellite and is selected by default when the Sattelite button is clicked. |