Map js


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}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). layers{Array(OpenLayers.Layer)} Ordered list of layers in the mapcontrols{Array(OpenLayers.Control)} List of controls associated with the map.baseLayer{OpenLayers.Layer} The currently selected base layer. 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?  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. ConstructorOpenLayers.MapConstructor for a new OpenLayers.Map instance. FunctionsgetViewportGet the DOMElement representing the view port.renderRender the map to a specified container.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 idaddLayeraddLayersremoveLayerRemoves 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. getControlremoveControlRemove 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)getCenter{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).getProjectionThis 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 scalegetViewPortPxFromLonLatgetLonLatFromPixelgetPixelFromLonLatReturns a pixel location given a map location. getViewPortPxFromLayerPxgetLayerPxFromViewPortPxgetLayerPxFromLonLatConstantsTILE_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 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. 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 baseLayer{OpenLayers.Layer} The currently selected base layer.  This determines min/max zoom level, projection, etc. 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. 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. 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. 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 js
map script js source
map script js source
map script js
Util js
browse map
js zegarek na www
map settings
Animation js
view map
Format js
Andorra mountain map
map settings
nazwy map do left 4 dead 2
livehelp js

więcej podobnych podstron