This library makes it easy to generate an image "snapshot" of your interactive map, using the Google Static Maps API.
The default behavior adds a control to the map, and then shows a popup with the snapshot when the control is clicked. However, the control can be hidden and the generated snapshot URLs can be programmatically retrieved, so the library may be used in a more flexible manner.
This control can detect the standard overlays (GMarker, GPolygon, GPolyline) and render them in the snapshot, and in the case of a poly with many points, it can pass in the points as an encoded string, resulting in a shorter URL.
The control will attempt to sense everything about the map and overlays, within the limits of what the API offers accessors for. For example, if the the filename of a marker's icon is "marker_greenA.png", then this control will parse that and set the parameters accordingly. If you want the control to maintain the style of polys, you must set additional properties on each poly object: ssColor, ssWeight, ssOpacity, and for polygons, ssFillColor and ssFillOpacity.
Various options can be sent into the constructor to change the default rendering of the snapshot.
For a description and examples of how to use this library, check out the how-to.
Constructor | Description |
---|---|
SnapShotControl(opt_opts?:SnapShotControlOptions) |
Creates a control with options specified in SnapShotControlOptions . |
Methods | Return Value | Description |
---|---|---|
getImage(mapCenterPos?:GLatLng) |
String |
Generate new URL for snapshot. If no center is passed in, then it uses the center of the map. If the center is set to false, then the center of the snapshot is auto-calculated based on the overlay positions. |
getImageUrl() |
String |
The most recently generated URL. |
hide() |
None |
Change visibility of the control to hidden. |
isHidden() |
Boolean |
Returns true when the control is hidden. |
isMobile(mobile:Boolean) |
None |
Specify whether to use mobile optimized tiles. |
setFormat(format:String) |
None |
Specify image format. The options are "gif," "jpg," "jpg-baseline," "png8," "png32". |
setLanguage(language:String) |
None |
Specify language for snapshot's copyright texts. |
setMapSize(mapSize:GSize) |
None |
Specify size for snapshot. |
setMapType(mapType:String) |
None |
Specify maptype for snapshot. The options are "roadmap", "satellite", "hybrid", "terrain" or auto-detect(""). |
show() |
None |
Change visibility of the control to visible. |
showPopup(mapCenterPos?:GLatLng) |
None |
Generate new snapshot URL and show popup with image and URL. |
usePolylineEncode(useEncode:Boolean) |
None |
Specify whether to use polyline encoding. |
This class represents optional arguments to SnapShotControl
. There is no constructor for this class. Instead, this class is instantiated as a javascript object literal.
Properties | Type | Description |
---|---|---|
buttonLabelHtml |
String |
Specify label HTML of
control button. The default value is "Say cheese!" . |
format |
String |
Specify image format for snapshot.
You can choice one from "gif", "jpg", "jpg-baseline", "png8", "png32". The default value is "gif" . |
hidden |
Boolean |
Specify visibility when control is
added to the map. If it is set to true, the button is hidden. The default value is false . |
language |
String |
Specify language for snapshot's copyrights.
If it is not set, then this library detects the language of the map. The default value is "" . |
maptype |
String |
Specify maptype for snapshot.
The options are "roadmap", "satellite", "hybrid", "terrain".
If it is not set, then the control detects the type of the map. The default value is "" . |
mobile |
Boolean |
Specify whether to use mobile optimized
tiles for snapshot. Useful for mobile devices. This property is ignored,
when the style property is not set to "roadmap". The default value is false . |
useAutoDetectMarker |
Boolean |
If it is set to true, the
control attempts to auto detect the marker color, label, and size,
based on standard image naming conventions. The default value is true . |
usePolylineEncode |
Boolean |
Specify whether to
use encoded polys in the snapshot. Useful if you're sending in a big poly,
and want to stay within URL limits. The default value is false . |