Class GSMap
GSMap is the central class in the Maps API encapsuating functionality for map creation, management of map feature layers, and map navigation.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
GSMap(container, options, listeners)
Constructs a new
GSMap that is initialized with the
properties provided in the options object literal. |
| Property Attributes | Property Name and Description |
|---|---|
| <static> |
GSMap.COMPACT_ZOOM_CONTROL
Constant for specifying a compact zoom control to be placed on the map
|
| <static> |
GSMap.COPYRIGHT_CONTROL
Constant for specifying the copyright control
|
| <static> |
GSMap.MAP_CONTROL
Constant for specifying a pan control to be placed on the map
|
| <static> |
GSMap.MAP_TYPE_CONTROL
Constant for specifying a map type control to be placed on the map
|
| <static> |
GSMap.MOBILE_ZOOM_CONTROL
Constant for specifying a mobile zoom control
|
| <static> |
GSMap.SCALEBAR_CONTROL
Constant denoting the map scalebar control
|
| <static> |
GSMap.SNAPBACK_CONTROL
Constant denoting the map snapback control
|
| <static> |
GSMap.ZOOM_CONTROL
Constant for specifying a regular zoom control to be placed on the map
|
| Method Attributes | Method Name and Description |
|---|---|
|
addContextMenuItem(menuItem)
Adds a context menu item for this component.
|
|
|
addControl(control, position)
Adds a control to the map
|
|
|
addFeature(feature)
A convenience function for adding a feature to the map
without explicitly creating a layer first.
|
|
|
addLayer(layer)
Adds a new layer to this map
|
|
|
addListener(obj)
Adds the specified object as a listener on this object.
|
|
|
addToSelection(item)
Expands the current selection to include the item passed in
|
|
|
animatedZoom(zoomLevel, onZoom)
Animates zooming from the current map zoom level to the new zoom level
specified
|
|
|
centerAndZoom(coordinate, zoomLevel, onCenter)
Centers the map on the provided coordinate at the given zoom level
|
|
|
centerAtCoordinate(coordinate, onCenter)
Centers the map on the specified coordinate
|
|
|
centerOnLayer(layer, onCenter)
Re-centers the map on the named layer.
|
|
|
centerOnNewZealand(onCenter)
Centers the map on the center of New Zealand, Nelson, and at such a scale that the full
extent of the country is visible
|
|
|
Removes all features from all layers that have been added
to this map.
|
|
|
Removes all items from the current selection
|
|
|
closeInfoWindow(coordinate, html)
Close the info window if it is open
|
|
|
contains(coordinate)
Tests if the specified coordinate is within the current map extents
|
|
|
createLayer(name, options)
Creates a new layer with the specified name.
|
|
|
Disables this component's context menu
|
|
|
Enables this component's context menu if it has been set
|
|
|
Returns the active map base layer
|
|
|
Returns the bounds of the map viewport as NZMG coordinates
|
|
|
Returns a reference to the map's container element
|
|
|
Returns the context menu for this component
|
|
|
getControl(name)
Returns the named map control, or
null if no control
has been added to the map with the given name |
|
|
Returns this map's info window instance
|
|
|
getLayer(name)
Returns the named map layer
|
|
|
Returns the feature layers for this map instance
|
|
|
Returns the center point of the map as an NZMG coordinate
|
|
|
Gets the current selection
|
|
|
getSize()
Returns the size, in pixels, of this map
|
|
|
Returns the current map zoom level
|
|
|
Hides all map controls
|
|
|
isSelected(item)
Tests if the item passed in is currently selected
|
|
|
markForSnapback(persistent)
Marks the current map position and zoom level for snapping back to later by GSMap#snapback
|
|
|
openInfoWindow(coordinate, html, options)
Displays the info window at the given coordinate.
|
|
|
openMapBlowup(coordinate, options)
Opens the info window with a blowup of the map specified by the coordinate
and mpx parameters
|
|
|
panTo(coordinate, onCenter, options)
Pans the map to the specified coordinate.
|
|
|
print(printServiceUrl, options)
Creates a raster image representation of the current map view using a server-side print
service and returns the URL for the image
|
|
|
remove()
Destroys any resources created by this map instance
|
|
|
Removes this component's context menu
|
|
|
removeContextMenuItem(menuItem)
Removes the passed in context menu item from the list of menu items dynamically
added by this component to its context menu
|
|
|
removeControl(control)
Removes a control from the map
|
|
|
removeFeature(feature, destroy)
A convenience function for removing a feature that was added
directly to the map
|
|
|
removeFromSelection(item)
Removes the passed in item from the current selection
|
|
|
removeLayer(name)
Removes a feature layer from the map
|
|
|
removeListener(obj)
Removes the specified object as a listener from this object
|
|
|
resize(topDelta, rightDelta, bottomDelta, leftDelta)
Notify the map of a change in the dimensions of the map container.
|
|
|
setBaseLayer(name, redraw)
Sets the map's active tile layer
|
|
|
setBounds(bounds, onBoundsChanged)
Sets the map extents to those specified by the bounds object
|
|
|
setContextMenu(contextMenu)
Sets the context menu for this component
|
|
|
setMapOptions(options)
Updates the map's configuration properties.
|
|
|
setSelection(items)
Sets the selection
|
|
|
Shows all map controls
|
|
|
snapback()
Restores the map view saved by GSMap#markForSnapback
|
|
|
startContinuousPan(delta)
Starts the map continuously panning in the direction specified by the
delta
parameter |
|
|
Stops a previously started continuous pan operation
|
|
|
toJson()
Outputs a JSON representation of this map
|
|
|
translateToMapCoordinate(coordinate)
Translates an NZMG
X/y coordinate
to it's corresponding pixel values in the screen map's coordinate space. |
|
|
translateToRealWorldCoordinate(coordinate, bounds)
Translates a coordinate in the screen map's coordinate space into a real
world coordinate (NZMG)
|
|
|
Recalculates the dimensions of the map from its container.
|
|
|
zoom(zoomLevel, onZoom)
Zooms to the specified zoom level
|
| Event Attributes | Event Name and Description |
|---|---|
|
infoWindowClosed(infoWindow)
|
|
|
infoWindowMaximized(infoWindow)
|
|
|
infoWindowOpened(infoWindow)
|
|
|
infoWindowOpening(infoWindow)
|
|
|
infoWindowRestored(infoWindow)
|
|
|
mapBaseLayerChanged(map, layer)
|
|
|
mapBoundsChanged(map, oldBounds, newBounds)
|
|
|
mapClicked(map, coordinate, event)
|
|
|
mapDblClicked(map, coordinate, event)
|
|
|
mapPanStarted(map)
|
|
|
mapPanStopped(map)
|
|
|
mapReady(map)
|
|
|
mapResized(map, oldSize, newSize)
|
|
|
mapZoomed(map, oldZoomLevel, newZoomLevel)
|
|
|
selectionChanged(selection)
|
Class Detail
GSMap(container, options, listeners)
Constructs a new
GSMap that is initialized with the
properties provided in the options object literal.
Most of the available options may be set on the new map instance after it has been created using the GSMap#setMapOptions method.
var options = {
centerX: 2530000,
centerY: 5990000,
width: 600,
height: 400,
zoomLevel: 3
};
var map = new GSMap('map', options);
- Parameters:
- {Mixed} container
- may be either a reference to the DOM element that will contain the map,
or the value of the
idproperty of that element. - {Object} options Optional
- an object literal specifying the map options to set:
- {boolean} options.centerOnDblClick
- when
trueenables map recentering when double-clicking on the map - {boolean} options.dragToPan
- when
trueenables map panning by moving the mouse while holding down the left mouse button. - {boolean} options.useMouseWheelZooming
- if
truemouse wheel zooming is enabled for the map - {String} options.mouseWheelModiferKey
- specifies a modifier to use to actuate mouse wheel zooming
- {boolean} options.animatedZooming
- if
truezooming will be animated, defaults totrue - {boolean} options.useInfoWindow
- if
truethe info window is enabled for the map - {boolean} options.useScalebar
- if
truea scalebar will be displayed on the map - {boolean} options.resizeable
- if
truethe map will be sized to fit its container element - {int} options.zoomLevel
- an integer value specifying the initial zoom level of the map, ranging from 16 (maximum zoom in) to 4 (maximum zoom out)
- {float} options.centerX
- the x coordinate the map should be initially centered on, currently the NZMG projection is supported only
- {float} options.centerY
- the y coordinate the map should be initially centered on, currently the NZMG projection is supported only
- {int} options.width
- the width of the map viewport in pixels. This option should be used exclusively of the
resizeableoption - {int} options.height
- the height of the map viewport in pixels. This option should be used exclusively of the
resizeableoption - {String} options.customCursor
- specifies the mouse cursor to display for the map viewport
- {Object} options.baseLayerOptions
- @see GSTileLayer constructor docs
- {Array} listeners
- an array of objects to subscribe to events published by the map
- Throws:
- {Error}
- if a DOM element is not specified as the first argument
Property Detail
<static>
{String}
GSMap.COMPACT_ZOOM_CONTROL
Constant for specifying a compact zoom control to be placed on the map
<static>
{String}
GSMap.COPYRIGHT_CONTROL
Constant for specifying the copyright control
<static>
{String}
GSMap.MAP_CONTROL
Constant for specifying a pan control to be placed on the map
<static>
{String}
GSMap.MAP_TYPE_CONTROL
Constant for specifying a map type control to be placed on the map
<static>
{String}
GSMap.MOBILE_ZOOM_CONTROL
Constant for specifying a mobile zoom control
<static>
{String}
GSMap.SCALEBAR_CONTROL
Constant denoting the map scalebar control
<static>
{String}
GSMap.SNAPBACK_CONTROL
Constant denoting the map snapback control
<static>
{String}
GSMap.ZOOM_CONTROL
Constant for specifying a regular zoom control to be placed on the map
Method Detail
addContextMenuItem(menuItem)
Adds a context menu item for this component. The menu item will be dynamically
added to the context menu set on the component when it is displayed.
When the context menu is closed the menu item will be automatically removed.
Requires that a context menu has first been set for this component.
- Parameters:
- {GSMenuItem} menuItem
- the menu item to set
- Throws:
- {Error}
- if an attempt is made to add a context menu item before a context menu has been set
addControl(control, position)
Adds a control to the map
map.addControl(GSMap.MAP_CONTROL,
{anchor: GSControl.ANCHOR_TOP_LEFT, offset: new GSPoint(7, 7)});
- Parameters:
- {Object} control
- the control object, or a String constant identifying the type of control to add to the map.
- {Object} position Optional
- specifies the position of this control on the map.
The control's position is specified as an object literal with 2 properties
anchorandoffset
- See:
- GSMap.MAP_TYPE_CONTROL
- GSMap.ZOOM_CONTROL
- GSMap.COMPACT_ZOOM_CONTROL
- GSMap.MAP_CONTROL
- GSMap.SNAPBACK_CONTROL
- GSMap.SCALEBAR_CONTROL
addFeature(feature)
A convenience function for adding a feature to the map
without explicitly creating a layer first. Features added in this
way are owned by the map's 'base' layer.
- Parameters:
- {MapFeature} feature
- a feature to be added to the map
- See:
- GSMap#removeFeature
{GSAbstractLayer}
addLayer(layer)
Adds a new layer to this map
- Parameters:
- {GSAbstractLayer} layer
- the layer to add to the map
- Returns:
- {GSAbstractLayer} the layer that was added
{boolean}
addListener(obj)
Adds the specified object as a listener on this object. The listener
object should provide callback methods for any events it wishes to
support
- Parameters:
- {Object} obj
- the object that should be added as a listener
- Returns:
- {boolean}
trueif the object was successfully added as a listener
addToSelection(item)
Expands the current selection to include the item passed in
- Parameters:
- {Object} item
- the item to add to the selection
animatedZoom(zoomLevel, onZoom)
Animates zooming from the current map zoom level to the new zoom level
specified
- Parameters:
- {int} zoomLevel
- the zoom level to set
- {Function} onZoom Optional
- callback to invoke after zooming has completed
centerAndZoom(coordinate, zoomLevel, onCenter)
Centers the map on the provided coordinate at the given zoom level
- Parameters:
- {GSPoint} coordinate
- the real world coordinate (NZMG) to center the map on
- {int} zoomLevel
- an integer value denoting a zoom level supported by the active tile layer
- {Function} onCenter Optional
- function that will be invoked when the map has been centered on the specified coordinate
centerAtCoordinate(coordinate, onCenter)
Centers the map on the specified coordinate
- Parameters:
- {GSPoint} coordinate
- the real world coordinate (NZMG) to center the map on
- {Function} onCenter Optional
- function that will be invoked when the map has been recentered
centerOnLayer(layer, onCenter)
Re-centers the map on the named layer. Specifically the minimum bounding box required
to display all features in the layer is calculated and the map is resized to match
the extents of this bounding box.
- Parameters:
- {mixed} layer
- the name of the layer to center the map on, or a reference to the layer itself
- {Function} onCenter Optional
- function that will be invoked when the map has been re-centered
- Throws:
- {Error}
- if the named layer does not exist
centerOnNewZealand(onCenter)
Centers the map on the center of New Zealand, Nelson, and at such a scale that the full
extent of the country is visible
- Parameters:
- {Function} onCenter Optional
- function that will be invoked when the map has been centered
clearLayers()
Removes all features from all layers that have been added
to this map. Note it does not remove the layer objects themselves
clearSelection()
Removes all items from the current selection
closeInfoWindow(coordinate, html)
Close the info window if it is open
- Parameters:
- {GSPoint} coordinate
- the point which the info window refers to
- {String} html
- the HTML content of the info window
{boolean}
contains(coordinate)
Tests if the specified coordinate is within the current map extents
- Parameters:
- {GSPoint} coordinate
- the coordinate to test
- Returns:
- {boolean}
trueif the coordinate is within the current map extents
{GSLayer}
createLayer(name, options)
Creates a new layer with the specified name. If a layer with the specified already exists it will be removed (along with all layer children) and replaced with a new layer.
- Parameters:
- {String} name
- the layer name
- {Object} options Optional
- an object literal specifying optional parameters for layer initialization.
- {int} options.zIndex
- the zIndex within the map content hierarchy the layer should be displayed at
- Deprecated:
- instantiate layer classes directly and use GSMap#addLayer instead
- Returns:
- {GSLayer} the layer that was created
disableContextMenu()
Disables this component's context menu
{GSContextMenu}
enableContextMenu()
Enables this component's context menu if it has been set
- Returns:
- {GSContextMenu} the context menu belonging to this component
{GSTileLayer}
getBaseLayer()
Returns the active map base layer
- Returns:
- {GSTileLayer} the active map tile layer
{GSBounds}
getBounds()
Returns the bounds of the map viewport as NZMG coordinates
- Returns:
- {GSBounds} a
GSBoundsobject representing the bounds of the map viewport in NZMG
- See:
- GSMap#setBounds
{HTMLElement}
getContainer()
Returns a reference to the map's container element
- Returns:
- {HTMLElement} the map's container element
{GSContextMenu}
getContextMenu()
Returns the context menu for this component
- Returns:
- {GSContextMenu} the compoonents's context menu
{GSControl}
getControl(name)
Returns the named map control, or
null if no control
has been added to the map with the given name
- Parameters:
- {String} name
- the name of the map control to return
- Returns:
- {GSControl} the map control
{GSInfoWindow}
getInfoWindow()
Returns this map's info window instance
- Returns:
- {GSInfoWindow} the map's info window or
undefinedif the info window is not enabled for this map instance
{GSLayer}
getLayer(name)
Returns the named map layer
- Parameters:
- {String} name
- of the layer to return
- Returns:
- {GSLayer} the named layer
{Array}
getLayers()
Returns the feature layers for this map instance
- Returns:
- {Array} an array of
GSLayerobjects
{GSPoint}
getMapCenter()
Returns the center point of the map as an NZMG coordinate
- Returns:
- {GSPoint} the map center point as an NZMG coordinate
{Array}
getSelection()
Gets the current selection
- Returns:
- {Array} the selected items
{GSDimension}
getSize()
Returns the size, in pixels, of this map
- Returns:
- {GSDimension} the size of the map
{int}
getZoomLevel()
Returns the current map zoom level
- Returns:
- {int} the current map zoom level
hideControls()
Hides all map controls
isSelected(item)
Tests if the item passed in is currently selected
- Parameters:
- {Object} item
- the item to test
markForSnapback(persistent)
Marks the current map position and zoom level for snapping back to later by GSMap#snapback
- Parameters:
- {boolean} persistent
- whether the snapback position should be remembered across user. Cookie support is required for persisting the map's snapback state. This feature is unavailable in Safari when the enclosing document is served with an XHTML mime-type as the document.cookie property is unsupported for XHTML documents. sessions
- Throws:
- {Error}
- if the snapback state is to be persisted and the host browser does not have cookies enabled
openInfoWindow(coordinate, html, options)
Displays the info window at the given coordinate. If the window is already open at some other
location it will be closed and thereafter reopened at the new location. The info window content may
be provided either as an HTML string, or a DOM node.
- Parameters:
- {GSPoint} coordinate
- the point which the info window refers to
- {Mixed} html
- the HTML content of the info window
- {Object} options Optional
- an object literal specifying content and display options for the info window. The following parameters may be specified:
- {GSPoint} options.offset
- pixel offset from the specified coordinate to position the info window at.
- {Function} options.onopen
- a function to be called when the info window is opened
- {Function} options.onclose
- a function to be called when the info window is closed
- {String} options.title
- the text to display in the info window title
- {boolean} options.showCloseButton
- if
truea close button will be displayed on the info window, defaults totrue
openMapBlowup(coordinate, options)
Opens the info window with a blowup of the map specified by the coordinate
and mpx parameters
- Parameters:
- {GSPoint} coordinate
- the coordinate at which to position the info window
- {Object} options Optional
- an object literal specifying content and display options for the info window. The following parameters may be specified:
- {int} options.zoomLevel
- an integer value from 0 (maximum zoom in) to 11 (maximum zoom out).
- {GSPoint} options.size
- the size of the blowup map.
- {GSPoint} options.offset
- pixel offset from the specified coordinate to position the info window at
- {Function} options.onopen
- a function to be called when the info window is opened
- {Function} options.onclose
- a function to be called when the info window is closed
panTo(coordinate, onCenter, options)
Pans the map to the specified coordinate. If the coordinate is within the visible part of
the map panning is animated, otherwise the map is directly centered on the coordinate.
- Parameters:
- {GSPoint} coordinate
- the real world coordinate (NZMG) to pan the map to
- {Function} onCenter Optional
- function that will be invoked when the map has been panned to the specified coordinate
- {Object} options Optional
- configuration options
- {int} options.framerate
- the rate at which the animation should be drawn (milliseconds)
- {int} options.duration
- the length of the animation (milliseconds)
{Object}
print(printServiceUrl, options)
Creates a raster image representation of the current map view using a server-side print
service and returns the URL for the image
var response = map.print([proxy-url]); var uri = response.uri;
- Parameters:
- {String} printServiceUrl
- the URL for the print service. Typically this will be a proxy that will forward the request to the actual print service
- {Object} options Optional
- optional parameters for printing
- {boolean} options.scale
- if
truethe map will be scaled if necessary to show the full content of the map bounding box in the output image. Iffalsethe current map zoom level will be maintained but the map bounds will be cropped if necessary. Defaults totrue - {int} options.width
- the width in pixels of the output image. Defaults to the width of the map container
- {int} options.height
- the height in pixels of the output image. Defaults to the height of the map container
- {boolean} options.useScalebar
- if
truethe map scalebar will be shown on the output image>. Defaults to the value of the map'suseScalebarconfiguration option - {GSBounds} options.boundingBox
- a specific bounding box to print. Defaults to the map's current bounding box
- {String} options.method
- the HTTP method used to call the print service, defaults to
post - {String} options.imageFormat
- the format of the output image. May be either
image/jpegorimage/png, defaults toimage/jpeg - {Function} options.onSuccess
- a callback function to be invoked when the call to the print service successfully returns
- {Function} options.onFailure
- a callback function to be invoked when the call to the print service fails
- Throws:
- {Error}
- if the
XMLHttpRequestobject is unavailable
- Returns:
- {Object} a response object containing the URI of the image created e.g.
remove()
Destroys any resources created by this map instance
{GSContextMenu}
removeContextMenu()
Removes this component's context menu
- Returns:
- {GSContextMenu} the context menu that was removed, or
nullif no context menu was set
{boolean}
removeContextMenuItem(menuItem)
Removes the passed in context menu item from the list of menu items dynamically
added by this component to its context menu
- Parameters:
- {GSMenuItem} menuItem
- the menu item to remove
- Returns:
- {boolean}
trueif the menu item was removed from the component's list of menu items,falseif the menu item was not contained in the list
{GSControl}
removeControl(control)
Removes a control from the map
- Parameters:
- {GSControl} control
- the control object
- Returns:
- {GSControl} the control that was removed
removeFeature(feature, destroy)
A convenience function for removing a feature that was added
directly to the map
- Parameters:
- {GSMapFeature} feature
- the feature to remove
- {Boolean} destroy
- if
truefeature event listeners will be removed in addition to removing the feature from the DOM. Defaults totrue
- See:
- GSMap#addFeature
{boolean}
removeFromSelection(item)
Removes the passed in item from the current selection
- Parameters:
- {Object} item
- the item to remove
- Returns:
- {boolean}
trueif the item was successfully removed from the selection
{boolean}
removeLayer(name)
Removes a feature layer from the map
- Parameters:
- {String} name
- the layer name
- Returns:
- {boolean}
trueif the layer was removed
{boolean}
removeListener(obj)
Removes the specified object as a listener from this object
- Parameters:
- {Object} obj
- the object that should be removed as a listener
- Returns:
- {boolean}
trueif the specified listener object was removed successfully
resize(topDelta, rightDelta, bottomDelta, leftDelta)
Notify the map of a change in the dimensions of the map container. The map will
resize based on the delta values supplied without re-centering.
- Parameters:
- {int} topDelta
- The change in the top coordinate measured in pixels
- {int} rightDelta
- The change in the right coordinate measured in pixels
- {int} bottomDelta
- The change in the bottom coordinate measured in pixels
- {int} leftDelta
- The change in the left coordinate measured in pixels
setBaseLayer(name, redraw)
Sets the map's active tile layer
- Parameters:
- {String} name
- the name of the tile layer to set
- {Boolean} redraw
- if
trueredraw the map
- Throws:
- {Error}
- if a tile layer is requested to be set which is not registered with the map
setBounds(bounds, onBoundsChanged)
Sets the map extents to those specified by the bounds object
- Parameters:
- {GSBounds} bounds
- the new map bounds
- {Function} onBoundsChanged Optional
- function that will be invoked when the map bounds have been set
- See:
- GSMap#getBounds
setContextMenu(contextMenu)
Sets the context menu for this component
- Parameters:
- {GSContextMenu} contextMenu
- the context menu to display in response to right-click events on this component
setMapOptions(options)
Updates the map's configuration properties.
- Parameters:
- {Object} options Optional
- an object literal specifying the map options to set. Supported options are:
- {boolean} options.centerOnDblClick
- when
trueenables map recentering when double-clicking on the map. - {boolean} options.dragToPan
- when
trueenables map panning by moving the mouse while holding down the left mouse button. - {boolean} options.useMouseWheelZooming
- if
truemouse wheel zooming is enabled for the map. - {String} options.mouseWheelModifierKey
- specifies a modifier to use to actuate mouse wheel zooming.
Any of the following modifiers may be specified:
alt, ctrl, meta, shift - {boolean} options.useInfoWindow
- if
truethe info window is enabled for the map. - {boolean} options.useScalebar
- if
truea scalebar will be displayed on the map. - {boolean} options.resizeable
- if
truethe map will be sized to fit its container element.
- Throws:
- {Error}
- if a non-supported option is provided
setSelection(items)
Sets the selection
- Parameters:
- {Array} items
- an array of items to set
showControls()
Shows all map controls
{boolean}
snapback()
Restores the map view saved by GSMap#markForSnapback
- Returns:
- {boolean}
trueif the map was successfully snapped-back
startContinuousPan(delta)
Starts the map continuously panning in the direction specified by the
delta
parameter
- Parameters:
- {GSPoint} delta
- an instance of
GSPointindicating the direction the map should be panned in. The map center is continusouly updated using the deltaxandyvalues until GSMap#stopContinuousPan is called
stopContinuousPan()
Stops a previously started continuous pan operation
{String}
toJson()
Outputs a JSON representation of this map
- Returns:
- {String} a JSON string
{GSPoint}
translateToMapCoordinate(coordinate)
Translates an NZMG
X/y coordinate
to it's corresponding pixel values in the screen map's coordinate space.
- Parameters:
- {GSPoint} coordinate
- an NZMG
X/Ycoordinate
- Returns:
- {GSPoint} the NZMG coordinate translated to a pixel coordinate
{GSPoint}
translateToRealWorldCoordinate(coordinate, bounds)
Translates a coordinate in the screen map's coordinate space into a real
world coordinate (NZMG)
- Parameters:
- {GSPoint} coordinate
- a pixel coordinate in the map's coordinate space
- {GSBounds} bounds Optional
- an optional bounding box that may be used if an alternative coordinate space is required
- Returns:
- {GSPoint} the map coordinate translated to an NZMG coordinate
updateSize()
Recalculates the dimensions of the map from its container. This method is called automatically
in reponse to window resize events when the
resizeable map option is set to
true. If the container DOM element is resized independently of a window resize event
this method should be called explicitly to allow the map to resize to the dimensions.
If the container DOM element is hidden (via a display:none style) and then made visible later, then
updateSize should be called after the container DOM element is visible again. This allows the map
dimensions to be calculated correctly and will fix map display problems.
zoom(zoomLevel, onZoom)
Zooms to the specified zoom level
- Parameters:
- {int} zoomLevel
- an integer value from 16 (maximum zoom in) to 4 (maximum zoom out)
- {Function} onZoom Optional
- function that will be invoked when the map has been zoomed to the new zoom level
Event Detail
infoWindowClosed(infoWindow)
- Parameters:
- {GSInfoWindow} infoWindow
- the info window that was closed
infoWindowMaximized(infoWindow)
- Parameters:
- {GSInfoWindow} infoWindow
- the info window that was maximized
infoWindowOpened(infoWindow)
- Parameters:
- {GSInfoWindow} infoWindow
- the info window that was opened
infoWindowOpening(infoWindow)
- Parameters:
- {GSInfoWindow} infoWindow
- the info window is opening
infoWindowRestored(infoWindow)
- Parameters:
- {GSInfoWindow} infoWindow
- the info window that was restored
mapBaseLayerChanged(map, layer)
- Parameters:
- {GSMap} map
- the map instance whose base layer was changed
- {GSTileLayer} layer
- the map's new base tile layer
mapBoundsChanged(map, oldBounds, newBounds)
- Parameters:
- {GSMap} map
- the map whose bounds have changed
- {GSBounds} oldBounds
- the map bounds before the new bounds were set
- {GSBounds} newBounds
- the map bounds after the new bounds were set
mapClicked(map, coordinate, event)
- Parameters:
- {GSMap} map
- the map instance that was clicked
- {GSPoint} coordinate
- the coordinate (in NZMG) where the click occurred
- {Event} event
- the native mouse event
mapDblClicked(map, coordinate, event)
- Parameters:
- {GSMap} map
- the map instance that was double clicked
- {GSPoint} coordinate
- the coordinate (in NZMG) where the double click occurred
- {Event} event
- the native mouse event
mapPanStarted(map)
- Parameters:
- {GSMap} map
- the map that is being panned
mapPanStopped(map)
- Parameters:
- {GSMap} map
- the map that was panned
mapReady(map)
- Parameters:
- {GSMap} map
- the map that has completed initialization
mapResized(map, oldSize, newSize)
- Parameters:
- {GSMap} map
- the map that has been resized
- {GSDimension} oldSize
- the map size before it was resized
- {GSDimension} newSize
- the map size after it was resized
mapZoomed(map, oldZoomLevel, newZoomLevel)
- Parameters:
- {GSMap} map
- the map instance that was zoomed
- {int} oldZoomLevel
- the map zoom level before it was zoomed
- {int} newZoomLevel
- the map zoom level after it was zoomed
selectionChanged(selection)
- Parameters:
- {Array} selection
- the new value of the selection