OpenLayers.Map - OpenLayers
OpenLayers.MapInstances 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.SummaryOpenLayers.MapInstances of OpenLayers.Map are interactive maps embedded in a web page. ConstantsZ_INDEX_BASE{Object} Base z-indexes for different classes of thingPropertiesevents{OpenLayers.Events}id{String} Unique identifier for the mapfractionalZoom{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{OpenLayers.Events} An events object that handles all events on the mapallOverlays{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{OpenLayers.Size} Size of the main div (this.div)viewPortDiv{HTMLDivElement} The element that represents the map viewportlayerContainerOrigin{OpenLayers.LonLat} The lonlat at which the later container was re-initialized (on-zoom)layerContainerDiv{HTMLDivElement} The element that contains the layers.layers{Array(OpenLayers.Layer)} Ordered list of layers in the mapcontrols{Array(OpenLayers.Control)} List of controls associated with the map.popups{Array(OpenLayers.Popup)} List of popups associated with the mapbaseLayer{OpenLayers.Layer} The currently selected base layer. center{OpenLayers.LonLat} The current center of the mapresolution{Float} The resolution of the map.zoom{Integer} The current zoom level of the mappanRatio{Float} The ratio of the current extent within which panning will tween.options{Object} The options object passed to the class constructor. tileSize{OpenLayers.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{<OpenLayers.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). minExtent{<OpenLayers.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). restrictedExtent{<OpenLayers.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{OpenLayers.Projection} Requires proj4js support for projections other than EPSG:4326 or EPSG:900913/EPSG:3857. fallThrough{Boolean} Should OpenLayers allow events on the map to fall through to other elements on the page, or should it swallow them? panTween{OpenLayers.Tween} Animated panning tween object, see panTo()eventListeners{Object} If set as an option at construction, the eventListeners object will be registered with OpenLayers.Events.on. panMethod{Function} The Easing function to be used for tweening. panDuration{Integer} The number of steps to be passed to the OpenLayers.Tween.start() method when the map is panned. paddingForPopups{OpenLayers.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. ConstructorOpenLayers.MapConstructor for a new OpenLayers.Map instance. FunctionsgetViewportGet the DOMElement representing the view port.renderRender the map to a specified container.unloadDestroyFunction that is called to destroy the map on page unload. updateSizeDestroyWhen 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.destroyDestroy this map. setOptionsChange the map optionsgetTileSizeGet the tile size for the mapgetByGet a list of objects given a property and a match item.getLayersByGet a list of layers with properties matching the given criteria.getLayersByNameGet a list of layers with names matching the given name.getLayersByClassGet a list of layers of a given class (CLASS_NAME).getControlsByGet a list of controls with properties matching the given criteria.getControlsByClassGet a list of controls of a given class (CLASS_NAME).getLayerGet a layer based on its idsetLayerZIndexresetLayersZIndexReset each layer’s z-index based on layer’s array indexaddLayeraddLayersremoveLayerRemoves 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.getLayerIndexsetLayerIndexMove the given layer to the specified (zero-based) index in the layer list, changing its z-index in the map display. raiseLayerChange the index of the given layer by delta. setBaseLayerAllows user to specify one of the currently-loaded layers as the Map’s new base layer.addControlAdd the passed over control to the map. addControlsAdd all of the passed over controls to the map. addControlToMapgetControlremoveControlRemove a control from the map. addPopupremovePopupgetSize{OpenLayers.Size} An OpenLayers.Size object that represents the size, in pixels, of the div into which OpenLayers has been loaded. updateSizeThis 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{OpenLayers.Size} A new OpenLayers.Size object with the dimensions of the map divcalculateBoundsgetCenter{OpenLayers.LonLat}getCachedCenter{OpenLayers.LonLat}getZoom{Integer}panAllows user to pan by a value of screen pixelspanToAllows user to pan to a new lonlat If the new lonlat is in the current extent the map will slide smoothlysetCenterSet the map center (and optionally, the zoom level).moveByPxDrag the map by pixels.adjustZoommoveTocenterLayerContainerThis function takes care to recenter the layerContainerDiv.isValidZoomLevelisValidLonLatgetProjectionThis method returns a string representing the projection. getProjectionObjectReturns the projection obect from the baselayer.getMaxResolution{String} The Map’s Maximum ResolutiongetMaxExtentgetNumZoomLevels{Integer} The total number of zoom levels that can be displayed by the current baseLayer.getExtent{OpenLayers.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. getZoomForExtentgetResolutionForZoomgetZoomForResolutionzoomToZoom to a specific zoom levelzoomInzoomOutzoomToExtentZoom to the passed in bounds, recenterzoomToMaxExtentZoom to the full extent and recenter.zoomToScaleZoom to a specified scalegetLonLatFromViewPortPxgetViewPortPxFromLonLatgetLonLatFromPixelgetPixelFromLonLatReturns a pixel location given a map location. getGeodesicPixelSizegetViewPortPxFromLayerPxgetLayerPxFromViewPortPxgetLonLatFromLayerPxgetLayerPxFromLonLatConstantsTILE_WIDTH{Integer} 256 Default tile width (unless otherwise specified)TILE_HEIGHT{Integer} 256 Default tile height (unless otherwise specified)
Constants
Z_INDEX_BASE{Object} Base z-indexes for different classes of thing
Properties
events{OpenLayers.Events}Register a listener for a particular event with the following syntaxmap.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.All event objects have at least the following propertiesobject{Object} A reference to map.events.object.element{DOMElement} A reference to map.events.element.Browser events have the following additional propertiesxy{OpenLayers.Pixel} The pixel location of the event (relative to the the map viewport).Supported map event typespreaddlayertriggered 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.addlayertriggered after a layer has been added. The event object will include a layer property that references the added layer.preremovelayertriggered 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.removelayertriggered after a layer has been removed. The event object will include a layer property that references the removed layer.changelayertriggered 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).movestarttriggered after the start of a drag, pan, or zoommovetriggered after each drag, pan, or zoommoveendtriggered after a drag, pan, or zoom completeszoomendtriggered after a zoom completesmouseovertriggered after mouseover the mapmouseouttriggered after mouseout the mapmousemovetriggered after mousemove the mapchangebaselayertriggered after the base layer changes
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. 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.
events{OpenLayers.Events} An events object that handles all events on the map
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.NoteIf 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.
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.NoteIf you are calling render after map construction, do not use maxResolution auto. Instead, divide your maxExtent by your maximum expected dimension.
dragging{Boolean} The map is currently being dragged.
size{OpenLayers.Size} Size of the main div (this.div)
viewPortDiv{HTMLDivElement} The element that represents the map viewport
layerContainerOrigin{OpenLayers.LonLat} The lonlat at which the later container was re-initialized (on-zoom)
layerContainerDiv{HTMLDivElement} The element that contains the layers.
layers{Array(OpenLayers.Layer)} Ordered list of layers in the map
controls{Array(OpenLayers.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:OpenLayers.Control.Navigation or OpenLayers.Control.TouchNavigationOpenLayers.Control.Zoom or OpenLayers.Control.PanZoomOpenLayers.Control.ArgParserOpenLayers.Control.Attribution
popups{Array(OpenLayers.Popup)} List of popups associated with the map
baseLayer{OpenLayers.Layer} The currently selected base layer. This determines min/max zoom level, projection, etc.
center{OpenLayers.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. Read-only.
tileSize{OpenLayers.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. 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:4326”. Note that the projection of the map is usually determined by that of the current baseLayer (see baseLayer and getProjectionObject).
units{String} The map units. Possible values are ‘degrees’ (or ‘dd’), ‘m’, ‘ft’, ‘km’, ‘mi’, ‘inches’. Normally taken from the projection. Only required if both map and layers do not define a projection, or if they define a projection which does not define units
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.).
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{<OpenLayers.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 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. To restrict user panning and zooming of the map, use restrictedExtent instead. The value for maxExtent will change calculations for tile URLs.
minExtent{<OpenLayers.Bounds>|Array} If provided as an array, the array should consist of four values (left, bottom, right, top). The minimum extent for the map. Defaults to null.
restrictedExtent{<OpenLayers.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.
numZoomLevels{Integer} Number of zoom levels for the map. Defaults to 16. Set a different value in the map options if needed.
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.
displayProjection{OpenLayers.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.
fallThrough{Boolean} Should OpenLayers allow events on the map to fall through to other elements on the page, or should it swallow them? (#457) Default is to fall through.
panTween{OpenLayers.Tween} Animated panning tween object, see panTo()
eventListeners{Object} If set as an option at construction, the eventListeners object will be registered with OpenLayers.Events.on. Object structure must be a listeners object as shown in the example for the events.on method.
panMethod{Function} The Easing function to be used for tweening. Default is OpenLayers.Easing.Expo.easeOut. Setting this to ‘null’ turns off animated panning.
panDuration{Integer} The number of steps to be passed to the OpenLayers.Tween.start() method when the map is panned. Default is 50.
paddingForPopups{OpenLayers.Bounds} Outside margin of the popup. Used to prevent the popup from getting too close to the map border.
minPx{Object} An object with a ‘x’ and ‘y’ values that is the lower left of maxExtent in viewport pixel space. Used to verify in moveByPx that the new location we’re moving to is valid. It is also used in the getLonLatFromViewPortPx function of Layer.
maxPx{Object} An object with a ‘x’ and ‘y’ values that is the top right of maxExtent in viewport pixel space. Used to verify in moveByPx that the new location we’re moving to is valid.
Constructor
OpenLayers.MapConstructor for a new OpenLayers.Map instance. There are two possible ways to call the map constructor. See the examples below.Parametersdiv{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.Valid options (in addition to the listed API properties)center{<OpenLayers.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{<OpenLayers.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.Examples// create a map with default options in an element with the id "map1"
var map = new OpenLayers.Map("map1");
// create a map with non-default options in an element with id "map2"
var options = {
projection: "EPSG:3857",
maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000),
center: new OpenLayers.LonLat(-12356463.476333, 5621521.4854095)
};
var map = new OpenLayers.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 OpenLayers.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 OpenLayers.Map({
projection: "EPSG:3857",
maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000)
});
Functions
getViewportgetViewport: function()Get the DOMElement representing the view port.Returns{DOMElement}
renderrender: function(div)Render the map to a specified container.Parametersdiv{String|DOMElement} The container that the map should be rendered to. If different than the current container, the map viewport will be moved from the current to the new container.
unloadDestroyFunction that is called to destroy the map on page unload. stored here so that if map is manually destroyed, we can unregister this.
updateSizeDestroyWhen 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.
destroydestroy: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.
Wyszukiwarka
Podobne podstrony:
Map jsmap script js sourcemap script js sourcemap script jsUtil jsbrowse mapjs zegarek na wwwmap settingsAnimation jsview mapFormat jsAndorra mountain mapmap settingsnazwy map do left 4 dead 2livehelp jswięcej podobnych podstron