Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

364
Views
Why React native map initialRegion is not working?

enter image description here

When I present my map it never loads the initRegion somewhy, it always starts with the african region. The loading that is visible in the gif is coming from an API call, and I stop it when the get request was succesfull.

Heres my code:

const [mapRegion, setMapRegion] = useState(null);

    const getLocation = async ()=>{
      let { status } = await Location.requestForegroundPermissionsAsync();
      if (status !== 'granted') {
        Alert.alert(
          'Whoops!',
          'Az alkalmazás nem kapott hely információ engedélyt. Ezt könnyen orvosolhatod telefonod beállításiban. \n\nSzeretnéd most bekapcsolni?',
          [
            {text: 'Igen', onPress: () => openSettings()},
            {text: 'Nem', style: 'cancel'},
          ],
          { cancelable: true }
        )
        return;
      }

      let location = await Location.getCurrentPositionAsync({accuracy: Location.Accuracy.Highest, maximumAge: 10000}); //accuracy: Location.Accuracy.Highest, maximumAge: 10000
      setUserPosition(location);

      let mapRegion = {
        latitude:location.coords.latitude,
        longitude:location.coords.longitude,
        latitudeDelta: .01,
        longitudeDelta: .01}

      setMapRegion(mapRegion)
    }

    useEffect(() => {
      getLocation()
    }, []);
 return(  


    <View style={styles.container}>
        <MapView style={styles.map}
        provider={PROVIDER_GOOGLE}
        region={mapRegion}
        initialRegion={{latitude:47.090417,longitude:19.234115,latitudeDelta: 5,longitudeDelta: 5}}
        showsUserLocation={true}
        showsCompass={true}
        >
        </MapView>
</View>
)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Turns out if you use some kind of loading in your code, then initRegion does not work: Before:

if(loading){
return(
<LoadingScreen/>
)}
else{
return(
<Mapview
initRegion
/>
)}

After:

return(
<View style={...}>
{loading ? <LoadingScreen/> : null}

<Mapview
initRegion={coords}
/>
<View/>
)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!