Attention! Do you have any ideas for reorganizing and updating the Mapki? Please leave a note here. Thank you!
Undocumented Features
From Google Mapki
This is a list of some undocumented methods and objects in the API that might be useful.
Warning: undocumented features are not guaranteed to be stable. They might change or disappear when a new version of the API code is released.
- browser returns some information about the browser currently being used.
- browser.type - 1=IE, 2=Mozilla, 3=Safari, 4=Opera, 0=other
- browser.version - 5=IE5, 7=Opera7, 8=Opera8, 0=other
- browser.os - 1=X11, 2=macintosh, null=other
- GPoint methods
- point.tostring( ) - returns a string like "(-123.56,45.5)".
- point.equals(point2) - returns true if the points are exactly equal.
- point.approxEquals(point2) - returns true if the points are closer than 0.000001 degrees in each direction.
- point.distanceFrom(point2) - returns the distance between the points in degrees.
- GSize methods
- size.tostring( ) - returns a string like "(20,34)".
- size.equals(size2) - returns true if the GSize's are exactly equal.
- size.approxEquals(size2) - returns true if the GSize's are closer than 0.000001 pixels in each direction.
- GMap methods
- map.onResize( ) - call this if the size of the map container changes.
- map.saveMapState( ) - saves the centre and zoom info that gets used when you click on the reset control.
- map.redrawOverlays( ) - redraws all markers and polylines and the info window.
- map.registerKeyHandlers(window.document) - enables keyboard controls for panning and zooming (arrow keys, page up/down, home, end, and -)
- map.hideOverlays( ) - hides all markers and polylines and the info window.
- map.showOverlays( ) - shows all markers and polylines and the info window.
- map.spec.getLowestZoomLevel(point,size,viewsize) - calculates the closest zoom level which covers a specified area. The parameters are
- 1: a GPoint object specifying the map centre (e.g. map.getCentreLatLng( ))
- 2: a GSize object specifying the required width and height of the area in longitude and latitude degrees
- 3: a GSize object specifying the size of the viewport, you can use map.viewSize.
- map.pan(x,y) - pans by the specified number of pixels
- GMarker methods
- marker.copy() - returns a new GMarker with the same position and icon information
- marker.redraw(true) - redraws the marker. Use this after changing the marker.point information to move the marker. In browsers other than IE it will also refresh the icon image. Note that marker.redraw(), without the "true" does nothing. This is much faster than using map.removeOverlay() and map.addOverlay() to move a marker, and reduces the memory leak.
- marker.setZIndex(zindex) - Use this after changing the marker.point information to ensure that markers overlap correctly. The z-index of the markers is calculated from the initial latitude in map.addOverlay(), so that the more southerly markers lie above the more northerly ones. Use marker.setZIndex(Math.round(marker.getLatitude()*-100000)) to get a moved marker to overlap correctly.
- marker.display(false) - hides the marker.
- marker.display(true) - shows the marker. This is much faster than using map.removeOverlay() and map.addOverlay(), and reduces the memory leak.
- To make a marker bounce programatically in 2.63
marker.enableDragging(); marker.fc(marker.q); marker.p=marker.Yc; marker.dc(marker.q); marker.disableDragging();
- GPolyline methods
- polyline.copy( ) - returns a new GPolyline that is a copy of the first one
- polyline.redraw(true) - redraws the polyline
- polyline.display(false) - hides the polyline
- polyline.display(true) - shows the polyline. This is much faster than using map.removeOverlay() and map.addOverlay(), and reduces the memory leak.
- polyline.getPoint(n) - returns the location of the nth node of the polyline in GPoint format.
- Events
- There are additional map events "drag", "dragstart", "dragend", "mousedown", "mouseup" and "dblclick". You can use them like this:
GEvent.addListener(map, "mouseup", function() { ... });
- There are additional marker events "mouseup", "mouseover" and "mouseout". You can use them like this:
GEvent.addListener(marker, "mouseover", function() { ... });
- For all Event-Listeners you can use a named - not an anonymous - function in this way:
GEvent.addListener(map, "click", this.yourfunction);
function yourfunction() {
do_something();
}
- Map Types
- For several months, starting in September 2005, there was an additional map type: G_KATRINA_TYPE, which provided deeper zoom levels in the New Orleans region.
- GMapTypeControl parameter
- map.addControl(new GMapTypeControl(true)); - creates a map control with "tiny" buttons instead of the normal buttons.
- GScaleControl
- map.addControl(new GScaleControl( )); - displays a scale bar on the map
- map.addControl(new GScaleControl(x)); - displays a scale bar with a maximum length of x pixels, where x defaults to 125.
- GControlPosition( )
- A GControlPosition( ) object can be used to control the position of a map control. The parameters are:
- * anchor: specifies which corner the control is placed near 0=top left, 1=top right, 2=bottom left, 3=bottom right, or you can use the names G_ANCHOR_TOP_LEFT, G_ANCHOR_TOP_RIGHT, G_ANCHOR_BOTTOM_LEFT, G_ANCHOR_BOTTOM_RIGHT.
- * offset width: minimum horizontal distance from that corner
- * offset height: minimum vertical distance from that corner
- E.g. map.addControl(new GMapTypeControl( ),new GControlPosition(G_ANCHOR_TOP_LEFT,7,7)); places the map type control near the top left corner instead of the top right.
- G_DEFAULT_ICON
- Is simply the name of the default icon. This can be useful if you're using custom markers that have a similar size and shape because you can write myIcon = new GIcon(G_DEFAULT_ICON); then just change the properties that are different, and inherit everything else.
