4、map类和Navigation类小结

 

Map类:

1、概述:

esri.Map类是一种容器,其中可以放置layer(图层),Graphic(),infowindow(动态信息窗口)。

其在网页中可以加载到DIV中,其高度宽度位置等有DIV决定。

其方法事件map.onload在第一个图层加载完成后激发,因此,onloadhandler事件经常用来初始化map的一些参数和加载图层。

2、引用方式为:esri.Map(divID,options?)

   divID为显示地图的层的ID

options为地图相关参数设置,主要的参数设置有:

1bool 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:当GraphicInfoTemplate时,单击Graphics就会出现InfoWindow,默认为:true
7<Boolean> slider:控制放大缩小滑块的显示,默认为True
var myMap = new esri.Map("mapDiv", { slider:false, nav:false });
3、属性:

Property

Type

Description

extent

Extent

The current extent of the map in map units. This property is read-only.

graphics

GraphicsLayer

Add and remove graphics from the GraphicsLayer.

height

Number

Current height of the map in screen pixels.

id

String

Reference to HTML DIV or other element where the map is placed on the page. This property is set in the Map constructor.

infoWindow

InfoWindow

Displays the InfoWindow on a map.

isClickRecenter

Boolean

When true, the key sequence of shift then click to recenter the map is enabled.

isDoubleClickZoom

Boolean

When true, double click zoom is enabled. This allows a user to zoom and recenter the map by double clicking the mouse.

isKeyboardNavigation

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.

isPan

Boolean

When true, map panning is enabled using the mouse.

isPanArrows

Boolean

When true, pan arrows are displayed around the edge of the map.

isRubberBandZoom

Boolean

When true, rubberband zoom is enabled. This allows users to draw a bounding box zoom area using the mouse.

isScrollWheelZoom

Boolean

When true, the mouse scroll wheel zoom is enabled.

isShiftDoubleClickZoom

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.

isZoomSlider

Boolean

When true, the zoom slider is displayed on the map.

layerIds

String[]

Array of current layers added to the map. There is always a default Graphics layer added to the map.

loaded

Boolean

After the first layer is loaded, the value is set to true.

position

Point

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.

spatialReference

SpatialReference

The spatial reference of the map. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.

width

Number

Current width of the map in screen pixels.

 
4、方法:

Method

Return Value

Description

addLayer(layer, index?)

none

Adds an ESRI Layer to the map.添加图层到地图中,index表示加入图层的位置。

getInfoWindowAnchor(screenCoords)

String

Sets an InfoWindow's anchor when calling InfoWindow.show.

获取InfoWindow的位置。

screenCoords<point>类型

getLayer(id)

Layer

Returns an individual layer of a map.

获取位置为id的图层

getLevel()

Number

Gets the current level of detail ID for the map. Valid only with an ArcGISTiledMapService layer.

removeAllLayers()

none

Removes all layers from the map.
The map's extent, spatial reference, and tiling scheme if defined do not change when the layers are removed. When the next layer is added to the map, this layer is displayed at the same extent and spatial reference.

删除后,保留投影等信息。

removeLayer(layer)

none

Removes the specified layer from the map.删除指定的图层

reorderLayer(layerId, index)

none

Changes the layer order in the map.重新为图层排序,layerId为当前图层IDindex为要移动到的位置

reposition()

none

Repositions the map DIV on the page. This method should be used after the map DIV has been repositioned.

改变DIV的位置

resize()

none

Resizes the map DIV. This method should be used after the map DIV has been resized.改变DIV的大小

setExtent(extent, fit?)

none

Sets the extent of the map. The extent must be in the same spatial reference as the map.

设置显示范围,fit是布尔型的,当为true时要使tiled类型的图层在map上全部显示

setLevel(level)

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.

toMap(screenPoint)

Point

Converts a single screen point or an array of screen points to map coordinates.

!!此方法很重要,用于将屏幕坐标转为地图坐标!

toScreen(mapPoint)

Point

Converts a single map point or an array of map points to screen coordinates.

toMap相反,其将地图坐标转变为屏幕坐标

5Map navigation 地图浏览导航

Method

Return Value

Description

centerAndZoom(mapPoint, levelOrFactor)

none

Centers and zooms the map.

centerAt(mapPoint)

none

Recenters the map based on map coordinates as the center point.

disableClickRecenter()

none

Disallows clicking on a map to recenter it.

disableDoubleClickZoom()

none

Disallows double clicking on a map to zoom in a level and recenter the map.

disableMapNavigation()

none

Disallows all map navigation except the slider and pan arrows.

disablePan()

none

Disallows panning a map using the mouse.

disableRubberBandZoom()

none

Disallows zooming in or out on a map using a bounding box.

disableScrollWheelZoom()

none

Disallows zooming in or out on a map using the mouse scroll wheel.

disableShiftDoubleClickZoom()

none

Disallows shift double clicking on a map to zoom in a level and recenter the map.

disbleKeyboardNavigation()

none

Disallows panning and zooming using the keyboard.

enableClickRecenter()

none

Permits users to click on a map to recenter it.

enableDoubleClickZoom()

none

Permits users to double click on a map to zoom in a level and recenter the map.

enableKeyboardNavigation()

none

Permits users to pan and zoom using the keyboard.

enableMapNavigation()

none

Allows all map navigation.

enablePan()

none

Permits users to pan a map using the mouse.

enableRubberBandZoom()

none

Permits users to zoom in or out on a map using a bounding box.

enableScrollWheelZoom()

none

Permits users to zoom in or out on a map using the mouse scroll wheel.

enableShiftDoubleClickZoom()

none

Permits users to shift double click on a map to zoom in a level and recenter the map.

hidePanArrows()

none

Hides the pan arrows from the map.

hideZoomSlider()

none

Hides the zoom slider from the map.

panDown()

none

Pans the map south.

panLeft()

none

Pans the map west.

panLowerLeft()

none

Pans the map southwest.

panLowerRight()

none

Pans the map southeast.

panRight()

none

Pans the map east.

panUp()

none

Pans the map north.

panUpperLeft()

none

Pans the map northwest.

panUpperRight()

none

Pans the map northeast.

showPanArrows()

none

Shows the pan arrows on the map.

showZoomSlider()

none

Shows the zoom slider on the map.

5Events事件列表以及功能

Event

Description

onClick(event)

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.

onDblClick(event)

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.

onExtentChange(extent, delta, levelChange, lod)

Fires when the extent of the map has changed.

onKeyDown(keyEvent)

Fires when a keyboard key is pressed.

onKeyUp(keyEvent)

Fires when a keyboard key is released.

onLayerAdd(layer)

Fires any time a layer is added to the map.

onLayerRemove(layer)

Fires after the layer has been removed.

onLayerReorder(layer, index)

Fires when the map layer order has been changed.

onLayersRemoved()

Fires after all the layers have been removed.

onLayersReordered(layerIds)

Fires when all the layers have been reordered.

onLoad(map)

Fires when the first or base layer has been successfully added to the map.

onMouseDown(event)

Fires when a mouse button is pressed down and the mouse cursor is in the map region of the HTML page.

onMouseDrag(event)

Fires while the mouse is being dragged until the mouse button is released.

onMouseDragEnd(event)

Fires when a mouse button is released and the user stops dragging the mouse.

onMouseDragStart(event)

Fires when a mouse button is pressed down and the user starts to drag the mouse.

onMouseMove(event)

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.

onMouseOut(event)

Fires when the mouse moves out of the map region of the HTML page.

onMouseOver(event)

Fires when the mouse moves into the map region of the HTML page.

onMouseUp(event)

Fires when the mouse button is released and the mouse pointer is within the map region of the HTML page.

onMouseWheel(event)

Fires when the mouse wheel is scrolled.

onPan(extent, delta)

Fires during the pan process.

onPanEnd(extent, endPoint)

Fires when the pan is complete.

onPanStart(extent, startPoint)

Fires when a user commences panning.

onReposition(x, y)

Fires when the map DIV is repositioned.

onResize(extent, height, width)

Fires when the Div containing the map has been resized.

onUnload(map)

Fires when the page is refreshed.

onZoom(extent, zoomFactor, anchor)

Fires during the zoom process.

onZoomEnd(extent, zoomFactor, anchor, level)

Fires when the zoom is complete.

onZoomStart(extent, zoomFactor, anchor, level)

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

activate(navType)

none

Activates the toolbar for map navigation. Activating the toolbar overrides default map navigation.

设定Navigation的当前浏览工具;如    navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT)

设定Navigation的当前工具为放大

deactivate()

none

Deactivates the toolbar and reactivates map navigation.

isFirstExtent()

Boolean

When "true", map is at the first extent.

判断是否为第一个视图

isLastExtent()

Boolean

When "true", map is at the last extent.

判断是否为最后一个视图

zoomToFullExtent()

none

Zoom to full extent of base layer.

全图显示地图

zoomToNextExtent()

none

Zoom to next extent in extent history.下一视图

zoomToPrevExtent()

none

Zoom to previous extent in extent history.

上一视图

5、  事件:
onExtentHistoryChange(),当视图历史变化时激发该事件!
 
 
 
 
至此两类的全部属性、事件等都罗列说明到此!!!
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值