location field extract data
Hi,
when using the internal "location" type, how can I extract e.g, city, country or the coordinates from it in calculations?
Regards,
Andreas
-
Hi Andreas,
to get them in the same app (i.e.: extract in the same item):
var a = @map.join(); a.split(",")[0]
This would return the street.
[0] = Street
[1] = Zip+City
[2] = State
[3]= CountryTo get them in a related app if there is only one item with an address field related:
var a = @all of map.join(); a.split(",")[0]
If there are are multiple items related:
var a = @all of map; result = []; for(var i = 0; i < a.length;i++){ result.push(String[a[i]).split(",")[0]); }; result.join("\n")
This would return all streets as a list
Rainer
-
Thanks Rainer! Your solution works of course very well.
I was unclear in my question - especially I wanted to get the coordinates. Looking at https://developers.podio.com/doc/items#location it seemed the values are internally stored seperated and I wondered if I could access them like @location.[lat] or @location.["lng"] in a calculation.
-
As I still have not found a solution for it: if I have an app with a location field e.g. "customers", how could I use the address data to filter my items based on country and city? This is something so basic that I wonder not every user having any kind of address data is requesting this?
With Rainer's solution I could have calculated fields showing the country but as this is text data and Podio obviously does not like text data it is up to no good except that I can export and then easily filter in Excel.
For now we still need to have additional category fields holding every possible country and our users must input data redundantly. Not cool at all! -
Hi Nicholas,
normally the zip code is the last number in a location field (the street number is always before the zip code, cities and countries normally don't have a digit in their name). In my country Germany, in France or in the USA the zip code has always 5 digits (don't know how the zip code looks like in your country).
This given the zip code can be extracted very simple by deleting all other characters (and spaces etc.) and then extracting the last 5 digits:
@location field.join().replace(/[^0-9]/g,"").substr(-5)
Another way I've described in this community post (see my first comment there).
Rainer
-
Hi Rainer,
As always your solution worked out. Thanks.
I have another problem regarding calculation fields giving null as a result when a field is empty.
In an app i have following fields :
1. reference field
2. date field
3. text field
I want to have a calculation field that shows the content of these 3 fields in the following way:
@all of title(reference field) + " - " + moment(@date field).format("DD/MM/YY") + @text field
But when either the date field or text field is empty i don't want a "null" to show up in my calculation field.
Do you know what code i have to use?
Greets,
Nicolas
-
Hi Nicolas,
you can do it this way:
(@all of title(reference field) + " - " + moment(@date field).format("DD/MM/YY") + @text field ).replace(/null/g,"")
That replaces all occurrences of "null" (even if both, date and text, are empty), but leaves the dash (which is unnecessary when both other values are missing). For that you can enter:
var ref = @all of title(reference field);
var date = moment(@date field).format("DD/MM/YY");
var text = @text field;
var title = text == null && date == null && ref != "" ? ref : (text != null || date != null) && ref != "" ? ref + " - " + date + text : ""
title.replace(/null/g,"")Rainer
-
I tried this as well and I am not getting the same results. Here is my code
var a = @Address.join();
a.split(",")[0]
"http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=<ZWSID>&address=" + a.toString().split(',').join('+')[0] + "&citystatezip=" + a.split(' ').join('+')[2]When I use this I get the following
http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=<ZWSID>&address=8&citystatezip=5
-
Hi Andreas. I would suggest you do a search for Scott Costello's JSON entry, either in YouTube or go to his site strugglinginvestor.com. Tons of free info, too. Our Podio community will be always indebted to him for all the time and effort he has put in. From day one, he has shared all the details of his progress, and NEVER asking for anything in return. We do owe him at least a big, huge THANK YOU.
-
Hi Gus,
thanks for pointing me there. Actually we went a similar route also using the Google Geocoder - we just do not store it in a JSON field. We also do not use flows but PHP scripts called by hooks. It is great that there are lots of such workarounds, but it is also my feeling that we should not need to use them. Having JSON data in text fields is not very user friendly at all :)
-
Hi all -
I'm having some issues with proper execution of this.
I want to isolate "state" from an address field.
Here's what I have:
var a = @Clinic Address.join();
a.split(",")[2]However, it is returning state and zip, for example " CA 12345"
To ensure consistency in entering addresses, we are always diligent about using the auto-prompted address that shows up to suggest the correct address when typing it into the address field.
Any guidance would be helpful.
Conor
-
Thanks for all of the information shared here.
I have been able to apply this to my situation to display just the city in one field and just the zip code in another field.
This displays just the zip code.
This displays just the city
My issue is that I have multiple items being referenced but the calculation is only displaying one of them. I tried to use what was suggested
---
var a = @all of map;
result = [];
for(var i = 0; i < a.length;i++){
result.push(String[a[i]).split(",")[0]);
};
result.join("\n")---
but this results in an error message.
Can you help me to display the information for all of the items referenced? Thanks.
-
Hi John,
I have the following fields in My Excel file:
Address (street)
City
State
Zip Code
How do I get my various Excel fields to import into my Seller Leads app "Property Address" field joined, so that my related fields "Street Map" and "Zillow Link" calculate the address properly? These fields need the complete address to function properly.
Here is my current "Street Map" calculation, as it defaulted:
var prop = @Property Address;
""
Here is my current "Zillow Link" calculation, as it defaulted:
var url = @Property Address
if(url){
"http://www.zillow.com/homes/"+url.toString().split(' ').join('-') +"_rb"
}Thanks!
Rich
Please sign in to leave a comment.
Comments
21 comments