मेरे पास एक ऐप है जो एपीआई को कॉल करता है और स्थानों की एक सूची देता है।मानचित्र की सीमाएं सेट करें
डेटा लौटाए जाने के बाद, मैं जेएसओएन एनोटेशन के लिए मानचित्र बिंदुओं में परिवर्तित करता हूं।
ये एमए में कोई समस्या नहीं है।
जिस समस्या में मैं चल रहा हूं वह मानचित्र की सीमा निर्धारित कर रहा है। मैं इसे समझने के लिए प्रतीत नहीं कर सकता।
मेरे पास वर्तमान में कोड है।
_handleResponse(response) {
var locations = [];
// Loop through repsone and add items to an arra for annotations
for (var i = 0; i < response.length; i++) {
// Get the location
var location = response[i];
// Parse the co ords
var lat = parseFloat(location.Latitude);
var lng = parseFloat(location.Longitude);
// Add the location to array
locations.push({
latitude: lat,
longitude: lng,
title: location.Name
});
}
// This calls the map set state
this.setState({
annotations: locations
});
}
और यहाँ आप
<MapView
...
region={region}
/>
चाहता हूँ जहाँ
var region = {
latitude,
longitude,
latitudeDelta,
longitudeDelta,
};
latitude
और longitude
मानचित्र और के केंद्र रहे हैं मेरे विचार कोड
<View style={styles.container}>
<MapView
style={styles.map}
onRegionChangeComplete={this._onRegionChangeComplete}
annotations={this.state.annotations}
/>
</View>