I’m trying to map a specific point using Google maps and am trying to configure the fields accordingly but my data arrives by api in the following format for lat/long:
If we need to have a field type as NUMBER, how can i save this data so that i can run a formula on it to map to a google map address??? As you can see, the lat/long has other types of data such as letters and dashes. ?
Can you use blockspring instead, that way, you can modify how the data is sent back to Bubble. We currently don’t enable writing custom transformation code. That’ll come with the plugin system, but it’s not for the very near future.
Is this the correct setup?
I’ve configured blockspring to work with “Google geo code” in hopes of:
- Converting degrees/minutes/seconds coordinates to decimal format to be able to run the Bubble function to convert coordinates to mapped address
or
- Converting those coordinates to a fixed address to be used in Google Maps in Bubble.
https://testingapplication604.bubbleapps.io/version-test/add_a_flight_airportdata?debug_mode=true
but it’s not working correctly.
I am not sure the format is correct.
The GPS coordinates are definitely wrong and don’t map to the correct address.
Each step is labeled in this test application as you can see.
I am not at all confident my setup/logic is correct or the formatting is correct.
Any input?
What is not working correctly? It sounds like you just need to convert the string to numbers right?
The format I receive from the AirportData.com API is in degrees minutes and seconds and contains also a letter (text) which cannot be used by the Bubbles built in function to convert coordinates to address…
I’ve then tried to configure blockspring to change the format but there isn’t the ability to do this with blockspring.
Blockspring won’t take a coordinate to address… only a full text address to coordinate.
The formula i need to be able to run converts coordinates in degrees/minutes/seconds to decimal format… which could then be easily used with the Bubble built in function.
I just need a way to add this formula to take what comes out of the API and convert it to a format usable by Bubble.
You should e able to write the few lines of code it takes to go from one format to another. We’re not at the stage where we can let you do this firefly in Bubble. If that’s too big of a pain we can add the API on a sponsored basis as well, and we’d take care of this.
1 Like
Old thread, but needed to reformat my Lat/Long to DMS. Here’s the JS snippet. Use this with js2bubble event convertToDMS and set 2 outputs to text, then use convertToDMS’s output1 and output2 for lat / long respectively
function convertToDMS(deg) {
const absolute = Math.abs(deg);
const degrees = Math.floor(absolute);
const minutesNotTruncated = (absolute - degrees) * 60;
const minutes = Math.floor(minutesNotTruncated);
const seconds = Math.floor((minutesNotTruncated - minutes) * 60 * 100) / 100;
const direction = deg >= 0 ? (degrees === absolute ? "N" : "E") : (degrees === absolute ? "S" : "W");
return `${degrees}° ${minutes}' ${seconds}" ${direction}`;
}
const latitude = "insert_dynamic_latitude";
const longitude = "insert_dynamic_longitude";
const formattedLatitude = convertToDMS(latitude);
const formattedLongitude = convertToDMS(longitude);
console.log(`Latitude: ${formattedLatitude}`);
console.log(`Longitude: ${formattedLongitude}`);
// Send the formatted results back to Bubble
bubble_fn_convertToDMS({
output1: formattedLatitude,
output2: formattedLongitude
});