GMap Molecule

Add a programmable google map.

Preference Dialog

Comments

GMap molecule sends out additional events that a script molecule can listen to.  Using these events, implementers can create a highly interactive google map applications.  These events are,

mousemovemouse moves over the map.
mouseovermouse enters the map.
mouseoutmouse leaves the map.
clicka mouse click on the map.
dblclicka mouse double click on the map.
rightclicka mouse right click on the map.
maptypeid_changeduser changed the map type.
projection_changeduser changed projection type in 3D view.
tilt_changeduser changed tilt amount in 3D view.
heading_changeduser changed map heading in 3D view.
center_changeduser changed map center.
idlenothing has happend.
infowindowopenan infowindow has just been opened.
infowindowclosean infowindow has just been closed.
zoom_changeduser changed zoom level.
dragstartuser has started dragging the map.
draguser is dragging the map.
dragenduser has finished dragging the map.
maploadmap has finished loading all its tiles.

Properties

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 function dynamically.

pref.lat

float, ( r, w )

The starting latitude of this google map.

pref.lng

float, ( r, w )

The starting longitude of this google map.

pref.z

int, ( r, w )

The starting zoom of this google map.

pref.type

string, ( r, w )

The starting type of this google map.  (map, sat, hyb, ter.)

mapType

string, ( r )

Returns the internal google map type ID.

center

object, ( r )

Returns the center of the map as {lat:12, lng:-77}.

bounds

object, ( r )

Returns the map’s bounds in latitudes and longitudes.

zoom

int, ( r, w )

Gets/Sets the map’s zoom value.

tilt

float, ( r, w )

Gets/Sets the map’s degree of tilt in 3D view.

heading

float, ( r, w )

Gets/Sets the map’s degree of heading in 3D view.

Functions

attach

attach(droplet);

Attach this molecule to the given droplet.

Parameters

droplet(object) a droplet.

Returns

N/A

detach

detach();

Remove this molecule from its droplet.

Parameters

N/A

Returns

N/A

delete

delete();

Delete this molecule.

Parameters

N/A

Returns

N/A

rename

rename(name);

Rename this molecule.

Parameters

name(string) a new name.

Returns

N/A

refresh

refresh();

Forces molecule to redraw with the current set of preferences.

Parameters

N/A

Returns

N/A

clone

clone();

Create a clone of this molecule.

Parameters

N/A

Returns

(object) a molecule.

serialize

serialize();

Serialize this molecule into its JSON representation.

Parameters

N/A

Returns

(string) JSON representation of a molecule.

setCenter

setCenter(lat, lng, zoom);

Move map’s center point to the given latitude and longitude, and set the zoom value as given.

Parameters

lat(float) latitue.
lng(float) longitude.
zoom(int) zoom level.

Returns

N/A

getLatLngFromAddress

getLatLngFromAddress(address, callback);

Use google map’s geocoder to resolve an address to latitude and longitude.  This operation is asynchonous, use a callback to receive the result.

Parameters

address(string) a valid street address.
callback(mixed) a document level function or a script molecule.  The result is in the format of {lat:value, lng:value}.

Returns

N/A

getLatLngFromPixel

getLatLngFromPixel(x, y);

Returns latitude and longitude from the given (x, y) position in a droplet’s window.

Parameters

x(int) x-coordinate in relation to the top left corner of the droplet.
y(int) y-coordinate in relation to the top left corner of the droplet.

Returns

(object) {lat:value, lng:value}

getPixelFromLatLng

getPixelFromLatLng(lat, lng);

Returns (x, y) position in a droplet’s window from the given latitude and longitude.

Parameters

lat(float) latitude.
lng(float) longitude.

Returns

(object) {x:value, y:value}

addMarker

addMarker(lat, lng, name);

Adds a named marker at the given latitude and longitude.

Parameters

lat(float) latitude.
lng(float) longitude.
name(string) an identifier for this marker.

Returns

N/A

removeMarkerByName

removeMarkerByName(name);

Removes the named marker.

Parameters

name(string) an identifier for a marker.

Returns

N/A

removeMarkerByLatLng

removeMarkerByLatLng(lat, lng);

Removes the marker at (latitude, longitude).

Parameters

lat(float) latitude.
lng(float) longitude.

Returns

N/A

clearMarkers

clearMarkers();

Removes all markers.

Parameters

N/A

Returns

N/A

panTo

panTo(lat, lng);

Move map’s center point to (lat, lng).  If the change is less than both the width and height of the map, the transition will be smoothly animated.

Parameters

lat(float) latitude.
lng(float) longitude.

Returns

N/A

panBy

panBy(x, y);

Changes the center of the map by the given distance in pixels.  If the distance is less than both the width and height of the map, the transition will be smoothly animated.

Parameters

x(int) delta in x direction.
y(int) delta in y direction.

Returns

N/A

zoomIn

zoomIn();

Increases the zoom level by one.

Parameters

N/A

Returns

N/A

zoomOut

zoomOut();

Decreases the zoom level by one.

Parameters

N/A

Returns

N/A

plotRoute

plotRoute(lat1, lng1, lat2, lng2, opt);

Computes and displays directions between two places given by (lat1, lng1) and (lat2, lng2).

Parameters

lat1(float) source latitude.
lng1(float) source longitude.
lat2(float) destination latitude.
lng2(float) destination longitude.
opt(object) routing preferences.  Can have the following properties,
avoidHighways - (bool)
avoidTolls - (bool)
optimizeWaypoints - (bool)
provideRouteAlternatives - (bool)
travelMode - (const) GMAP_DRIVING, GMAP_BICYCLING, GMAP_TRANSIT, GMAP_WALKING.
transitOptions - (object)
waypoints - (object)
unitSystem - (const) 'IMPERIAL', 'METRIC'.

See Google Map Direction Service for information on how to set these values.

Returns

N/A

plotRouteByAddresses

plotRouteByAddresses(addr1, addr2, opt);

Computes and displays directions between two places given by addr1 and addr2.

Parameters

addr1(string) source address.
addr2(string) destination address.
opt(object) routing preferences.  Can have the following properties,
avoidHighways - (bool)
avoidTolls - (bool)
optimizeWaypoints - (bool)
provideRouteAlternatives - (bool)
travelMode - (const) GMAP_DRIVING, GMAP_BICYCLING, GMAP_TRANSIT, GMAP_WALKING.
transitOptions - (object)
waypoints - (object)
unitSystem - (const) 'IMPERIAL', 'METRIC'.

See Google Map Direction Service for information on how to set these values.

Returns

N/A

removeRoute

removeRoute();

Removes route from the map.

Parameters

N/A

Returns

N/A

getDirections

getDirections();

Returns the current route’s turn by turn directions.

Parameters

N/A

Returns

(object) route directions.

openInfoWindow

openInfoWindow(name, opt);

Opens a info window at the named marker.

Parameters

name(string) a valid marker name.
opt(object) info window preferences.  Can have the following properties,
content -        (string) Content to display in the InfoWindow. This can be an HTML element,
                          a plain-text string, or a string containing HTML.

disableAutoPan - (bool) Disable auto-pan on open. By default, the info window will
                        pan the map so that it is fully visible when it opens.

maxWidth -       (int) Maximum width of the infowindow, regardless of content's width.

pixelOffset -    (object) The offset, in pixels, of the tip of the info window from the
                          anchor point.

position -       (object) The LatLng at which to display this InfoWindow. If the InfoWindow
                          is opened with an anchor, the anchor's position will be used instead.

zIndex -         (int) All InfoWindows are displayed on the map in order of their zIndex,
                       with higher values displaying in front of InfoWindows with lower values.

See Google Map InfoWindow options for information on how to set these values.

Returns

N/A

closeInfoWindow

closeInfoWindow(name);

Closes the currenly opened info window by name.

Parameters

name(string) a valid marker name.

Returns

N/A

viewTraffic

viewTraffic(opt);

Shows/Hides current traffic condition on the map.

Parameters

opt(bool)

Returns

N/A

Close