4、map类和Navigation类小结
Map类:
1、概述:
esri.Map类是一种容器,其中可以放置layer(图层),Graphic(),infowindow(动态信息窗口)。
其在网页中可以加载到DIV中,其高度宽度位置等有DIV决定。
其方法事件map.onload在第一个图层加载完成后激发,因此,onloadhandler事件经常用来初始化map的一些参数和加载图层。
2、引用方式为:esri.Map(divID,options?)
divID为显示地图的层的ID;
options为地图相关参数设置,主要的参数设置有:
(1)bool displayGraphicsOnPan:设置地图浏览时是否显示图形,设置为false可以提高运行效率和效果;
使用方法:
var myMap = new esri.Map("mapDiv", { displayGraphicsOnPan:false });
(2)<Extent> extent:设置地图的显示范围;
使用方法:
var myMap = new esri.Map("mapDiv", { extent: new esri.geometry.Extent(-124.71, 31.89, -113.97, 42.63) });
(3)<Object> layer:用来加载图层,初始化地图。格式为:{type, url}
(4)<LOD[]> lods:待研究
(5)<Boolean> nav:地图可以pan,默认为True
(6)<Boolean> showInfoWindowOnClick:当Graphic有InfoTemplate时,单击Graphics就会出现InfoWindow,默认为:true
(7)<Boolean> slider:控制放大缩小滑块的显示,默认为True
var myMap = new esri.Map("mapDiv", { slider:false, nav:false });
3、属性:
Property |
Type |
Description |
The current extent of the map in map units. This property is read-only. | ||
Add and remove graphics from the GraphicsLayer. | ||
Number |
Current height of the map in screen pixels. | |
String |
Reference to HTML DIV or other element where the map is placed on the page. This property is set in the Map constructor. | |
Displays the InfoWindow on a map. | ||
Boolean |
When true, the key sequence of shift then click to recenter the map is enabled. | |
Boolean |
When true, double click zoom is enabled. This allows a user to zoom and recenter the map by double clicking the mouse. | |
Boolean |
When true, keyboard navigation is enabled. This allows users to pan the keyboard using the arrow keys and to zoom using the + and - keys. | |
Boolean |
When true, map panning is enabled using the mouse. | |
Boolean |
When true, pan arrows are displayed around the edge of the map. | |
Boolean |
When true, rubberband zoom is enabled. This allows users to draw a bounding box zoom area using the mouse. | |
Boolean |
When true, the mouse scroll wheel zoom is enabled. | |
Boolean |
When true, shift double click zoom is enabled. This allows a user to zoom and recenter the map by shift + double clicking the mouse. | |
Boolean |
When true, the zoom slider is displayed on the map. | |
String[] |
Array of current layers added to the map. There is always a default Graphics layer added to the map. | |
Boolean |
After the first layer is loaded, the value is set to true. | |
This point geometry in screen coordinates represent the top-left corner of the map container. This coordinate also acts as the origin for all screen coordinates returned by Map and GraphicsLayer events. | ||
The spatial reference of the map. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references. | ||
Number |
Current width of the map in screen pixels. |
4、方法:
Method |
Return Value |
Description |
none |
Adds an ESRI Layer to the map.添加图层到地图中,index表示加入图层的位置。 | |
String |
Sets an InfoWindow's anchor when calling InfoWindow.show. 获取InfoWindow的位置。 screenCoords为<point>类型 | |
Returns an individual layer of a map. 获取位置为id的图层 | ||
Number |
Gets the current level of detail ID for the map. Valid only with an ArcGISTiledMapService layer. | |
none |
Removes all layers from the map. 删除后,保留投影等信息。 | |
none |
Removes the specified layer from the map.删除指定的图层 | |
none |
Changes the layer order in the map.重新为图层排序,layerId为当前图层ID,index为要移动到的位置 | |
none |
Repositions the map DIV on the page. This method should be used after the map DIV has been repositioned. 改变DIV的位置 | |
none |
Resizes the map DIV. This method should be used after the map DIV has been resized.改变DIV的大小 | |
none |
Sets the extent of the map. The extent must be in the same spatial reference as the map. 设置显示范围,fit是布尔型的,当为true时要使tiled类型的图层在map上全部显示 | |
none |
Sets the map to the specified level ID. Zooms to the new level based on the current map center point. Valid only with an ArcGISTiledMapService layer. | |
Converts a single screen point or an array of screen points to map coordinates. !!此方法很重要,用于将屏幕坐标转为地图坐标! | ||
Converts a single map point or an array of map points to screen coordinates. 与toMap相反,其将地图坐标转变为屏幕坐标 |
5、Map navigation 地图浏览导航
Method |
Return Value |
Description |
none |
Centers and zooms the map. | |
none |
Recenters the map based on map coordinates as the center point. | |
none |
Disallows clicking on a map to recenter it. | |
none |
Disallows double clicking on a map to zoom in a level and recenter the map. | |
none |
Disallows all map navigation except the slider and pan arrows. | |
none |
Disallows panning a map using the mouse. | |
none |
Disallows zooming in or out on a map using a bounding box. | |
none |
Disallows zooming in or out on a map using the mouse scroll wheel. | |
none |
Disallows shift double clicking on a map to zoom in a level and recenter the map. | |
none |
Disallows panning and zooming using the keyboard. | |
none |
Permits users to click on a map to recenter it. | |
none |
Permits users to double click on a map to zoom in a level and recenter the map. | |
none |
Permits users to pan and zoom using the keyboard. | |
none |
Allows all map navigation. | |
none |
Permits users to pan a map using the mouse. | |
none |
Permits users to zoom in or out on a map using a bounding box. | |
none |
Permits users to zoom in or out on a map using the mouse scroll wheel. | |
none |
Permits users to shift double click on a map to zoom in a level and recenter the map. | |
none |
Hides the pan arrows from the map. | |
none |
Hides the zoom slider from the map. | |
none |
Pans the map south. | |
none |
Pans the map west. | |
none |
Pans the map southwest. | |
none |
Pans the map southeast. | |
none |
Pans the map east. | |
none |
Pans the map north. | |
none |
Pans the map northwest. | |
none |
Pans the map northeast. | |
none |
Shows the pan arrows on the map. | |
none |
Shows the zoom slider on the map. |
5、Events事件列表以及功能
Event |
Description |
Fires when a user single clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. | |
Fires when a user double clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. | |
Fires when the extent of the map has changed. | |
Fires when a keyboard key is pressed. | |
Fires when a keyboard key is released. | |
Fires any time a layer is added to the map. | |
Fires after the layer has been removed. | |
Fires when the map layer order has been changed. | |
Fires after all the layers have been removed. | |
Fires when all the layers have been reordered. | |
Fires when the first or base layer has been successfully added to the map. | |
Fires when a mouse button is pressed down and the mouse cursor is in the map region of the HTML page. | |
Fires while the mouse is being dragged until the mouse button is released. | |
Fires when a mouse button is released and the user stops dragging the mouse. | |
Fires when a mouse button is pressed down and the user starts to drag the mouse. | |
Fires any time the mouse pointer moves over the map region. A common use for this event is to show the current x,y coordinate of the map as the user moves the mouse pointer. | |
Fires when the mouse moves out of the map region of the HTML page. | |
Fires when the mouse moves into the map region of the HTML page. | |
Fires when the mouse button is released and the mouse pointer is within the map region of the HTML page. | |
Fires when the mouse wheel is scrolled. | |
Fires during the pan process. | |
Fires when the pan is complete. | |
Fires when a user commences panning. | |
Fires when the map DIV is repositioned. | |
Fires when the Div containing the map has been resized. | |
Fires when the page is refreshed. | |
Fires during the zoom process. | |
Fires when the zoom is complete. | |
Fires when a user commences zooming. |
Navigation类:
1、 概述:其中主要有的功能为对地图的浏览(放大、缩小等)
2、 引用方法:esri.toolbars.Navigation(map) ,map为控件的名称!
3、 常量:
ZOON_IN:放大地图
ZOOM_OUT:缩小地图
PAN:平移
4、 方法:
Method |
Return Value |
Description |
none |
Activates the toolbar for map navigation. Activating the toolbar overrides default map navigation. 设定Navigation的当前浏览工具;如 navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT) 设定Navigation的当前工具为放大 | |
none |
Deactivates the toolbar and reactivates map navigation. | |
Boolean |
When "true", map is at the first extent. 判断是否为第一个视图 | |
Boolean |
When "true", map is at the last extent. 判断是否为最后一个视图 | |
none |
Zoom to full extent of base layer. 全图显示地图 | |
none |
Zoom to next extent in extent history.下一视图 | |
none |
Zoom to previous extent in extent history. 上一视图 |
5、 事件:
onExtentHistoryChange(),当视图历史变化时激发该事件!
至此两类的全部属性、事件等都罗列说明到此!!!