0

I am using React-Native's Location.getCurrentPositionAsync() to retrieve a user's location when they arrive at a site and also when they depart from the site. However, even though the user is in the exact same location the geolocation data is different.

I am using BingMaps to pull the address and a map of the location and the address is sometimes several blocks away from the user's actual location. I set the location accuracy to LocationAccuracy.Highest but still get some odd results.

Any help fixing this is much appreciated!

`

export async function GetPosition() {
       
        let { status } = await Location.requestForegroundPermissionsAsync();
        if (status !== 'granted') {
          console.log('Permission to access location was denied');
          return;
        }
  
        
        return new Promise((resolve, reject) => {
        Location.getCurrentPositionAsync({accuracy:LocationAccuracy.Highest}).then(pos => {
        console.log(pos); resolve(getCoordsFromPosition(pos));
        }, reject);
        });

    }

`

`

function getCoordsFromPosition(position) {
    const coords = position.coords;
    return coords;
}

`

function getAddressByPoint(address) {
        const name = address.resourceSets[0].resources[0].name;
        return name;
     
}

`

export async function FindLocationByPoint (latitude, longitude) {
    return new Promise(async (resolve, reject) => {
    await fetch("https://dev.virtualearth.net/REST/v1/Locations/"+ latitude + "," + longitude + "?key=" + bing_maps_key, {
    method: 'GET', 
    headers: new Headers({
        Accept: 'application/json'
        }), 
    }).then(res => res.json()).then(data => {
        console.log(data);
        resolve(getAddressByPoint(data));
    }, reject)
    });
}

`

`

var startPos = await GetPosition().then((res) => startPos = res);
var startLoc = await FindLocationByPoint(startPos.latitude, startPos.longitude).then((data) => startLoc = data);

var stopPos = await GetPosition().then((res) => stopPos = res);
var stopLoc = await FindLocationByPoint(stopPos.latitude, stopPos.longitude).then((data) => stopLoc = data);

`

I tried setting location accuracy to the highest setting and expected accuracy within a few addresses but I am getting addresses several blocks away

1 Answer 1

0

In this scenario that are a couple of things that contribute to this situation:

  1. Location sensor accuracy. The coordinates returned from the getCurrentPositionAsync and the highest setting is dependent on the sensors available on the end device (both physically, and connection at the time). GPS accuracy typically has an accuracy of 15 meters. While cell tower triangulation can is between 0.5KM and 1.5KM.
  2. Reverse geocoders return an approximate address for a coordinate. The address accuracy is 100% dependent on the level of accuracy of the location data for the area the user is in. Most address location data in the word is approximated based on building number, and address ranges between "city blocks". For example, if a section of road has an address range of 1 and 100, a building with number 50 would be estimated to be positioned in the middle of that road section, but in reality, that may not be the case. In some parts of the world, "rooftop" accurate data is available. This type of data has a high accurate position for buildings (gathered either manually or through AI on street level imagery). Details on geographic coverage levels in Bing maps can be found here: https://learn.microsoft.com/en-us/bingmaps/coverage/geographic-coverage
Sign up to request clarification or add additional context in comments.

1 Comment

thanks it says there is rooftop level accuracy in my country but I guess the data is sometimes inaccurate due to the reasons you listed. I'm trying to create a loop that keeps checking until the accuracy of the results is under a threshold but its not working. Either way I think I'm going in the right direction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.