User location as initial region
Closed this issue · 2 comments
minuitagency commented
Hi,
We are trying to use the user's position as initial region, but when we pass a state to the props "initial region" the map goes to geolocation [0,0].
Any idea?
Thanks,
Théo
DanGDroid commented
Hi, @AideProjet
try to use the map action by its ref: this.map.getMapRef().animateToRegion(region, duration)
fire it up once when you receive the users position/ or when ever you want to change map location programmatically and not by map interface
ex:
<ClusteredMapView
style={styles.map}
ref={ref => { this.map = ref; }}
...
/>
if(this.map){
this.map.getMapRef().animateToRegion(region, durationInMilli);
}
region object:
{
longitude:position.longitude,
latitude:position.latitude,
latitudeDelta:position.latitudeDelta || DEFAULT_LATITUDE_DELTA,
longitudeDelta:position.longitudeDelta || DEFAULT_LONGITUDE_DELTA
}
39otrebla commented
@AideProjet initialRegion
works as expected, I'd look into data structure/format you are passing down. Closing.