地图
<Amap>
<!-- 覆盖物 -->
</Amap>
Props
属性名 | 类型 | 备注 |
---|---|---|
center | number[2] | |
zoom | number | |
rotation | number | |
pitch | number | |
viewMode | '2D', '3D' | |
features | string[] | |
zooms | number[2] | |
dragEnable | boolean | |
zoomEnable | boolean | |
jogEnable | boolean | |
pitchEnable | boolean | |
rotateEnable | boolean | |
animateEnable | boolean | |
keyboardEnable | boolean | |
doubleClickZoom | boolean | |
scrollWheel | boolean | |
touchZoom | boolean | |
touchZoomCenter | boolean | |
showLabel | boolean | |
defaultCursor | string | |
isHotspot | boolean | |
mapStyle | string | |
wallColor | string | |
roofColor | string | |
skyColor | string | |
showBuildingBlock | boolean | |
showIndoorMap | boolean | |
mask | number[][], number[][][] |
Events
事件名 | 备注 |
---|---|
complete | |
click | |
dblclick | |
rightclick | |
mapmove | |
movestart | |
moveend | |
hotspotclick | |
hotspotover | |
hotspotout | |
mousemove | |
mousewheel | |
mouseover | |
mouseup | |
mousedown | |
zoomchange | |
zoomstart | |
zoomend | |
dragstart | |
dragging | |
dragend | |
resize | |
touchstart | |
touchmove | |
touchend |
Amap.AmapContext
当你需要开发自定义扩展组件时,可以在子组件里使用Context
来获取组件树上父级或祖先级的AMap.Map
实例。
<AmapContext.Consumer>
{(map) => {
// map: AMap.Map | undefined
}}
</AmapContext.Consumer>
如果你使用的Functional Component
和 React Hooks,推荐使用useAmap()
。
Example
查看源代码: