Instances of ALKMaps.Map are interactive maps embedded in a web page. Create a new map with the ALKMaps.Map constructor.
On their own maps do not provide much functionality. To extend a map it’s necessary to add controls (ALKMaps.Control) and layers (ALKMaps.Layer) to the map.
//Create main map object var map = new ALKMaps.Map('map'); //Create the map layer object var layer = new ALKMaps.Layer.BaseMap( "ALK Maps", {}, {displayInLayerSwitcher: false}); //Add the layer to the map object map.addLayer(layer); //Change the initial viewpoint of the map map.setCenter(new ALKMaps.LonLat(-96, 35), 2);
ALKMaps.Map | Instances of ALKMaps.Map are interactive maps embedded in a web page. |
Constants | |
Z_INDEX_BASE | {Object} Base z-indexes for different classes of thing |
Properties | |
events | {ALKMaps.Events} |
id | {String} Unique identifier for the map |
fractionalZoom | {Boolean} For a base layer that supports it, allow the map resolution to be set to a value between one of the values in the resolutions array. |
events | {ALKMaps.Events} An events object that handles all events on the map |
allOverlays | {Boolean} Allow the map to function with “overlays” only. |
div | {DOMElement|String} The element that contains the map (or an id for that element). |
dragging | {Boolean} The map is currently being dragged. |
size | {ALKMaps.Size} Size of the main div (this.div) |
viewPortDiv | {HTMLDivElement} The element that represents the map viewport |
layerContainerOrigin | {ALKMaps.LonLat} The lonlat at which the later container was re-initialized (on-zoom) |
layerContainerDiv | {HTMLDivElement} The element that contains the layers. |
layers | {Array(ALKMaps.Layer)} Ordered list of layers in the map |
controls | {Array(ALKMaps.Control)} List of controls associated with the map. |
popups | {Array(ALKMaps.Popup)} List of popups associated with the map |
baseLayer | {ALKMaps.Layer} The currently selected base layer. |
center | {ALKMaps.LonLat} The current center of the map |
resolution | {Float} The resolution of the map. |
zoom | {Integer} The current zoom level of the map |
panRatio | {Float} The ratio of the current extent within which panning will tween. |
options | {Object} The options object passed to the class constructor. |
tileSize | {ALKMaps.Size} Set in the map options to override the default tile size for this map. |
projection | {String} Set in the map options to specify the default projection for layers added to this map. |
units | {String} The map units. |
resolutions | {Array(Float)} A list of map resolutions (map units per pixel) in descending order. |
maxResolution | {Float} Required if you are not displaying the whole world on a tile with the size specified in tileSize. |
minResolution | {Float} |
maxScale | {Float} |
minScale | {Float} |
maxExtent | {<ALKMaps.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). |
minExtent | {<ALKMaps.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). |
restrictedExtent | {<ALKMaps.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). |
numZoomLevels | {Integer} Number of zoom levels for the map. |
theme | {String} Relative path to a CSS file from which to load theme styles. |
displayProjection | {ALKMaps.Projection} Requires proj4js support for projections other than EPSG:4326 or EPSG:900913/EPSG:3857. |
fallThrough | {Boolean} Should ALKMaps allow events on the map to fall through to other elements on the page, or should it swallow them? |
panTween | {<ALKMaps.Tween>} Animated panning tween object, see panTo() |
eventListeners | {Object} If set as an option at construction, the eventListeners object will be registered with ALKMaps.Events.on. |
panMethod | {Function} The Easing function to be used for tweening. |
panDuration | {Integer} The number of steps to be passed to the ALKMaps.Tween.start() method when the map is panned. |
paddingForPopups | {ALKMaps.Bounds} Outside margin of the popup. |
minPx | {Object} An object with a ‘x’ and ‘y’ values that is the lower left of maxExtent in viewport pixel space. |
maxPx | {Object} An object with a ‘x’ and ‘y’ values that is the top right of maxExtent in viewport pixel space. |
autoAdjustZoomControl | {Boolean} Used for enabling the automatic adjustment of PanZoom controls based on map height. |
allowSafeScroll | {Boolean} Used for initially setting the SafeScroll feature. |
panLock | {Boolean} Indicates something is being dragged across the map and therefore panning should be locked. |
_isInitialized | {Boolean} Set to true after the base constructor is called. |
Constructor | |
ALKMaps.Map | Constructor for a new ALKMaps.Map instance. |
Functions | |
getViewport | Get the DOMElement representing the view port. |
render | Render the map to a specified container. |
unloadDestroy | Function that is called to destroy the map on page unload. |
updateSizeDestroy | When the map is destroyed, we need to stop listening to updateSize events: this method stores the function we need to unregister in non-IE browsers. |
destroy | Destroy this map. |
setOptions | Change the map options |
getTileSize | Get the tile size for the map |
getBy | Get a list of objects given a property and a match item. |
getLayersBy | Get a list of layers with properties matching the given criteria. |
getLayersByName | Get a list of layers with names matching the given name. |
getLayersByClass | Get a list of layers of a given class (CLASS_NAME). |
getControlsBy | Get a list of controls with properties matching the given criteria. |
getControlsByClass | Get a list of controls of a given class (CLASS_NAME). |
getLayer | Get a layer based on its id |
setLayerZIndex | |
resetLayersZIndex | Reset each layer’s z-index based on layer’s array index |
addLayer | |
addLayers | |
removeLayer | Removes a layer from the map by removing its visual element (the layer.div property), then removing it from the map’s internal list of layers, setting the layer’s map property to null. |
getNumLayers | {Int} The number of layers attached to the map. |
getLayerIndex | |
setLayerIndex | Move the given layer to the specified (zero-based) index in the layer list, changing its z-index in the map display. |
raiseLayer | Change the index of the given layer by delta. |
setBaseLayer | Allows user to specify one of the currently-loaded layers as the Map’s new base layer. |
addControl | Add the passed over control to the map. |
addControls | Add all of the passed over controls to the map. |
addControlToMap | |
getControl | |
removeControl | Remove a control from the map. |
addPopup | |
removePopup | |
getSize | {ALKMaps.Size} An ALKMaps.Size object that represents the size, in pixels, of the div into which ALKMaps has been loaded. |
updateSize | This function should be called by any external code which dynamically changes the size of the map div (because mozilla wont let us catch the “onresize” for an element) |
getCurrentSize | {ALKMaps.Size} A new ALKMaps.Size object with the dimensions of the map div |
calculateBounds | |
enableContextMenu | Enables the default right-click context menu; |
disableContextMenu | Disables the default right-click context menu; |
getCenter | {ALKMaps.LonLat} |
getCachedCenter | {ALKMaps.LonLat} |
getZoom | {Integer} |
pan | Allows user to pan by a value of screen pixels |
panTo | Allows user to pan to a new lonlat If the new lonlat is in the current extent the map will slide smoothly |
setCenter | Set the map center (and optionally, the zoom level). |
moveByPx | Drag the map by pixels. |
adjustZoom | |
moveTo | |
centerLayerContainer | This function takes care to recenter the layerContainerDiv. |
isValidZoomLevel | |
isValidLonLat | |
getProjection | This method returns a string representing the projection. |
getProjectionObject | Returns the projection obect from the baselayer. |
getMaxResolution | {String} The Map’s Maximum Resolution |
getMaxExtent | |
getNumZoomLevels | {Integer} The total number of zoom levels that can be displayed by the current baseLayer. |
getExtent | {ALKMaps.Bounds} A Bounds object which represents the lon/lat bounds of the current viewPort. |
getResolution | {Float} The current resolution of the map. |
getUnits | {Float} The current units of the map. |
getScale | {Float} The current scale denominator of the map. |
getZoomForExtent | |
getResolutionForZoom | |
getZoomForResolution | |
zoomTo | Zoom to a specific zoom level |
zoomIn | |
zoomOut | |
zoomToExtent | Zoom to the passed in bounds, recenter |
zoomToMaxExtent | Zoom to the full extent and recenter. |
zoomToScale | Zoom to a specified scale |
getLonLatFromViewPortPx | |
getViewPortPxFromLonLat | |
getLonLatFromPixel | |
getPixelFromLonLat | Returns a pixel location given a map location. |
getGeodesicPixelSize | |
getViewPortPxFromLayerPx | |
getLayerPxFromViewPortPx | |
getLonLatFromLayerPx | |
getLayerPxFromLonLat | |
showLoading | |
hideLoading | |
showMapLoadingIcon | |
adjustZoomControl | |
enableSafeScroll | Enables the SafeScroll feature for the map. |
disableSafeScroll | Disables the SafeScroll feature for the map. |
safeScroll | |
reverseGeocode | This function takes latitude and longitude, returns address object synchronously or asynchronously. |
geocode | This function takes address object, returns address arrays with longitudes and latitudes. |
simpleGeocode | This function takes address object, returns address arrays with longitudes and latitudes. |
geoSearch | This function is used to search country, state, and city places. |
getReports | Takes coords objects and report options, return total time and total distance synchronously. |
getRoutePath | Takes coords objects and route options, return lat/lons for the route path. |
getDerivedRoutePath | Take pings and route options, return derived route points. |
Constants | |
TILE_WIDTH | {Integer} 256 Default tile width (unless otherwise specified) |
TILE_HEIGHT | {Integer} 256 Default tile height (unless otherwise specified) |
map.events.register(type, obj, listener);
Listeners will be called with a reference to an event object. The properties of this event depends on exactly what happened.
object | {Object} A reference to map.events.object. |
element | {DOMElement} A reference to map.events.element. |
xy | {ALKMaps.Pixel} The pixel location of the event (relative to the the map viewport). |
preaddlayer | triggered before a layer has been added. The event object will include a layer property that references the layer to be added. When a listener returns “false” the adding will be aborted. |
addlayer | triggered after a layer has been added. The event object will include a layer property that references the added layer. |
preremovelayer | triggered before a layer has been removed. The event object will include a layer property that references the layer to be removed. When a listener returns “false” the removal will be aborted. |
removelayer | triggered after a layer has been removed. The event object will include a layer property that references the removed layer. |
changelayer | triggered after a layer name change, order change, opacity change, params change, visibility change (due to resolution thresholds) or attribution change (due to extent change). Listeners will receive an event object with layer and property properties. The layer property will be a reference to the changed layer. The property property will be a key to the changed property (name, order, opacity, params, visibility or attribution). |
movestart | triggered after the start of a drag, pan, or zoom |
move | triggered after each drag, pan, or zoom |
moveend | triggered after a drag, pan, or zoom completes |
zoomend | triggered after a zoom completes |
mouseover | triggered after mouseover the map |
mouseout | triggered after mouseout the map |
mousemove | triggered after mousemove the map |
changebaselayer | triggered after the base layer changes |
{Boolean} For a base layer that supports it, allow the map resolution to be set to a value between one of the values in the resolutions array. Default is false.
When fractionalZoom is set to true, it is possible to zoom to an arbitrary extent. This requires a base layer from a source that supports requests for arbitrary extents (i.e. not cached tiles on a regular lattice). This means that fractionalZoom will not work with commercial layers (Google, Yahoo, VE), layers using TileCache, or any other pre-cached data sources.
If you are using fractionalZoom, then you should also use getResolutionForZoom instead of layer.resolutions[zoom] as the former works for non-integer zoom levels.
{ALKMaps.Events} An events object that handles all events on the map
{Boolean} Allow the map to function with “overlays” only. Defaults to false. If true, the lowest layer in the draw order will act as the base layer. In addition, if set to true, all layers will have isBaseLayer set to false when they are added to the map.
If you set map.allOverlays to true, then you cannot use map.setBaseLayer or layer.setIsBaseLayer. With allOverlays true, the lowest layer in the draw layer is the base layer. So, to change the base layer, use setLayerIndex or raiseLayer to set the layer index to 0.
{DOMElement|String} The element that contains the map (or an id for that element). If the ALKMaps.Map constructor is called with two arguments, this should be provided as the first argument. Alternatively, the map constructor can be called with the options object as the only argument. In this case (one argument), a div property may or may not be provided. If the div property is not provided, the map can be rendered to a container later using the render method.
If you are calling render after map construction, do not use maxResolution auto. Instead, divide your maxExtent by your maximum expected dimension.
{ALKMaps.Size} Size of the main div (this.div)
{ALKMaps.LonLat} The lonlat at which the later container was re-initialized (on-zoom)
{Array(ALKMaps.Layer)} Ordered list of layers in the map
{Array(ALKMaps.Control)} List of controls associated with the map.
If not provided in the map options at construction, the map will by default be given the following controls if present in the build:
{Array(ALKMaps.Popup)} List of popups associated with the map
{ALKMaps.Layer} The currently selected base layer. This determines min/max zoom level, projection, etc.
{ALKMaps.LonLat} The current center of the map
{ALKMaps.Size} Set in the map options to override the default tile size for this map.
{String} Set in the map options to specify the default projection for layers added to this map. When using a projection other than EPSG:4326 (CRS:84, Geographic) or EPSG:3857 (EPSG:900913, Web Mercator), also set maxExtent, maxResolution or resolutions. Default is “EPSG:900913”. Note that the projection of the map is usually determined by that of the current baseLayer (see baseLayer and getProjectionObject).
{Float} Required if you are not displaying the whole world on a tile with the size specified in tileSize.
{<ALKMaps.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). The maximum extent for the map. Defaults to the whole world in meters (-20037508.34, -20037508.34, 20037508.34, 20037508.34). Specify a different extent in the map options if you are not using a geographic projection and displaying the whole world. To restrict user panning and zooming of the map, use restrictedExtent instead. The value for maxExtent will change calculations for tile URLs.
{<ALKMaps.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). Limit map navigation to this extent where possible. If a non-null restrictedExtent is set, panning will be restricted to the given bounds. In addition, zooming to a resolution that displays more than the restricted extent will center the map on the restricted extent. If you wish to limit the zoom level or resolution, use maxResolution.
{ALKMaps.Projection} Requires proj4js support for projections other than EPSG:4326 or EPSG:900913/EPSG:3857. Projection used by several controls to display data to user. If this property is set, it will be set on any control which has a null displayProjection property at the time the control is added to the map.
{Object} If set as an option at construction, the eventListeners object will be registered with ALKMaps.Events.on. Object structure must be a listeners object as shown in the example for the events.on method.
{ALKMaps.Bounds} Outside margin of the popup. Used to prevent the popup from getting too close to the map border.
Constructor for a new ALKMaps.Map instance. There are two possible ways to call the map constructor. See the examples below.
div | {DOMElement|String} The element or id of an element in your page that will contain the map. May be omitted if the div option is provided or if you intend to call the render method later. |
options | {Object} Optional object with properties to tag onto the map. |
center | {<ALKMaps.LonLat>|Array} The default initial center of the map. If provided as array, the first value is the x coordinate, and the 2nd value is the y coordinate. Only specify if layers is provided. Note that if an ArgParser/Permalink control is present, and the querystring contains coordinates, center will be set by that, and this option will be ignored. |
zoom | {Number} The initial zoom level for the map. Only specify if layers is provided. Note that if an ArgParser/Permalink control is present, and the querystring contains a zoom level, zoom will be set by that, and this option will be ignored. |
extent | {<ALKMaps.Bounds>|Array} The initial extent of the map. If provided as an array, the array should consist of four values (left, bottom, right, top). Only specify if center and zoom are not provided. |
// create a map with default options in an element with the id "map1" var map = new ALKMaps.Map("map1"); // create a map with non-default options in an element with id "map2" var options = { projection: "EPSG:3857", maxExtent: new ALKMaps.Bounds(-200000, -200000, 200000, 200000), center: new ALKMaps.LonLat(-12356463.476333, 5621521.4854095) }; var map = new ALKMaps.Map("map2", options); // map with non-default options - same as above but with a single argument, // a restricted extent, and using arrays for bounds and center var map = new ALKMaps.Map({ div: "map_id", projection: "EPSG:3857", maxExtent: [-18924313.432222, -15538711.094146, 18924313.432222, 15538711.094146], restrictedExtent: [-13358338.893333, -9608371.5085962, 13358338.893333, 9608371.5085962], center: [-12356463.476333, 5621521.4854095] }); // create a map without a reference to a container - call render later var map = new ALKMaps.Map({ projection: "EPSG:3857", maxExtent: new ALKMaps.Bounds(-200000, -200000, 200000, 200000) });
destroy:function()
Destroy this map. Note that if you are using an application which removes a container of the map from the DOM, you need to ensure that you destroy the map before this happens; otherwise, the page unload handler will fail because the DOM elements that map.destroy() wants to clean up will be gone. This will apply to GeoExt and also to other applications which modify the DOM of the container of the ALKMaps Map.
getBy: function( array, property, match )
Get a list of objects given a property and a match item.
array | {String} A property on the map whose value is an array. |
property | {String} A property on each item of the given array. |
match | {String | Object} A string to match. Can also be a regular expression literal or object. In addition, it can be any object with a method named test. For regular expressions or other, if match.test(map[array][i][property]) evaluates to true, the item will be included in the array returned. If no items are found, an empty array is returned. |
{Array} An array of items where the given property matches the given criteria.
getLayersBy: function( property, match )
Get a list of layers with properties matching the given criteria.
property | {String} A layer property to be matched. |
match | {String | Object} A string to match. Can also be a regular expression literal or object. In addition, it can be any object with a method named test. For regular expressions or other, if match.test(layer[property]) evaluates to true, the layer will be included in the array returned. If no layers are found, an empty array is returned. |
{Array(ALKMaps.Layer)} A list of layers matching the given criteria. An empty array is returned if no matches are found.
getLayersByName: function( match )
Get a list of layers with names matching the given name.
match | {String | Object} A layer name. The name can also be a regular expression literal or object. In addition, it can be any object with a method named test. For regular expressions or other, if name.test(layer.name) evaluates to true, the layer will be included in the list of layers returned. If no layers are found, an empty array is returned. |
{Array(ALKMaps.Layer)} A list of layers matching the given name. An empty array is returned if no matches are found.
getLayersByClass: function( match )
Get a list of layers of a given class (CLASS_NAME).
match | {String | Object} A layer class name. The match can also be a regular expression literal or object. In addition, it can be any object with a method named test. For regular expressions or other, if type.test(layer.CLASS_NAME) evaluates to true, the layer will be included in the list of layers returned. If no layers are found, an empty array is returned. |
{Array(ALKMaps.Layer)} A list of layers matching the given class. An empty array is returned if no matches are found.
getControlsBy: function( property, match )
Get a list of controls with properties matching the given criteria.
property | {String} A control property to be matched. |
match | {String | Object} A string to match. Can also be a regular expression literal or object. In addition, it can be any object with a method named test. For regular expressions or other, if match.test(layer[property]) evaluates to true, the layer will be included in the array returned. If no layers are found, an empty array is returned. |
{Array(ALKMaps.Control)} A list of controls matching the given criteria. An empty array is returned if no matches are found.
getControlsByClass: function( match )
Get a list of controls of a given class (CLASS_NAME).
match | {String | Object} A control class name. The match can also be a regular expression literal or object. In addition, it can be any object with a method named test. For regular expressions or other, if type.test(control.CLASS_NAME) evaluates to true, the control will be included in the list of controls returned. If no controls are found, an empty array is returned. |
{Array(ALKMaps.Control)} A list of controls matching the given class. An empty array is returned if no matches are found.
getLayer: function( id )
Get a layer based on its id
id | {String} A layer id |
{ALKMaps.Layer} The Layer with the corresponding id from the map’s layer collection, or null if not found.
addLayer: function ( layer )
layer | {ALKMaps.Layer} |
{Boolean} True if the layer has been added to the map.
removeLayer: function( layer, setNewBaseLayer )
Removes a layer from the map by removing its visual element (the layer.div property), then removing it from the map’s internal list of layers, setting the layer’s map property to null.
a “removelayer” event is triggered.
very worthy of mention is that simply removing a layer from a map will not cause the removal of any popups which may have been created by the layer. this is due to the fact that it was decided at some point that popups would not belong to layers. thus there is no way for us to know here to which layer the popup belongs.
A simple solution to this is simply to call destroy() on the layer. the default ALKMaps.Layer class’s destroy() function automatically takes care to remove itself from whatever map it has been attached to.
The correct solution is for the layer itself to register an event-handler on “removelayer” and when it is called, if it recognizes itself as the layer being removed, then it cycles through its own personal list of popups, removing them from the map.
layer | {ALKMaps.Layer} |
setNewBaseLayer | {Boolean} Default is true |
getLayerIndex: function ( layer )
layer | {ALKMaps.Layer} |
{Integer} The current (zero-based) index of the given layer in the map’s layer stack. Returns -1 if the layer isn’t on the map.
setLayerIndex: function ( layer, idx )
Move the given layer to the specified (zero-based) index in the layer list, changing its z-index in the map display. Use map.getLayerIndex() to find out the current index of a layer. Note that this cannot (or at least should not) be effectively used to raise base layers above overlays.
layer | {ALKMaps.Layer} |
idx | {int} |
raiseLayer: function ( layer, delta )
Change the index of the given layer by delta. If delta is positive, the layer is moved up the map’s layer stack; if delta is negative, the layer is moved down. Again, note that this cannot (or at least should not) be effectively used to raise base layers above overlays.
layer | {ALKMaps.Layer} |
delta | {int} |
setBaseLayer: function( newBaseLayer )
Allows user to specify one of the currently-loaded layers as the Map’s new base layer.
newBaseLayer | {ALKMaps.Layer} |
addControl: function ( control, px )
Add the passed over control to the map. Optionally position the control at the given pixel.
control | {ALKMaps.Control} |
px | {ALKMaps.Pixel} |
addControls: function ( controls, pixels )
Add all of the passed over controls to the map. You can pass over an optional second array with pixel-objects to position the controls. The indices of the two arrays should match and you can add null as pixel for those controls you want to be autopositioned.
controls | {Array(ALKMaps.Control)} |
pixels | {Array(ALKMaps.Pixel)} |
getControl: function ( id )
id | {String} ID of the control to return. |
{ALKMaps.Control} The control from the map’s list of controls which has a matching ‘id’. If none found, returns null.
removeControl: function ( control )
Remove a control from the map. Removes the control both from the map object’s internal array of controls, as well as from the map’s viewPort (assuming the control was not added outsideViewport)
control | {ALKMaps.Control} The control to remove. |
addPopup: function( popup, exclusive )
popup | {ALKMaps.Popup} |
exclusive | {Boolean} If true, closes all other popups first |
getSize: function ()
{ALKMaps.Size} An ALKMaps.Size object that represents the size, in pixels, of the div into which ALKMaps has been loaded. Note - A clone() of this locally cached variable is returned, so as not to allow users to modify it.
getCurrentSize: function()
{ALKMaps.Size} A new ALKMaps.Size object with the dimensions of the map div
calculateBounds: function( center, resolution )
center | {ALKMaps.LonLat} Default is this.getCenter() |
resolution | {float} Default is this.getResolution() |
{ALKMaps.Bounds} A bounds based on resolution, center, and current mapsize.
panTo: function( lonlat )
Allows user to pan to a new lonlat If the new lonlat is in the current extent the map will slide smoothly
lonlat | {ALKMaps.LonLat} |
setCenter: function( lonlat, zoom, dragging, forceZoomChange )
Set the map center (and optionally, the zoom level).
lonlat | {<ALKMaps.LonLat>|Array} The new center location. If provided as array, the first value is the x coordinate, and the 2nd value is the y coordinate. |
zoom | {Integer} Optional zoom level. |
dragging | {Boolean} Specifies whether or not to trigger movestart/end events |
forceZoomChange | {Boolean} Specifies whether or not to trigger zoom change events (needed on baseLayer change) |
adjustZoom: function( zoom )
zoom | {Number} The zoom level to adjust |
{Integer} Adjusted zoom level that shows a map not wider than its baseLayer’s maxExtent.
centerLayerContainer: function ( lonlat )
This function takes care to recenter the layerContainerDiv.
lonlat | {ALKMaps.LonLat} |
isValidLonLat: function( lonlat )
lonlat | {ALKMaps.LonLat} |
{Boolean} Whether or not the lonlat passed in is non-null and within the maxExtent bounds
getProjection: function()
This method returns a string representing the projection. In the case of projection support, this will be the srsCode which is loaded -- otherwise it will simply be the string value that was passed to the projection at startup.
{String} The Projection string from the base layer or null.
getProjectionObject: function()
Returns the projection obect from the baselayer.
{ALKMaps.Projection} The Projection of the base layer.
getMaxExtent: function ( options )
options | {Object} |
restricted | {Boolean} If true, returns restricted extent (if it is available.) |
{ALKMaps.Bounds} The maxExtent property as set on the current baselayer, unless the ‘restricted’ option is set, in which case the ‘restrictedExtent’ option from the map is returned (if it is set).
getExtent: function ()
{ALKMaps.Bounds} A Bounds object which represents the lon/lat bounds of the current viewPort. If no baselayer is set, returns null.
getZoomForExtent: function ( bounds, closest )
bounds | {ALKMaps.Bounds} |
closest | {Boolean} Find the zoom level that most closely fits the specified bounds. Note that this may result in a zoom that does not exactly contain the entire extent. Default is false. |
{Integer} A suitable zoom level for the specified bounds. If no baselayer is set, returns null.
getZoomForResolution: function( resolution, closest )
resolution | {Float} |
closest | {Boolean} Find the zoom level that corresponds to the absolute closest resolution, which may result in a zoom whose corresponding resolution is actually smaller than we would have desired (if this is being called from a getZoomForExtent() call, then this means that the returned zoom index might not actually contain the entire extent specified... but it’ll be close). Default is false. |
{Integer} A suitable zoom level for the specified resolution. If no baselayer is set, returns null.
zoomToExtent: function( bounds, closest )
Zoom to the passed in bounds, recenter
bounds | {<ALKMaps.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). |
closest | {Boolean} Find the zoom level that most closely fits the specified bounds. Note that this may result in a zoom that does not exactly contain the entire extent. Default is false. |
getLonLatFromViewPortPx: function ( viewPortPx )
viewPortPx | {<ALKMaps.Pixel>|Object} An ALKMaps.Pixel or an object with a ‘x’ and ‘y’ properties. |
{ALKMaps.LonLat} An ALKMaps.LonLat which is the passed-in view port ALKMaps.Pixel, translated into lon/lat by the current base layer.
getViewPortPxFromLonLat: function ( lonlat )
lonlat | {ALKMaps.LonLat} |
{ALKMaps.Pixel} An ALKMaps.Pixel which is the passed-in ALKMaps.LonLat, translated into view port pixels by the current base layer.
getLonLatFromPixel: function ( px )
px | {<ALKMaps.Pixel>|Object} An ALKMaps.Pixel or an object with a ‘x’ and ‘y’ properties. |
{ALKMaps.LonLat} An ALKMaps.LonLat corresponding to the given ALKMaps.Pixel, translated into lon/lat by the current base layer
getPixelFromLonLat: function ( lonlat )
Returns a pixel location given a map location. The map location is translated to an integer pixel location (in viewport pixel coordinates) by the current base layer.
lonlat | {ALKMaps.LonLat} A map location. |
{ALKMaps.Pixel} An ALKMaps.Pixel corresponding to the ALKMaps.LonLat translated into view port pixels by the current base layer.
getGeodesicPixelSize: function( px )
px | {ALKMaps.Pixel} The pixel to get the geodesic length for. If not provided, the center pixel of the map viewport will be used. |
{ALKMaps.Size} The geodesic size of the pixel in kilometers.
getViewPortPxFromLayerPx:function( layerPx )
layerPx | {ALKMaps.Pixel} |
{ALKMaps.Pixel} Layer Pixel translated into ViewPort Pixel coordinates
getLayerPxFromViewPortPx:function( viewPortPx )
viewPortPx | {ALKMaps.Pixel} |
{ALKMaps.Pixel} ViewPort Pixel translated into Layer Pixel coordinates
getLayerPxFromLonLat: function ( lonlat )
lonlat | {ALKMaps.LonLat} lonlat |
{ALKMaps.Pixel} An ALKMaps.Pixel which is the passed-in ALKMaps.LonLat, translated into layer pixels by the current base layer
reverseGeocode: function ( inputs )
This function takes latitude and longitude, returns address object synchronously or asynchronously.
inputs | {Object} Accept {“lonLat”:ALKMaps.LonLat, “region”:String, “async”:Boolean, “success”: cbfunction, “failure”: cbfunction} |
lonLat | {ALKMaps.LonLat} The place with longitude and latitude values or meters depending on map projection. |
region | {String} The data region in which the address or coordinates lie. Valid values are NA, EU, OC and SA. If region is not provided, it may inherit from baseLayer region parameter. |
async | {Boolean} Send service request asynchronously or not. |
success | {Function} Function handles success asynchronous service response. |
failure | {Function} Function handles failure asynchronous service response. |
{Array of Address Object}
Call reverseGeocode function synchronously
var lonlat = new ALKMaps.LonLat(-122.31693, 47.60784); var d = map.reverseGeocode({"lonLat":lonlat, "async":false});
Call reverseGeocode function asynchronously
var inputs = { "lonLat":new ALKMaps.LonLat(-122.31693, 47.60784), "async":true, "success":function(response){ var responseText = response.responseText; // Todo: Convert response text into Json object. }, "failure":function(response){ alert(response.status + '\n' + response.statusText + '\n ' + response.responseText); } }; map.reverseGeocode(inputs);
Returned result should look like the following - [{“Address”:{ “StreetAddress”:”665 12th Avenue”, “City”:”Seattle”, “State”:”WA”, “Zip”:”98122”, “County”:”King”, “Country”:null, “Region”:0, “PlaceName”:””, “SPLC”:null, “CountryPostalFilter”:0, “Label”:null }, “Coords”:{ “Lat”:”47.60784”, “Lon”:”-122.31693” }, “Errors”:null }]
geocode: function ( inputs )
This function takes address object, returns address arrays with longitudes and latitudes. If the geocoding service finds multiple results that match the address object, by default, one result is returned. To receive multiple results set the optional listSize property to the desired amount.
inputs | {Object} Accepts {“address”: {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region}, “listSize”:number, “async”:Boolean, “success”:cbfunction, “failure”:cbfunction} |
address | {Object} Accepts {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode} |
listSize | {Number} Optional. Maximum number of results to be returned. |
async | {Boolean} Send service request asynchronously or not. |
success | {Function} Function handles success asynchronous service response. |
failure | {Function} Function handles failure asynchronous service response. |
addr | {String} Street address |
city | {String} City name |
state | {String} The state (or country) abbreviation, for example, AZ for Arizona or NSW for New South Wales. |
zip | {String} The zip or postal code. |
region | {String} The data region in which the address or coordinates lie. Valid values are NA, EU, OC and SA. If region is not provided, it may inherit from baseLayer region parameter. |
{Array of Address Object}
Call geocode function synchronously
var inputs = {"address":{"addr":"1048 Spring Street", "city":"Seattle", "state":"WA", "zip":"98104"}, "async":false}; var address = map.geocode(inputs);
Call geocode function asynchronously
var inputs = { "address":{"addr":"1048 Spring Street", "city":"Seattle", "state":"WA", "zip":"98104"}, "async":true, "success":function(response){ var responseText = response.responseText; // Todo: Convert response text into Json object. }, "failure":function(response){ alert(response.status + '\n' + response.statusText + '\n ' + response.responseText); } }; map.geocode(inputs);
Returned result should look like the following - [{“Address”:{“StreetAddress”:”1048 Spring Street”,”City”:”Seattle”,”State”:”WA”,”Zip”:”98104”,”County”:”King”,”Country”:null,”Region”:0,”PlaceName”:null,”SPLC”:null,”CountryPostalFilter”:0,”Label”:null},”Coords”:{“Lat”:”47.609813”,”Lon”:”-122.32636”},”Errors”:[]}]
simpleGeocode: function ( inputs )
This function takes address object, returns address arrays with longitudes and latitudes.
inputs | {Object} Accept {“address”: {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region}, “async”:Boolean, “success”:cbfunction, “failure”:cbfunction} |
address | {Object} Accept JSON structure {“addr”: address, “city”: cityName, “state”: stateAbbr, “zip”: zipCode, “region”:region}. If region is not provided, it may inherit from baseLayer region parameter. |
async | {Boolean} Send service request asynchronously or not. |
success | {Function} Function handles success asynchronouse service response. |
failure | {Function} Function handles failure asynchronouse service response. |
addr | {String} Street address |
city | {String} City name |
state | {String} The state (or country) abbreviation, for example, AZ for Arizona or NSW for New South Wales. |
zip | {String} The zip or postal code. |
region | {String} The data region in which the address or coordinates lie. Valid values are NA, EU, OC and SA. |
geoSearch: function( inputs )
This function is used to search country, state, and city places.
inputs | {Object} |
place | {String} Country or state or city name |
listSize | {Number} Optional. Maximum number of results to be returned. |
transform | {Boolean} Optional. The unit of returned longitude and latitude values will be determined by the map projection by default. The geo coder service returns degrees for longitude and latitude values. If degree is desirable, then set this parameter to false. |
success | {Function} Function handles success asynchronouse service response. |
failure | {Function} Function handles failure asynchronouse service response. |
var inputs = { "place": "", "listSize": 1, "success": function(response){ var responseText = response.responseText; // Todo: Convert response text into Json object. }, "failure": function(response){ alert(response.status + '\n' + response.statusText + '\n ' + response.responseText); } }
Returned result should look like the following - [{“Address”:{“StreetAddress”:”1048 Spring Street”,”City”:”Seattle”,”State”:”WA”,”Zip”:”98104”,”County”:”King”,”Country”:null,”Region”:0,”PlaceName”:null,”SPLC”:null,”CountryPostalFilter”:0,”Label”:null},”Coords”:{“Lat”:”47.609813”,”Lon”:”-122.32636”},”BBox”:{“Left”:11.039,”Bottom”:44.44,”Right”: 33.33,”Top”:33.222},”Errors”:[]}]
{Array of Objects with Address, Coords, BBox and Errors properties} BBox has Left, Bottom, Right and Top properties, representing country, state, or city bounding box in rectangle.
getReports: function ( inputs )
Takes coords objects and report options, return total time and total distance synchronously.
inputs | {Object} |
coords | {Array of decimal pairs} Coordinates of the start, end, and any waypoints for the given route. |
options | {Object} optional function specification settings. |
reportOptions | {Object} optional reporting specification settings. |
vehicleType | {Number} Restricts the route to roads that are accessible by the selected vehicle. Default: 0 (0 - Truck, 1 - Light Truck, 2 - Automobile) |
routingType | {Number} Generates the route to match the type. Default: 0 (0 - Practical, 1 - Shortest) |
highwayOnly | {Boolean} Restricts the route to only highway roads. Default: false |
custRdSpeeds | {Boolean} Can be true or false and indicates whether to use custom road speeds. |
useAvoidFavors | {Boolean} Can be true or false and indicates whether or not to use avoids and favors while routing. |
classOverrides | {Number} 0 - Indicates that no class overrides are present, 1 - Indicates a 53’ class override, 2 - Indicates a National Network class override. Default: 0 |
distanceUnits | {Number} Distance units as miles or kilometers. Default: 0 (0 - Miles, 1 - Kilometers) |
fuelUnits | {Number} Fuel units as gallons and liters. Default: 0 (0 - Gallons, 1 - Liters) |
tollDiscourage | {Boolean} Generates the route by trying to avoid toll roads. Default: false |
inclFerryDist | {Boolean} Indicates whether or not to include ferry distances in mileage calculations; can be true or false. |
bordersOpen | {Boolean} Indicates whether borders are open for travel. Default: true |
overrideRestrict | {Boolean} Indicates whether or not to override truck restrictions. Default: false |
hazMatType | {Number} Restricts the route to roads that allow transportation of the selected hazardous material. Default: 0 (0 - None, 1 - General, 2 - Caustic, 3 - Explosives, 4 - Flammable, 5 - Inhalants, 6 - Radioactive, 7 - HarmfulToWater) |
tunnelCategory | {Number} Indicates the tunnel categories which are applicable for EU region only. Default: 0 (0 - None, 1 - TunnelBCDE, 2 - TunnelCDE, 3 - TunnelDE, 4 - TunnelE). |
routeOptimization | {Number} 0 - None, 1 - Optimize All Stops, 2 - Optimize Intermediate Stops. Default: 0 |
lang | {String} The language. (ENUS - English United States, ENGB - English Great Britain, DE - German, FR - French, ES - Spanish, IT - Italian) |
hubRouting | {Boolean} Indicates whether or not to enable hub routing; can be true or false. |
trkUnits | {Number} Vehicle dimension units; can be English or Metric. Default: 0 (0 - Indicates that vehicle dimension units should be English, 1 - Indicates that vehicle dimension units should be metric) |
trkHeight | {Number} The height of the vehicle in feet and inches or meters depending on units. |
trkLength | {Number} The length of the vehicle in feet and inches or meters depending on units. |
trkWidth | {Number} The width of the vehicle in feet and inches or meters depending on units. |
trkWeight | {Number} The weight of the vehicle in pounds or kilograms depending on units. |
trkAxles | {Number} The number of axles on the vehicle; acceptable values are 2 through 14. Default: 5 |
truckConfig | {Number} The vehicle style. Default: 0 (0 - no vehicle style is chosen, 1 - 28’ double trailer, 2 - 40’ straight trailer, 3 - 48’ semitrailer, 4 - 53’ semitrailer) |
trkLCV | {Boolean} Indicates whether the truck is a multi-trailer or longer combination vehicle. |
inclTollData | {Boolean} Indicates whether or not reports should calculate toll costs. Default: true |
fuelEconLoad | {Number} The fuel efficiency (distance units per fuel units) when loaded. |
fuelEconEmpty | {Number} The fuel efficiency (distance units per fuel units) when empty. |
costPerFuelUnit | {Number} The cost per fuel unit of fuel. |
costGHG | {Number} The cost of greenhouse gas in lbs. per fuel unit. |
costMaintLoad | {Number} The maintenance cost per distance unit when loaded. |
costMaintEmpty | {Number} The maintenance cost per distance unit when empty. |
costTimeLoad | {Number} The time cost per mile/km when loaded. |
costTimeEmpty | {Number} The time cost per mile/km when empty. |
tollCurrency | {Number} The toll currency. Default: 0 (0 - United States dollars, 1 - Canadian dollars) |
exchangeRate | {Number} The change rate to convert US dollars to Canadian dollars. |
tollPlan | The toll discount plan which is a comma-separated list of toll discount programs. Use All for everything otherwise valid values are (407ETR Transponder,A25 Transponder,BreezeBy,C-Pass,Cruise Card,E-Pass,E-Pass Canada,EXpress Toll,EZ Tag,EZPass,EZPass-NJ,EZPass-WV,FAST LANE,FasTrak,GeauxPass,Good To Go,GO-PASS,I-Pass,I-Zoom,K-TAG,Laredo Trade Tag,LeeWay,MACPASS,NC Quick Pass,NEXPress,Palmetto Pass,Peach Pass,PikePass,Quickpass,Smart Tag,StraitPASS,SunPass,TollTag,TxTag,Wabash Pass) |
citeInt | {Number} The cite interval to be used when generating a geotunnel report. The minimum value is 0.1. |
region | {String} The data region in which the route stops are located. Default: NA (NA - North America, EU - Europe, OC, SA - South America) |
type | {String} Comma-separated list of requested report types. (Mileage, Directions, Detail, State, CalcMiles, LeastCost, Geotunnel) |
format | {String} The format of the report returned with the route. Default: json (json, html) |
dataVersion | {String} Data version. (‘current’,’PCM18’ through ‘PCM26’) |
estimatedTimeOpts | {String} Estimated time options, format Depart(Arrive)|[DayOfWeek][SpecificDateTime]|[TimeOfDay], ex: Depart|Monday|18:30 to depart given day of week and time of day; or Arrive|2014-03-04T08:15:30-05:00 to arrive at specific date/time, or Arrive or Depart to arrive or depart with system time. |
breakInterval | {Number} The elapsed time of the trip before a break will be taken. The format is in decimal hours, ex: 3.5 for 3 hours 30 minutes. |
breakLength | {Number} The amount of time a break will last. The format is in decimal hours, ex: 0.5 for 30 minutes. |
borderWait | {Number} The additional amount of time at the border to the overall trip. The format is in decimal hours. |
remHrsOfSvc | {Number} The remaining hours of service at the start of the trip before the driver needs to take a break. The format is in decimal hours. |
ALKMaps.Services.getReports({ coords: [[-75.173297,39.942892],[-74.438942,39.362469]], options: { vehicleType: 2, routingType: 0, routeOptimization: 1, highwayOnly: false, distanceUnits: 0, tollCurrency: 0, inclTollData:true, region: "NA" }, reportOptions: { type: "Directions,Mileage", format: "json", dataVersion: "current" }, success: function(resp){Display Reports} });
getRoutePath: function ( inputs )
Takes coords objects and route options, return lat/lons for the route path.
inputs | {Object} |
ioformat | {Object} It has input and output properties. Input can be null, 1, or 2. Output can be null, 1, or 2. |
stops | {String} “lon,lat;...;lon,lat” if ioformat.input is not provided. Expected an array of ALKMaps.LonLat objects if ioformat.input is 1. Or [[lon,lat], ...,[lon,lat]] if ioformat.input is 2. |
options | {Object} |
{ stops: '-75.339368,40.11442;-74.911539,40.159933;-74.885531,39.993483;-75.191123,39.802326', ioformat: { output: 1 }, options: { 'vehicleType': 'Truck', 'routingType': 'Practical', 'routeOptimization': 1, 'highwayOnly': false, 'distanceUnits': 'Miles', 'tollDiscourage': true } }
[[lon,lat],[lon,lat], ... , [lon,lat], [lon,lat]] if ioformat.output is null. If ioformat.output is 1, returns an array of ALKMaps.Geometry.Point. If ioformat.output is 2, returns ALKMaps.Geometry.MultiLineString.
getDerivedRoutePath: function( inputs )
Take pings and route options, return derived route points.
ioformat | {Object} It has input and output properties. Input can be null, 1, or 2. Output can be null, 1, or 2. |
pings | {String} “lon,lat;...;lon,lat” if ioformat.input is not provided. Expected an array of ALKMaps.LonLat objects if ioformat.input is 1. Or [[lon,lat], ...,[lon,lat]] if ioformat.input is 2. |
options | {Object} {region: “NA”, offRouteMiles: number, highwayOnly: boolean}. See notes bellow. |
success | {Function} Success callback function |
failure | {Function} Failure callback function |
[[lon,lat],[lon,lat], ... , [lon,lat], [lon,lat]] if ioformat.output is null. If ioformat.output is 1, returns an array of ALKMaps.Geometry.Point. If ioformat.output is 2, returns ALKMaps.Geometry.MultiLineString.
Convenience method for registering listeners with a common scope.
on: function( object )
Get the DOMElement representing the view port.
getViewport: function()
Render the map to a specified container.
render: function( div )
Destroy this map.
destroy:function()
Change the map options
setOptions: function( options )
Get the tile size for the map
getTileSize: function()
Get a list of objects given a property and a match item.
getBy: function( array, property, match )
Get a list of layers with properties matching the given criteria.
getLayersBy: function( property, match )
Get a list of layers with names matching the given name.
getLayersByName: function( match )
Get a list of layers of a given class (CLASS_NAME).
getLayersByClass: function( match )
Get a list of controls with properties matching the given criteria.
getControlsBy: function( property, match )
Get a list of controls of a given class (CLASS_NAME).
getControlsByClass: function( match )
Get a layer based on its id
getLayer: function( id )
setLayerZIndex: function ( layer, zIdx )
Reset each layer’s z-index based on layer’s array index
resetLayersZIndex: function()
addLayer: function ( layer )
addLayers: function ( layers )
Removes a layer from the map by removing its visual element (the layer.div property), then removing it from the map’s internal list of layers, setting the layer’s map property to null.
removeLayer: function( layer, setNewBaseLayer )
{Int} The number of layers attached to the map.
getNumLayers: function ()
getLayerIndex: function ( layer )
Move the given layer to the specified (zero-based) index in the layer list, changing its z-index in the map display.
setLayerIndex: function ( layer, idx )
Change the index of the given layer by delta.
raiseLayer: function ( layer, delta )
Allows user to specify one of the currently-loaded layers as the Map’s new base layer.
setBaseLayer: function( newBaseLayer )
Add the passed over control to the map.
addControl: function ( control, px )
Add all of the passed over controls to the map.
addControls: function ( controls, pixels )
addControlToMap: function ( control, px )
getControl: function ( id )
Remove a control from the map.
removeControl: function ( control )
addPopup: function( popup, exclusive )
removePopup: function( popup )
{ALKMaps.Size} An ALKMaps.Size object that represents the size, in pixels, of the div into which ALKMaps has been loaded.
getSize: function ()
This function should be called by any external code which dynamically changes the size of the map div (because mozilla wont let us catch the “onresize” for an element)
updateSize: function()
{ALKMaps.Size} A new ALKMaps.Size object with the dimensions of the map div
getCurrentSize: function()
calculateBounds: function( center, resolution )
Enables the default right-click context menu;
enableContextMenu: function()
Disables the default right-click context menu;
disableContextMenu: function()
{ALKMaps.LonLat}
getCenter: function ()
{ALKMaps.LonLat}
getCachedCenter: function()
{Integer}
getZoom: function ()
Allows user to pan by a value of screen pixels
pan: function( dx, dy, options )
Allows user to pan to a new lonlat If the new lonlat is in the current extent the map will slide smoothly
panTo: function( lonlat )
Set the map center (and optionally, the zoom level).
setCenter: function( lonlat, zoom, dragging, forceZoomChange )
Drag the map by pixels.
moveByPx: function( dx, dy )
adjustZoom: function( zoom )
moveTo: function( lonlat, zoom, options )
This function takes care to recenter the layerContainerDiv.
centerLayerContainer: function ( lonlat )
isValidZoomLevel: function( zoomLevel )
isValidLonLat: function( lonlat )
This method returns a string representing the projection.
getProjection: function()
Returns the projection obect from the baselayer.
getProjectionObject: function()
{String} The Map’s Maximum Resolution
getMaxResolution: function()
getMaxExtent: function ( options )
{Integer} The total number of zoom levels that can be displayed by the current baseLayer.
getNumZoomLevels: function()
{ALKMaps.Bounds} A Bounds object which represents the lon/lat bounds of the current viewPort.
getExtent: function ()
{Float} The current resolution of the map.
getResolution: function ()
{Float} The current units of the map.
getUnits: function ()
{Float} The current scale denominator of the map.
getScale: function ()
getZoomForExtent: function ( bounds, closest )
getResolutionForZoom: function( zoom )
getZoomForResolution: function( resolution, closest )
Zoom to a specific zoom level
zoomTo: function( zoom )
zoomIn: function()
zoomOut: function()
Zoom to the passed in bounds, recenter
zoomToExtent: function( bounds, closest )
Zoom to the full extent and recenter.
zoomToMaxExtent: function( options )
Zoom to a specified scale
zoomToScale: function( scale, closest )
getLonLatFromViewPortPx: function ( viewPortPx )
getViewPortPxFromLonLat: function ( lonlat )
getLonLatFromPixel: function ( px )
Returns a pixel location given a map location.
getPixelFromLonLat: function ( lonlat )
getGeodesicPixelSize: function( px )
getViewPortPxFromLayerPx:function( layerPx )
getLayerPxFromViewPortPx:function( viewPortPx )
getLonLatFromLayerPx: function ( px )
getLayerPxFromLonLat: function ( lonlat )
showLoading: function( evt )
hideLoading: function( evt )
showMapLoadingIcon: function( id, imgURL, className )
adjustZoomControl: function()
Enables the SafeScroll feature for the map.
enableSafeScroll: function()
Disables the SafeScroll feature for the map.
disableSafeScroll: function()
safeScroll: function()
This function takes latitude and longitude, returns address object synchronously or asynchronously.
reverseGeocode: function ( inputs )
This function takes address object, returns address arrays with longitudes and latitudes.
geocode: function ( inputs )
This function takes address object, returns address arrays with longitudes and latitudes.
simpleGeocode: function ( inputs )
This function is used to search country, state, and city places.
geoSearch: function( inputs )
Takes coords objects and report options, return total time and total distance synchronously.
getReports: function ( inputs )
Takes coords objects and route options, return lat/lons for the route path.
getRoutePath: function ( inputs )
Take pings and route options, return derived route points.
getDerivedRoutePath: function( inputs )