Class mxn.Mapstraction
Defined in: mxn.core.js.
Constructor Attributes | Constructor Name and Description |
---|---|
mxn.Mapstraction(element, api, debug)
Mapstraction instantiates a map with some API choice into the HTML element given
|
Field Attributes | Field Name and Description |
---|---|
The name of the active API.
|
|
The DOM element containing the map.
|
|
The original element value passed to the constructor.
|
|
The markers currently loaded.
|
|
Options defaults.
|
|
The polylines currently loaded.
|
Method Attributes | Method Name and Description |
---|---|
addControls(args)
addControls adds controls to the map.
|
|
addEventListener(type, func, caller)
Add a listener for an event.
|
|
addFilter(name, presently, the)
addFilter adds a marker filter
|
|
addImageOverlay(unique, url, opacity, west, south, east, north)
addImageOverlay layers an georeferenced image over the map
|
|
addJSON(json)
|
|
Adds a large map panning control and zoom buttons to the map
|
|
Adds a map type control to the map (streets, aerial imagery etc)
|
|
addMarker(marker, old)
Adds a marker pin to the map
|
|
addMarkerWithData(marker, data)
addMarkerWithData will addData to the marker, then add it to the map
|
|
addOverlay(url, autoCenterAndZoom)
Adds a GeoRSS or KML overlay to the map
some flavors of GeoRSS and KML are not supported by some of the Map providers
|
|
addPolyline(polyline, old)
Add a polyline to the map
|
|
addPolylineWithData(polyline, data)
addPolylineWithData will addData to the polyline, then add it to the map
|
|
Adds a small map panning control and zoom buttons to the map
|
|
addTileLayer(template, opacity, copyright, Minimum, Maximum, Should)
Adds a Tile Layer to the map
Requires providing a parameterized tile url.
|
|
applyFilter(o, f)
|
|
Applies the current option settings
|
|
autoCenterAndZoom sets the center and zoom of the map to the smallest bounding box
containing all markers
|
|
callEventListeners(sEventType, oEventArgs)
Call listeners for a particular event.
|
|
centerAndZoomOnPoints(points)
centerAndZoomOnPoints sets the center and zoom of the map from an array of points
This is useful if you don't want to have to add markers to the map
|
|
clickHandler(lat, lon, me)
|
|
Closes the map-based info bubble, if open
|
|
declutterMarkers(opts)
Declutter the markers on the map, group together overlapping markers.
|
|
doFilter(showCallback, hideCallback)
doFilter executes all filters added since last call
Now supports a callback function for when a marker is shown or hidden
|
|
dragging(on)
Enable/disable dragging of the map
|
|
Enable scroll wheel zooming
|
|
getAttributeExtremes(name)
getAttributeExtremes returns the minimum/maximum of "field" from all markers
|
|
Gets the BoundingBox of the map
|
|
Gets the central point of the map
|
|
getMap()
getMap returns the native map object that mapstraction is talking to
|
|
Gets the imagery type for the map.
|
|
Returns a ratio to turn distance into pixels based on current projection
|
|
getZoom()
Returns the zoom level of the map
|
|
Returns the best zoom level for bounds given
|
|
isLoaded(api)
Returns the loaded state of a Map Provider
|
|
mousePosition(element)
Displays the coordinates of the cursor in the HTML element
|
|
moveendHandler(me)
|
|
openBubble(LatLonPoint, Content)
Opens an info bubble at a given point, with given content
|
|
polylineCenterAndZoom(radius)
Automatically sets center and zoom level to show all polylines
Takes into account radious of polyline
|
|
removeAllFilters
|
|
removeAllMarkers removes all the Markers on a map
|
|
Removes all polylines from the map
|
|
removeFilter(field, operator, value)
Remove the specified filter
|
|
removeMarker(marker)
removeMarker removes a Marker from the map
|
|
removePolyline(polyline)
Remove the polyline from the map
|
|
resizeTo(width, height)
Resize the current map to the specified width and height
(since it is actually on a child div of the mapElement passed
as argument to the Mapstraction constructor, the resizing of this
mapElement may have no effect on the size of the actual map)
|
|
Run any queued provider API calls for the methods defined in the provider's implementation.
|
|
setBounds(bounds)
Sets the map to the appropriate location and zoom for a given BoundingBox
|
|
setCenter(point, options)
setCenter sets the central point of the map
|
|
setCenterAndZoom(point, zoom)
Centers the map to some place and zoom level
|
|
setDebug(debug)
Set the debugging on or off - shows alert panels for functions that don't exist in Mapstraction
|
|
setDefer(set)
Set the api call deferment on or off - When it's on, mxn.invoke will queue up provider API calls until
runDeferred is called, at which time everything in the queue will be run in the order it was added.
|
|
setImageOpacity(id, opacity)
|
|
setImagePosition(id)
|
|
setMapType(type)
Sets the imagery type for the map
The type can be one of:
mxn.Mapstraction.ROAD
mxn.Mapstraction.SATELLITE
mxn.Mapstraction.HYBRID
mxn.Mapstraction.PHYSICAL
|
|
setOption(sOptName, vVal)
Sets an option and applies it.
|
|
setOptions(oOpts)
Sets the current options to those specified in oOpts and applies them
|
|
setZoom(zoom)
Sets the zoom level for the map
MS doesn't seem to do zoom=0, and Gg's sat goes closer than it's maps, and MS's sat goes closer than Y!'s
TODO: Mapstraction.prototype.getZoomLevels or something.
|
|
swap(api, element)
Change the current api on the fly
|
|
toggleFilter(field, operator, value)
Delete the current filter if present; otherwise add it
|
|
toggleTileLayer(url)
Turns a Tile Layer on or off
|
|
Sets the center and zoom of the map to the smallest bounding box
containing all visible markers and polylines
will only include markers and polylines with an attribute of "visible"
|
Event Attributes | Event Name and Description |
---|---|
Zoom is changed
|
|
click()
Map is clicked {location: LatLonPoint}
|
|
endPan()
Map is panned
|
|
load()
Map has loaded
|
|
Marker is removed {marker: Marker}
|
|
Marker is removed {marker: Marker}
|
|
Polyline is added {polyline: Polyline}
|
|
Polyline is removed {polyline: Polyline}
|
Class Detail
mxn.Mapstraction(element, api, debug)
Mapstraction instantiates a map with some API choice into the HTML element given
- Parameters:
- {String} element
- The HTML element to replace with a map
- {String} api
- The API to use, one of 'google', 'googlev3', 'yahoo', 'microsoft', 'openstreetmap', 'multimap', 'map24', 'openlayers', 'mapquest'. If omitted, first loaded provider implementation is used.
- {Bool} debug
- optional parameter to turn on debug support - this uses alert panels for unsupported actions
Field Detail
api
The name of the active API.
currentElement
The DOM element containing the map.
element
The original element value passed to the constructor.
markers
The markers currently loaded.
options
Options defaults.
polylines
The polylines currently loaded.
Method Detail
addControls(args)
addControls adds controls to the map. You specify which controls to add in
the associative array that is the only argument.
addControls can be called multiple time, with different args, to dynamically change controls.
args = {
pan: true,
zoom: 'large' || 'small',
overview: true,
scale: true,
map_type: true,
}
- Parameters:
- {array} args
- Which controls to switch on
addEventListener(type, func, caller)
Add a listener for an event.
- Parameters:
- {String} type
- Event type to attach listener to
- {Function} func
- Callback function
- {Object} caller
- Callback object
addFilter(name, presently, the)
addFilter adds a marker filter
- Parameters:
- {field} name
- of attribute to filter on
- {operator} presently
- only "ge" or "le"
- {value} the
- value to compare against
addImageOverlay(unique, url, opacity, west, south, east, north)
addImageOverlay layers an georeferenced image over the map
- Parameters:
- {id} unique
- DOM identifier
- {src} url
- of image
- {opacity} opacity
- 0-100
- {west} west
- boundary
- {south} south
- boundary
- {east} east
- boundary
- {north} north
- boundary
addJSON(json)
- Parameters:
- json
addLargeControls()
Adds a large map panning control and zoom buttons to the map
addMapTypeControls()
Adds a map type control to the map (streets, aerial imagery etc)
addMarker(marker, old)
Adds a marker pin to the map
- Parameters:
- {Marker} marker
- The marker to add
- {Boolean} old
- If true, doesn't add this marker to the markers array. Used by the "swap" method
addMarkerWithData(marker, data)
addMarkerWithData will addData to the marker, then add it to the map
- Parameters:
- {Marker} marker
- The marker to add
- {Object} data
- A data has to add
addOverlay(url, autoCenterAndZoom)
Adds a GeoRSS or KML overlay to the map
some flavors of GeoRSS and KML are not supported by some of the Map providers
- Parameters:
- {String} url
- GeoRSS or KML feed URL
- {Boolean} autoCenterAndZoom
- Set true to auto center and zoom after the feed is loaded
addPolyline(polyline, old)
Add a polyline to the map
- Parameters:
- {Polyline} polyline
- The Polyline to add to the map
- {Boolean} old
- If true replaces an existing Polyline
addPolylineWithData(polyline, data)
addPolylineWithData will addData to the polyline, then add it to the map
- Parameters:
- {Polyline} polyline
- The polyline to add
- {Object} data
- A data has to add
addSmallControls()
Adds a small map panning control and zoom buttons to the map
addTileLayer(template, opacity, copyright, Minimum, Maximum, Should)
Adds a Tile Layer to the map
Requires providing a parameterized tile url. Use {Z}, {X}, and {Y} to specify where the parameters
should go in the URL.
For example, the OpenStreetMap tiles are:
m.addTileLayer("http://tile.openstreetmap.org/{Z}/{X}/{Y}.png", 1.0, "OSM", 1, 19, true);
- Parameters:
- {tile_url} template
- url of the tiles.
- {opacity} opacity
- of the tile layer - 0 is transparent, 1 is opaque. (default=0.6)
- {copyright_text} copyright
- text to use for the tile layer. (default=Mapstraction)
- {min_zoom} Minimum
- (furtherest out) zoom level that tiles are available (default=1)
- {max_zoom} Maximum
- (closest) zoom level that the tiles are available (default=18)
- {map_type} Should
- the tile layer be a selectable map type in the layers palette (default=false)
applyFilter(o, f)
- Parameters:
- o
- f
applyOptions()
Applies the current option settings
autoCenterAndZoom()
autoCenterAndZoom sets the center and zoom of the map to the smallest bounding box
containing all markers
callEventListeners(sEventType, oEventArgs)
Call listeners for a particular event.
- Parameters:
- {String} sEventType
- Call listeners of this event type
- {Object} oEventArgs
- Event args object to pass back to the callback
centerAndZoomOnPoints(points)
centerAndZoomOnPoints sets the center and zoom of the map from an array of points
This is useful if you don't want to have to add markers to the map
- Parameters:
- points
clickHandler(lat, lon, me)
- Parameters:
- lat
- lon
- me
closeBubble()
Closes the map-based info bubble, if open
declutterMarkers(opts)
Declutter the markers on the map, group together overlapping markers.
- Parameters:
- {Object} opts
- Declutter options
{Int}
doFilter(showCallback, hideCallback)
doFilter executes all filters added since last call
Now supports a callback function for when a marker is shown or hidden
- Parameters:
- {Function} showCallback
- {Function} hideCallback
- Returns:
- {Int} count of visible markers
dragging(on)
Enable/disable dragging of the map
- Parameters:
- {Boolean} on
- Deprecated:
- Use setOption instead.
enableScrollWheelZoom()
Enable scroll wheel zooming
- Deprecated:
- Use setOption instead.
{array}
getAttributeExtremes(name)
getAttributeExtremes returns the minimum/maximum of "field" from all markers
- Parameters:
- {field} name
- of "field" to query
- Returns:
- {array} of minimum/maximum
{BoundingBox}
getBounds()
Gets the BoundingBox of the map
- Returns:
- {BoundingBox} The bounding box for the current map state
{LatLonPoint}
getCenter()
Gets the central point of the map
- Returns:
- {LatLonPoint} The center point of the map
getMap()
getMap returns the native map object that mapstraction is talking to
- Returns:
- the native map object mapstraction is using
{Number}
getMapType()
Gets the imagery type for the map.
The type can be one of:
mxn.Mapstraction.ROAD
mxn.Mapstraction.SATELLITE
mxn.Mapstraction.HYBRID
mxn.Mapstraction.PHYSICAL
- Returns:
- {Number}
{Float}
getPixelRatio()
Returns a ratio to turn distance into pixels based on current projection
- Returns:
- {Float} ratio
{Integer}
getZoom()
Returns the zoom level of the map
- Returns:
- {Integer} The zoom level of the map
{Integer}
getZoomLevelForBoundingBox(bbox)
Returns the best zoom level for bounds given
- Parameters:
- {BoundingBox} bbox
- The bounds to fit
- Returns:
- {Integer} The closest zoom level that contains the bounding box
isLoaded(api)
Returns the loaded state of a Map Provider
- Parameters:
- {String} api
- Optional API to query for. If not specified, returns state of the originally created API
mousePosition(element)
Displays the coordinates of the cursor in the HTML element
- Parameters:
- {String} element
- ID of the HTML element to display the coordinates in
moveendHandler(me)
- Parameters:
- me
openBubble(LatLonPoint, Content)
Opens an info bubble at a given point, with given content
- Parameters:
- {point} LatLonPoint
- where the window should open
- {content} Content
- string for the window
polylineCenterAndZoom(radius)
Automatically sets center and zoom level to show all polylines
Takes into account radious of polyline
- Parameters:
- {Int} radius
removeAllFilters()
removeAllFilters
removeAllMarkers()
removeAllMarkers removes all the Markers on a map
removeAllPolylines()
Removes all polylines from the map
removeFilter(field, operator, value)
Remove the specified filter
- Parameters:
- {Object} field
- {Object} operator
- {Object} value
removeMarker(marker)
removeMarker removes a Marker from the map
- Parameters:
- {Marker} marker
- The marker to remove
removePolyline(polyline)
Remove the polyline from the map
- Parameters:
- {Polyline} polyline
- The Polyline to remove from the map
resizeTo(width, height)
Resize the current map to the specified width and height
(since it is actually on a child div of the mapElement passed
as argument to the Mapstraction constructor, the resizing of this
mapElement may have no effect on the size of the actual map)
- Parameters:
- {Integer} width
- The width the map should be.
- {Integer} height
- The width the map should be.
runDeferred()
Run any queued provider API calls for the methods defined in the provider's implementation.
For example, if defferable in mxn.[provider].core.js is set to {getCenter: true, setCenter: true}
then any calls to map.setCenter or map.getCenter will be queued up in this.onload. When the provider's
implementation loads the map, it calls this.runDeferred and any queued calls will be run.
setBounds(bounds)
Sets the map to the appropriate location and zoom for a given BoundingBox
- Parameters:
- {BoundingBox} bounds
- The bounding box you want the map to show
setCenter(point, options)
setCenter sets the central point of the map
- Parameters:
- {LatLonPoint} point
- The point at which to center the map
- {Object} options
- Optional parameters
- {Boolean} options.pan
- Whether the map should move to the locations using a pan or just jump straight there
setCenterAndZoom(point, zoom)
Centers the map to some place and zoom level
- Parameters:
- {LatLonPoint} point
- Where the center of the map should be
- {Integer} zoom
- The zoom level where 0 is all the way out.
setDebug(debug)
Set the debugging on or off - shows alert panels for functions that don't exist in Mapstraction
- Parameters:
- {Boolean} debug
- true to turn on debugging, false to turn it off
setDefer(set)
Set the api call deferment on or off - When it's on, mxn.invoke will queue up provider API calls until
runDeferred is called, at which time everything in the queue will be run in the order it was added.
- Parameters:
- {Boolean} set
- deferred to true to turn on deferment
setImageOpacity(id, opacity)
- Parameters:
- id
- opacity
setImagePosition(id)
- Parameters:
- id
setMapType(type)
Sets the imagery type for the map
The type can be one of:
mxn.Mapstraction.ROAD
mxn.Mapstraction.SATELLITE
mxn.Mapstraction.HYBRID
mxn.Mapstraction.PHYSICAL
- Parameters:
- {Number} type
setOption(sOptName, vVal)
Sets an option and applies it.
- Parameters:
- {String} sOptName
- Option name
- vVal
- Option value
setOptions(oOpts)
Sets the current options to those specified in oOpts and applies them
- Parameters:
- {Object} oOpts
- Hash of options to set
setZoom(zoom)
Sets the zoom level for the map
MS doesn't seem to do zoom=0, and Gg's sat goes closer than it's maps, and MS's sat goes closer than Y!'s
TODO: Mapstraction.prototype.getZoomLevels or something.
- Parameters:
- {Number} zoom
- The (native to the map) level zoom the map to.
swap(api, element)
Change the current api on the fly
- Parameters:
- {String} api
- The API to swap to
- element
toggleFilter(field, operator, value)
Delete the current filter if present; otherwise add it
- Parameters:
- {Object} field
- {Object} operator
- {Object} value
toggleTileLayer(url)
Turns a Tile Layer on or off
- Parameters:
- {tile_url} url
- of the tile layer that was created.
visibleCenterAndZoom()
Sets the center and zoom of the map to the smallest bounding box
containing all visible markers and polylines
will only include markers and polylines with an attribute of "visible"
Event Detail
changeZoom()
Zoom is changed
click()
Map is clicked {location: LatLonPoint}
endPan()
Map is panned
load()
Map has loaded
markerAdded()
Marker is removed {marker: Marker}
markerRemoved()
Marker is removed {marker: Marker}
polylineAdded()
Polyline is added {polyline: Polyline}
polylineRemoved()
Polyline is removed {polyline: Polyline}