Can I get the LatLong capture from the Adress point?
@Marlon_Xavier_Medina Hi Marlon, if you want to convert an existing address to LatLong, Iโm afraid this is currently not possible in the app. However, if you want to capture the current location of the app user, you can learn how to do so in this article:
help.appsheet.com - Capturing GPS Location Capturing GPS Location help.appsheet.com
@Marlon_Xavier_Medina what you are asking is a reverse geocode and Iโm afraid thatโs not possible with AppSheet right at the moment. However, itโs doable with scripting.
all right. When you mention โscrptingโ means that it will work in another platform ?
@Marlon_Xavier_Medina can you clarify what do you want to mean with"โฆit will work in another platformโฆ"?
@LeventK this sounds like what I need. If I can explain
I have an app that allows addresses to be entered. For a maintenance activity, I want to allow a user to pick an address thatโs โcloseโ. I naturally thought I could calculate a virtual column [Distance from HERE to Address] and then ORDERBY( โฆ[Distance from HERE to Address]โฆ).
But of course distance calculations donโt work with addresses.
Hence the need to be able to convert Addresses to LatLong.
Since itโs plotted on a map there must already be a calculated LatLong for each address in my list. So may we access that please?
And if it needs a geocoding call like this then how may I code it so that the values are calculated when a record is saved?
THanks
As Andrew_Smith1 says, it already get the lat long to place the pin on the map, but i cant find a way to accually use that lat long in a DISTANCE(HERE(),[Address]) expresion.
I dont know if it is only me, but i dont know the lat long of a worksites address by heart and it is not many costumers that specify the lat long in their postal address.
Will it be possible to get a function like GEO_CODE([ADDRESS]) so it will be possible to make a DISTANCE(HERE(),GEO_CODE([Address]))
PS. I am pretty new to APPSHEET and i love it, maybe i have to ask this as a feature request somewhere
Please see the following:
Vote for the feature here:
It would be better if you could do this in Appsheet, but as otherโs have said itโs not available right now. I overcame the issue by putting an extra column in my google sheet titled LatLong and used a script for a custom function.
*/
function GEOCODE_GOOGLE(address) {
if (address.map) {
return address.map(GEOCODE_GOOGLE)
} else {
var r = Maps.newGeocoder().geocode(address)
for (var i = 0; i < r.results.length; i++) {
var res = r.results[i]
return res.geometry.location.lat + ", " + res.geometry.location.lng
}
}
}
@Brady_Lovell built the script and posted it on another chain.
Once the script is in I use the function geocode_google(address) to get the latlong.
Then I created a virtual column in appsheet distance(here(),[LatLong]) and sorted my result by distance.
Once again it would be better as a native appsheet function, but until that happens this seems to do the trick. Hope this helps
FYG
This is another script sample, I scripted for GAS (Google App Script), which return driving distance between location, A to B.
First function returns driving distance in KM using Address value, while the second function return the same from lat/long for A and B.
function DrivingKM(origin, destination) {
var directions = Maps.newDirectionFinder()
.setOrigin(origin)
.setDestination(destination)
.setMode(Maps.DirectionFinder.Mode.DRIVING)
.getDirections();
return directions.routes[0].legs[0].distance.value/1000;
}
function DrivingKM(lat1,long1,lat2,long2) {
var directions = Maps.newDirectionFinder()
.setOrigin(lat1,long1)
.setDestination(lat2,long2)
.setMode(Maps.DirectionFinder.Mode.DRIVING)
.getDirections();
return directions.routes[0].legs[0].distance.value/1000;
}
I raised feature request to do the same calculation within Appsheet with their own function natively, but until they implement, this is only the solution with me to achieve my goal.
If you want to get the distance by โwalkโ instead of โdrivingโ, change the syntax to
.setMode(Maps.DirectionFinder.Mode.Walking)
Hi David,
excuse the question, but can I use your script? once created can i use it in my project created with appsheet? Thank you
Giampaolo
Feel free to use the script however you want.
Iโm having the same trouble with calculating the distance and came across your solution. However, I can not understand where to build the script mentioned by you. Can you please explain? Thanks in advance!
Menu in the Google Sheets: Tools/Script Editor
Thanks for your reply! Can you share an article or more information on how then to use the script into my app? I couldnโt find any helpful information related to AppSheet.
You may find useful information on Stackoverflow for example, this forum is not dedicated to helping on Google Apps Script.
Also, This Youtube channel here is really well made in my opinion for learning basics:
Basically:
=DrivingKM(yourAddresse, yourAddress2)
Iโm not 100% sure about procedure, but it should be something really close to this.
Hi! I keep getting TypeError: Cannot read property โmapโ of undefined. Am I missing something?
User | Count |
---|---|
40 | |
34 | |
29 | |
23 | |
17 |