GMap Molecule
From oWiki
Preference Dialog
Attributes
type
string ( r )
Type of this molecule, 'gmap'.
pref.name
string ( r )
The scriptable name for this molecule. This name can be set using rename method dynamically.
pref.lat
float ( r, w )
Latitude. Latitude is the number of degrees north or south of the equator, and ranges from -90 (South Pole) to 90 (North Pole).
pref.lng
float ( r, w )
Longitude. Longitude is the number of degrees east or west of the prime meridian at Greenwich, in England, and ranges from -180 (westward) to 180 (eastward).
pref.z
int ( r, w )
Specifies the zoom level of the map. Valid values are from 0 to 18. At zoom level 0, a single tile covers the Earth.
pref.control
string ( r, w )
Specifies a comma-delimited list of map controls. Possible Values are panControl, zoomControl, mapTypeControl, scaleControl, streetViewControl, and overviewMapControl.
pref.type
string ( r, w )
Specifies the type of map.
| Value | Description |
|---|---|
| map | The street map. |
| sat | The satellite imagery. |
| hyb | The combination of street map and satellite imagery. |
| ter | The combination of street map and terrain. |
Methods
rename(n)
n: string
| Rename this molecule. |
refresh()
| Force molecule to redraw with the current set of attributes. |
clone()
Return: a molecule
| Create a clone of this molecule. |
attach(droplet)
droplet: a droplet object (e.g. app.box.droplet)
| Attach this molecule to a droplet. |
detach()
| Remove this molecule from its droplet. |
deleteMod()
| Delete this molecule. |
serialize()
Return: string
| Serialize this molecule into its JSON representation. |
setCenter( lat, lng, zoom )
lat: float
lng: float
zoom: int
| Centers the map at the given latitude and longitude and at the given zoom level. |
getLatLngFromPixel( x, y )
x: int
y: int
Return: array
| Returns the latitude and longitude from the given pixel location on the map (relative to the upper left corner of the droplet). This function returns an array of [lat, lng]. |
getPixelFromLatLng( lat, lng )
lat: float
lng: float
Return: array
| Returns the pixel location on the map (relative to the upper left corner of the container) from the given latitude and longitude. This function returns an array of [x, y]. |
getLatLngFromAddress( addr )
addr: string
Return: array
| Returns the latitude and longitude from the given address. This function returns an array of [lat, lng]. |
addMarker( lat, lng, name )
lat: float
lng: float
name: string
| Adds a marker at (lat, lng). The marker's title is set as name. |
removeMarkerByName( name )
name: string
| Remove the marker with the given title. |
removeMarkerByLatLng( lat, lng )
lat: float
lng: float
| Remove markers at (lat, lng). |
clearMarkers()
| Clears all markers. |
getBounds()
Return: array
| Returns the locations of the upper left and bottom right corners of the map in an array, [lat_ul, lng_ul, lat_br, lng_br]. |
getCenter()
Return: array
| Returns the location of the center of the map. This function returns an array of [lat, lng]. |
getTilt()
Return: int
| Returns the angle of incidence for aerial imagery (available for SATELLITE and HYBRID map types) measured in degrees from the viewport plane to the map plane. A value of 0 indicates no angle of incidence (no tilt) while 45° imagery will return a value of 45. |
setTilt(x)
x: int
| Sets the angle of incidence for aerial imagery. |
getHeading()
Return: int
| Returns the compass heading of aerial imagery. The heading value is measured in degrees (clockwise) from cardinal direction North. |
setHeading(x)
x: int
| Sets the compass heading of aerial imagery. |
getZoom()
Return: int
| Returns the current zoom level. |
setZoom( z )
z: int
| Sets the current zoom level from 0 to 18. |
panTo( lat, lng )
lat: float
lng: float
| Pans the map to the given latitude and longitude. |
panBy( x, y )
x: int
y: int
| Pans the map by the given pixels in the x and y directions. |
zoomIn()
| Increases the zoom level by 1. |
zoomOut()
| Decreases the zoom level by 1. |
getCurrentMapType()
Return: int
| Get the current map type (roadmap, satellite, hybrid, terrain). |
plotRoute(lat1, lng1, lat2, lng2, opt)
lat1: float
lng1: float
lat2: float
lng2: float
opt: object
| Plot the direction from starting point (lat1, lng1) to the end point (lat2, lng2) using the options given in opt. Possible option properties are:
|
plotRouteByAddresses(addr1, addr2, opt)
addr1: string
addr2: string
opt: object
| Plot the direction from starting address addr1 (e.g. Chicago, IL) to the end address addr2 using the options given in opt. |
removeRoute()
| Remove direction from the map. |
getDirections()
Return: string
| Returns the detailed direction result currently displayed in the map as JSON string. |
openInfoWindow(name, opt)
name: string
opt: object
| Open an info window anchored at the marker with the given name and use the options given in opt. Possible option properties are:
|
closeInfoWindow(name)
name: string
| Close the info window associated with the marker that has the given name. |
viewTraffic(opt)
opt: bool
| Turn on/off the traffic overlay. |
Events
This molecule adds the following Google Map Events to the droplet:
click
This event is fired when the map is clicked with the mouse.
(params.event.screenX, params.event.screenY) is the position of the click in the screen coordinate.
(params.event.boxX, params.event.boxY) is in the droplet's coordinate.
params.event.which tells which button is clicked.
params.overlay is the name of the marker that is clicked, otherwise, it equals '<map>' which signifies that the map itself is clicked.
dblclick
This event is fired when a double click occurs on the map.
mousedown
This event is fired when a mousedown occurs on the map.
mouseup
This event is fired when a mouseup occurs on the map.
mouseover
This event is fired when a mouseover occurs on the map.
mouseout
This event is fired when a mouseout occurs on the map.
idle
This event is fired when the map becomes idle after panning or zooming.
maptypeid_changed
This event is fired when the mapTypeId property changes.
projection_changed
This event is fired when the projection has changed.
zoom_changed
This event is fired when the map reaches a new zoom level.
tilt_changed
This event is fired when the map tilt property changes.
heading_changed
This event is fired when the map heading property changes.
center_changed
This event is fired when the map center property changes.
dragstart
This event is fired when the user starts dragging the map.
drag
This event is repeatedly fired while the user drags the map.
dragend
This event is fired when the user stops dragging the map.
mapload
This event is fired when the visible tiles have finished loading.
Comments
(1) The GMap Molecule uses server-side embedding of Google Map API Version 3, no API key is required.
(2) A complete documentation and in-depth exposition of Google Map can be found here: Google Map API.

