This creates a widget to show a map provided by Google. One can specify the center of the map, markers on the map and add line semgemnts and polygons. This extension to gWidgets is gWidgetsWWW specific.
1 2 3
Location of center of map. Given as a string containing an address, or as a vector of latitude and longitude values.
The center is marked. This sets the text for the tooltip.
Determines type of map. One of "map" or "panorama".
A google API key. The default is for localhost 127.0.0.1:8079, which hopefully just works.
A gWidgetsWWW container object
This widget was created using the code posted to the ExtJS blog by Shea Frederick http://extjs.com/blog/2008/07/01/integrating-google-maps-api-with-extjs/ .
This widget requires the HTML page that will render it have the DOCTYPE of the page set according to these instructions: http://code.google.com/apis/maps/documentation/index.html#XHTML_and_VML
Next, the website the page will be listed on must register to have an
API key: http://code.google.com/apis/maps/signup.html. NOT WORKING:This key is
specifies through the
key argument. The default will work for the domain
The key can be specified in the header of the html page that will render the gWidgets code. The following will work for the domain 127.0.0.1:8079:
This widget is experimental. Its API is still not settled. As of
now, the method
svalue<- is used to set the center of the
map. After rendering this is done using a data vector of longitude
and latitude. Prior to rendering an address can be used.
[ method will return the markers locations, but does not
reflect their position after if they are moved with the mouse.
[$<$- method can be used to set markers. The value can
These are specified in a 2 or 3 column data frame with columns of
latitude, longitude and the optional title. After the widget has
rendered, the proto method
widget$addMarker is more efficient.
should work. The first argument of the handler,
h, is, as
usual, a list. The component
latlng contains a vector with
the latitude and longitude of the location the mouse click occurred at.
More of the Google maps API is availble through some proto
methods. These methods are called using the dollar sign notation, as
The available proto methods and their signatures are:
Returns a list with the lower and upper coordinates of the current map.
Sets map center to new coordinates specified using a numeric vector of latitude and longitude.
Sets new zoom value. Default is 14
Pops up message at point
Add a new marker at the
specified point with tooltip. These markers may be draggable. A popup
shows the new coordinates after dragging. However, the values
[ are not aware of the new coordinates.
lines graphic function, this
method adds line segments to the map. The points are specified in
latlng, which is a matrix or data frame with columns of
latitude and longitude values. If this is missing, the values set
addMarker are used. The color is set
using hexadecimal RGB notation, eg. "\#ff0000". Opacity levels less
than 1 allow the map to bleed through. When the line is clicked, its
length in meters is given.
graphics function, this method draws a polygon, rendering it on the
map. The points are specified by a matrix (or data.frame) to
latlng. If missing, the values set via
addMarker are used.. When the polygon is clicked its area in
square meters is presented.
Adding additional methods from the Google API is certainly possible.
Returns a gWidgetsWWW object.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.