annotations [{latitude: number, longitude: number, animateDrop: bool, title: string, subtitle: string, hasLeftCallout: bool, hasRightCallout: bool, onLeftCalloutPress: function, onRightCalloutPress: function, id: string}]
地图上的标注点,可以带有标题及副标题。
legalLabelInsets {top: number, left: number, bottom: number, right: number}
地图上标签的合法范围。默认在地图底部左侧。参见EdgeInsetsPropType.js
了解更多信息。
mapType enum('standard', 'satellite', 'hybrid')
要显示的地图类型。
- standard: 标准道路地图(默认)。
- satellite: 卫星视图。
- hybrid: 卫星视图并附带道路和感兴趣的点标记。
maxDelta number
可以被显示的最大区域尺寸。
minDelta number
可以被显示的最小区域尺寸。
overlays [{coordinates: [{latitude: number, longitude: number}], lineWidth: number, strokeColor: ColorPropType, fillColor: ColorPropType, id: string}]
地图的覆盖层。
region {latitude: number, longitude: number, latitudeDelta: number, longitudeDelta: number}
地图显示的区域。
区域使用中心的坐标和要显示的范围来定义。
rotateEnabled bool
当此属性设为true
并且地图上关联了一个有效的镜头时,镜头的朝向角度会用于基于中心点旋转地图平面。当此属性设置为false
时,朝向角度会被忽略,并且地图永远都显示为顶部方向为正北方。
showsUserLocation bool
如果此属性为true
,应用会请求用户当前的位置并且聚焦到该位置。默认值是false
。
注意:你需要在Info.plist中增加NSLocationWhenInUseUsageDescription字段。否则它会没有任何提示而直接失败!
style View#style
active bool
showsCompass bool
如果此属性为false
,地图上不会显示指南针。默认值为true
。
showsPointsOfInterest bool
如果此属性为false
,感兴趣的点不会在地图上显示。默认为true
。
'use strict';
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
MapView,
} from 'react-native'
const styles=StyleSheet.create({
map:{
marginTop:64,
height:350,
margin:10,
borderWidth:1,
borderColor:'#000000',
}
});
class testMapView extends Component {
render(){
return(
<MapView
style={styles.map}
onRegionChangeComplete={()=>{}}
region={{
latitude: 40.027737,
longitude:116.403694,
latitudeDelta: 1,
longitudeDelta: 0.5,
}}
annotations={[{
longitude: 116.403694,
latitude: 40.027737,
title: 'I am Here!',
}]}
/>
);
}
}
AppRegistry.registerComponent('TestMapView', () => testMapView);