你需要
"centroid": {
"latitude": "24.2472",
"longitude": "89.920914"
},
"boundingBox": {
"southWest": {
"latitude": "24.234631",
"longitude": "89.907127"
},
"northEast": {
"latitude": "24.259769",
"longitude": "89.934692"
}
}
或者类似的数据来正确计算latitudeDelta和longitudeDelta .
下面是react / react-native的演示代码 .
componentDidMount() {
const { width, height } = Dimensions.get('window');
const ASPECT_RATIO = width / height;
const lat = parseFloat(centroid.latitude);
const lng = parseFloat(centroid.longitude);
const northeastLat = parseFloat(boundingBox.northEast.latitude);
const southwestLat = parseFloat(boundingBox.southWest.latitude);
const latDelta = northeastLat - southwestLat;
const lngDelta = latDelta * ASPECT_RATIO;
this.setState({
region: {
latitude: lat,
longitude: lng,
latitudeDelta: latDelta,
longitudeDelta: lngDelta
}
})
}