|
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
|
* full list of contributors). Published under the Clear BSD license. |
|
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
|
* full text of the license. */ |
|
|
|
/** |
|
* @requires OpenLayers/Util.js |
|
* @requires OpenLayers/Events.js |
|
* @requires OpenLayers/Tween.js |
|
* @requires OpenLayers/Console.js |
|
*/ |
|
|
|
/** |
|
* Class: OpenLayers.Map |
|
* Instances of OpenLayers.Map are interactive maps embedded in a web page. |
|
* Create a new map with the <OpenLayers.Map> constructor. |
|
* |
|
* On their own maps do not provide much functionality. To extend a map |
|
* it's necessary to add controls (<OpenLayers.Control>) and |
|
* layers (<OpenLayers.Layer>) to the map. |
|
*/ |
|
OpenLayers.Map = OpenLayers.Class({ |
|
|
|
/** |
|
* Constant: Z_INDEX_BASE |
|
* {Object} Base z-indexes for different classes of thing |
|
*/ |
|
Z_INDEX_BASE: { |
|
BaseLayer: 100, |
|
Overlay: 325, |
|
Feature: 725, |
|
Popup: 750, |
|
Control: 1000 |
|
}, |
|
|
|
/** |
|
* Constant: EVENT_TYPES |
|
* {Array(String)} Supported application event types. Register a listener |
|
* for a particular event with the following syntax: |
|
* (code) |
|
* map.events.register(type, obj, listener); |
|
* (end) |
|
* |
|
* Listeners will be called with a reference to an event object. The |
|
* properties of this event depends on exactly what happened. |
|
* |
|
* All event objects have at least the following properties: |
|
* - *object* {Object} A reference to map.events.object. |
|
* - *element* {DOMElement} A reference to map.events.element. |
|
* |
|
* Browser events have the following additional properties: |
|
* - *xy* {<OpenLayers.Pixel>} The pixel location of the event (relative |
|
* to the the map viewport). |
|
* - other properties that come with browser events |
|
* |
|
* Supported map event types: |
|
* - *preaddlayer* triggered before a layer has been added. The event |
|
* object will include a *layer* property that references the layer |
|
* to be added. |
|
* - *addlayer* triggered after a layer has been added. The event object |
|
* will include a *layer* property that references the added layer. |
|
* - *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 or visibility change |
|
* (due to resolution thresholds). 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 or visibility). |
|
* - *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 |
|
*/ |
|
EVENT_TYPES: [ |
|
"preaddlayer", "addlayer", "removelayer", "changelayer", "movestart", |
|
"move", "moveend", "zoomend", "popupopen", "popupclose", |
|
"addmarker", "removemarker", "clearmarkers", "mouseover", |
|
"mouseout", "mousemove", "dragstart", "drag", "dragend", |
|
"changebaselayer"], |
|
|
|
/** |
|
* Property: id |
|
* {String} Unique identifier for the map |
|
*/ |
|
id: null, |
|
|
|
/** |
|
* Property: 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. 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. |
|
*/ |
|
fractionalZoom: false, |
|
|
|
/** |
|
* APIProperty: events |
|
* {<OpenLayers.Events>} An events object that handles all |
|
* events on the map |
|
*/ |
|
events: null, |
|
|
|
/** |
|
* APIProperty: allOverlays |
|
* {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. |
|
* |
|
* Note: |
|
* 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. |
|
*/ |
|
allOverlays: false, |
|
|
|
/** |
|
* APIProperty: div |
|
* {DOMElement|String} The element that contains the map (or an id for |
|
* that element). If the <OpenLayers.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. |
|
* |
|
* Note: |
|
* If you are calling <render> after map construction, do not use |
|
* <maxResolution> auto. Instead, divide your <maxExtent> by your |
|
* maximum expected dimension. |
|
*/ |
|
div: null, |
|
|
|
/** |
|
* Property: dragging |
|
* {Boolean} The map is currently being dragged. |
|
*/ |
|
dragging: false, |
|
|
|
/** |
|
* Property: size |
|
* {<OpenLayers.Size>} Size of the main div (this.div) |
|
*/ |
|
size: null, |
|
|
|
/** |
|
* Property: viewPortDiv |
|
* {HTMLDivElement} The element that represents the map viewport |
|
*/ |
|
viewPortDiv: null, |
|
|
|
/** |
|
* Property: layerContainerOrigin |
|
* {<OpenLayers.LonLat>} The lonlat at which the later container was |
|
* re-initialized (on-zoom) |
|
*/ |
|
layerContainerOrigin: null, |
|
|
|
/** |
|
* Property: layerContainerDiv |
|
* {HTMLDivElement} The element that contains the layers. |
|
*/ |
|
layerContainerDiv: null, |
|
|
|
/** |
|
* APIProperty: layers |
|
* {Array(<OpenLayers.Layer>)} Ordered list of layers in the map |
|
*/ |
|
layers: null, |
|
|
|
/** |
|
* Property: controls |
|
* {Array(<OpenLayers.Control>)} List of controls associated with the map. |
|
* |
|
* If not provided in the map options at construction, the map will |
|
* be given the following controls by default: |
|
* - <OpenLayers.Control.Navigation> |
|
* - <OpenLayers.Control.PanZoom> |
|
* - <OpenLayers.Control.ArgParser> |
|
* - <OpenLayers.Control.Attribution> |
|
*/ |
|
controls: null, |
|
|
|
/** |
|
* Property: popups |
|
* {Array(<OpenLayers.Popup>)} List of popups associated with the map |
|
*/ |
|
popups: null, |
|
|
|
/** |
|
* APIProperty: baseLayer |
|
* {<OpenLayers.Layer>} The currently selected base layer. This determines |
|
* min/max zoom level, projection, etc. |
|
*/ |
|
baseLayer: null, |
|
|
|
/** |
|
* Property: center |
|
* {<OpenLayers.LonLat>} The current center of the map |
|
*/ |
|
center: null, |
|
|
|
/** |
|
* Property: resolution |
|
* {Float} The resolution of the map. |
|
*/ |
|
resolution: null, |
|
|
|
/** |
|
* Property: zoom |
|
* {Integer} The current zoom level of the map |
|
*/ |
|
zoom: 0, |
|
|
|
/** |
|
* Property: panRatio |
|
* {Float} The ratio of the current extent within |
|
* which panning will tween. |
|
*/ |
|
panRatio: 1.5, |
|
|
|
/** |
|
* Property: viewRequestID |
|
* {String} Used to store a unique identifier that changes when the map |
|
* view changes. viewRequestID should be used when adding data |
|
* asynchronously to the map: viewRequestID is incremented when |
|
* you initiate your request (right now during changing of |
|
* baselayers and changing of zooms). It is stored here in the |
|
* map and also in the data that will be coming back |
|
* asynchronously. Before displaying this data on request |
|
* completion, we check that the viewRequestID of the data is |
|
* still the same as that of the map. Fix for #480 |
|
*/ |
|
viewRequestID: 0, |
|
|
|
// Options |
|
|
|
/** |
|
* APIProperty: tileSize |
|
* {<OpenLayers.Size>} Set in the map options to override the default tile |
|
* size for this map. |
|
*/ |
|
tileSize: null, |
|
|
|
/** |
|
* APIProperty: projection |
|
* {String} Set in the map options to override the default projection |
|
* string this map - also set maxExtent, maxResolution, and |
|
* units if appropriate. Default is "EPSG:4326". |
|
*/ |
|
projection: "EPSG:4326", |
|
|
|
/** |
|
* APIProperty: units |
|
* {String} The map units. Defaults to 'degrees'. Possible values are |
|
* 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'. |
|
*/ |
|
units: 'degrees', |
|
|
|
/** |
|
* APIProperty: resolutions |
|
* {Array(Float)} A list of map resolutions (map units per pixel) in |
|
* descending order. If this is not set in the layer constructor, it |
|
* will be set based on other resolution related properties |
|
* (maxExtent, maxResolution, maxScale, etc.). |
|
*/ |
|
resolutions: null, |
|
|
|
/** |
|
* APIProperty: maxResolution |
|
* {Float} Default max is 360 deg / 256 px, which corresponds to |
|
* zoom level 0 on gmaps. Specify a different value in the map |
|
* options if you are not using a geographic projection and |
|
* displaying the whole world. |
|
*/ |
|
maxResolution: 1.40625, |
|
|
|
/** |
|
* APIProperty: minResolution |
|
* {Float} |
|
*/ |
|
minResolution: null, |
|
|
|
/** |
|
* APIProperty: maxScale |
|
* {Float} |
|
*/ |
|
maxScale: null, |
|
|
|
/** |
|
* APIProperty: minScale |
|
* {Float} |
|
*/ |
|
minScale: null, |
|
|
|
/** |
|
* APIProperty: maxExtent |
|
* {<OpenLayers.Bounds>} The maximum extent for the map. Defaults to the |
|
* whole world in decimal degrees |
|
* (-180, -90, 180, 90). Specify a different |
|
* extent in the map options if you are not using a |
|
* geographic projection and displaying the whole |
|
* world. |
|
*/ |
|
maxExtent: null, |
|
|
|
/** |
|
* APIProperty: minExtent |
|
* {<OpenLayers.Bounds>} |
|
*/ |
|
minExtent: null, |
|
|
|
/** |
|
* APIProperty: restrictedExtent |
|
* {<OpenLayers.Bounds>} 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. |
|
*/ |
|
restrictedExtent: null, |
|
|
|
/** |
|
* APIProperty: numZoomLevels |
|
* {Integer} Number of zoom levels for the map. Defaults to 16. Set a |
|
* different value in the map options if needed. |
|
*/ |
|
numZoomLevels: 16, |
|
|
|
/** |
|
* APIProperty: theme |
|
* {String} Relative path to a CSS file from which to load theme styles. |
|
* Specify null in the map options (e.g. {theme: null}) if you |
|
* want to get cascading style declarations - by putting links to |
|
* stylesheets or style declarations directly in your page. |
|
*/ |
|
theme: null, |
|
|
|
/** |
|
* APIProperty: displayProjection |
|
* {<OpenLayers.Projection>} Requires proj4js support.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. |
|
*/ |
|
displayProjection: null, |
|
|
|
/** |
|
* APIProperty: fallThrough |
|