How do I allow users to adjust location data?

Data:

  • Location (from current location)

Task:
I want to adjust this location if it isn’t 100% accurate.

Question:
How do I do this?

How do you picture users adjusting the location? You can manually edit the coordinates, but it’s not very user friendly.

1 Like

I’m trying to think of the UX and UI of doing this in another app.
You could enter an address an the field looks up the actual address and you select it.
Or I guess you could drop a pin on a map.

I’m assuming that both are overkill for what I’m trying to achieve.

The goal is to accurately and also quickly record the location of a car accident.

Got it. Can’t really think of any good solutions that are user friendly. Ideally the map component would allow us to drop a pin on the map.

Other options would be to use a separate mapping app, get coordinates from that app, and paste them into glide. Still not great though.

This is all assuming that using street addresses would not always be convenient or known. I’m just thinking of an accident that might happen in a rural area or nowhere near posted addresses.

You can check out this post by @Robert_Petitto which demonstrates some integrations that might be useful to you. Maybe they could be useful.

@Jeff_Hager
I become curious, what if in the case of an accident in rural areas we use Google’s “Plus Code”? Is this also supported by Mapbox?

Did a quick test, and it doesn’t appear that Mapbox properly recognizes google plus codes.

2 Likes

Here I share a Google map that uses a plus code. Quite interesting, for example: https://plus.codes/6PH57VP3+PR. Take 4 characters from the code and add an approximate location, such as a city, state, or country. The above example then becomes “7VP3+PR6 Singapore”.
Another interesting thing about this map is that we can move the location to find its code.

Then, how to convert between coordinates and plus codes can be read at Open Location Code - Wikipedia. I’m not very familiar with this part, maybe you know how, Jeff?

Note: This Google map can be embedded with web embeds, and it’s free.

1 Like

I’ll take a closer look later, but at initial glance it looks like it’s easy to decode and encode the long form plus codes to and from coordinates, but the problem I see is that google maps appears to share the short form plus code that includes the city name, which can’t be fully decoded into a set of coordinates on its own. You have to first use a google API, just to geocode a city into it’s 4 digit plus code, and then append it to the rest of the plus code, just to turn around and decode it into a set of useable coordinates.

It’s just as easy, if not easier, to simply grab the coordinates from google maps instead, so I really don’t see much of a benefit to first having to track down the long form plus code, and then add the extra step to decode it into coordinates when you can directly grab the coordinates.

If you look at my screenshot, this is from google maps on my phone. It shows me coordinates as well as the plus code, but the plus code is the short form which can’t be decoded on it’s own without first figuring out the encoding for the city location. Not enough information to pull out coordinates without involving a third party service. The coordinates are right there above it, don’t require any decoding, and are universally recognized, so I would be using those before anything else.

While it’s true that you can embed a google map, web embeds are sandboxed from the rest of the app, so it still becomes difficult or not as user friendly to transfer data between the web embed and the app itself. Closest option is copy/paste, which is not quite as convenient as dropping a pin and having the coordinates automatically save into your data table. Although it would save a step of having to open a separate app.

2 Likes

This is the result of struggling with GPT:

function convertToOpenLocationCode(lat, long) {
    let newLat = lat + 90;
    let newLong = long + 180;

    newLat *= 8000;
    newLong *= 8000;

    let base20Lat = convertToBase20(Math.floor(newLat));
    let base20Long = convertToBase20(Math.floor(newLong));

    let plusCode = insertCharacters(base20Lat, base20Long);

    return plusCode;
}

function convertToBase20(num) {
    const alphabet = '23456789CFGHJMPQRVWX';
    let result = '';

    while (num > 0) {
        let remainder = num % 20;
        result = alphabet[remainder] + result;
        num = Math.floor(num / 20);
    }

    while (result.length < 5) {
        result = '2' + result;
    }

    return result;
}

function insertCharacters(base20Lat, base20Long) {
    let result = '';
    let latIndex = 0;
    let longIndex = 0;
    for (let i = 0; i < 8; i++) {
        if (i === 4) {
            result += '+';
        } else {
            result += base20Lat.charAt(latIndex++);
            result += base20Long.charAt(longIndex++);
        }
    }
    return result;
}

let [lat, long] = p1.split(',').map(Number);
let plusCode = convertToOpenLocationCode(lat, long);
return plusCode;

Coordinate: 1.286813,103.854563
Return: 6PH57VP3+PR

Regarding copy-pasting, it’s something that cannot be avoided. However, if what is expected is dropping a pin and having the coordinates automatically saved into table, it is something that carries a risk of instability because it can inadvertently change. This is a choice.

1 Like

I only read from Google that accuracy can be achieved through this plus code method. It might come in handy, especially when inputting addresses or rural areas without clear addresses. Another thing is its concise form, making it easy to remember. Okay, just sharing.

1 Like

Plus codes and coordinates are just different ways to write the same thing. One just requires an extra encoding and decoding step to use. They are both definitely more accurate and precise than addresses. I agree with that.

2 Likes

Glad I could take us down that rabbit hole :slight_smile:

I actually think using current location in my use case will suffice for now and can look at a more full on solution in future as required.

Thank you again everyone, happy to consider this solved and also acknowledge that you’re getting into some nitty gritty stuff with plus codes and coordinates that I don’t want to shut down.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.