Saj*_*ith 2 react-native react-android react-native-maps
我已将反应本机地图与最新的反应本机应用程序集成。在地图中,我想设置地图的边界。官方文档建议了该方法
setMapBoundaries ,但需要这样的论证northEast: LatLng, southWest: LatLng 。
我怎样才能获得这些参数的值。我的mapView是这样的。
<MapView
showsUserLocation
provider={MapView.PROVIDER_GOOGLE}
style={styles.map}
region={region}
onRegionChangeComplete={this.onRegionChangeComplete}
setMapBoundaries={}
onUserLocationChange={this.onUserLocationChange}
>
Run Code Online (Sandbox Code Playgroud)
您尝试使用的不是propertyor event,而是 a method。所以你不能在那里使用它。再次检查文档。
setMapBoundaries(northEast: LatLng, southWest: LatLng): void;
export interface LatLng {
latitude: number;
longitude: number;
}
Run Code Online (Sandbox Code Playgroud)
尝试获取refMapView的,
<MapView
ref={(ref)=> this.mapRef = ref}
/>
Run Code Online (Sandbox Code Playgroud)
并调用该方法setMapBoundaries
this.mapRef.setMapBoundaries({latitude: 1, longitude: 1},{latitude: 1, longitude: 1})
| 归档时间: |
|
| 查看次数: |
4095 次 |
| 最近记录: |