Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

44 Part I — Basics


Table 3-3(continued)

Method Description

recenterOrPanTo Centers the map at the given point, doing a fluid pan to the
LatLng(latLng) point if it is within the current map viewport.
zoomTo(zoomLevel) Zooms to the given integer zoom level, ignoring the request if
the given zoom level is outside the bounds of the current map
type.
centerAndZoom(latLng, Atomically centers and zooms the map. Useful to initialize the
zoomLevel) map with an initial center and zoom level.
getMapTypes() Returns an array of map types supported by this map
(currently G_MAP_TYPE, G_HYBRID_TYPE, and
G_SATELLITE_TYPE).
getCurrentMapType() Returns the map type currently in use (G_MAP_TYPE,
G_HYBRID_TYPE, or G_SATELLITE_TYPE).
setMapType(mapType) Switches this map to the given map type (G_MAP_TYPE,
G_HYBRID_TYPE, or G_SATELLITE_TYPE).

To add an overlay to the map, you must first create the overlay (using GMarkeror
GPolyline) and then use the addOverlaymethod from Table 3-4 to draw the overlay onto
the map. You can also delete an overlay (providing you have the object definition) or remove all
overlays.

Table 3-4: Methods for Adding/Removing Overlays to a Map

Method Description

addOverlay(overlay) Adds the given overlay object to the map.
removeOverlay(overlay) Removes the given overlay object from the map.
clearOverlays() Removes all of the overlays from the map.

To add an information window to a map, use the methods in Table 3-5. Note that the methods
in this table are primarily aimed at adding information windows to areas of the map that do
not have a specific marker; there is a separate method for adding information windows to
markers that is part of the definition for the GMarkerobject.

You configure events for a map object, marker, or other element by using one of the event types
specified in Table 3-6. These events are common to all places where you can specify an event.
Free download pdf