Geolocation API does not return locality in the response for certain addresses - geolocation

Google Geolocation API does not return the "locality" field in the response for certain address?
For input, 225 Bush Street San Francisco CA 94104 , the API returns locality field.
For input 12732 W Myrtle Ave, Glendale, AZ 85307, the API does not return locality field. Its getting resolved into a formatted address, which has a city.
When that field will get populated? I looked at the document, it is not clear. Any help will be appreciated.
I read the documentation https://developers.google.com/maps/documentation/geocoding/requests-geocoding#Types. It has no detail what type will be set for what address?

Related

Google Places Autocomplete API filter type "address" returns places of type "route" via iOS SDK

Google Places API for iOS version: 2.2.30010.0
Code:
let filter = GMSAutocompleteFilter()
filter.type = .address
filter.country = "us"
return filter
When searching for example Montrose with filter of type address & country us, the search results display:
The country filter works, but the type filter displays results of type route. Is this the intended behavior?
The Place Autocomplete docs specify:
address instructs the Place Autocomplete service to return only geocoding results with a precise address. Generally, you use this request when you know the user will be looking for a fully specified address.
Maybe I'm misunderstanding what a precise address is, but it seems like the query should only return results with a building number ex. 22 Montrose Ave.
Is it possible to return only places that have building numbers?
You just need to remove filter.type = .address

Search four fields in YQL geo.places

We are currently using YQL to query geo data for towns and counties in the UK. At the moment, we can use the following query to find all towns named Boston:
select * from geo.places where text="boston" and placeTypeName="Town"
Demo
The issue is, that we would like to specify the county and country to generate more specific results. I have tried the following query, but it returns 0 results:
select * from geo.places where (text="boston" and placeTypeName="Town") and (text="lincolnshire" and placeTypeName="County")
Demo
How can I query 3 field types to return the results I need? Essentially, we would like to query the following fields:
text and placeTypeName="Town"
text and placeTypeName="County"
text and placeTypeName="Country"
This may be an option maybe:
https://developer.yahoo.com/blogs/ydnsevenblog/solving-location-based-services-needs-yahoo-other-technology-7952.html
As it mentions:
Turning text into a location
You can also turn a text (name) into a location using the following code:
yqlgeo.get('paris,fr',function(o){
alert(o.place.name+' ('+
o.place.centroid.latitude+','+
o.place.centroid.longitude+
')');
})
This wrapper call uses our Placemaker Service under the hood and automatically disambiguates for you. This means that Paris is Paris, France, and not Paris Hilton; London is London, England, and not Jack London.

best solutions to combine different geo web services results?

I would like to call different geo webservice in order to get the data with the geo location. for example I would like to search restaurants in san francisco from google place api, yelp api.
let say i will get the following data.
google:
restaurant A, address A, latlng(x1,y1) ,restaurant B, address B, latlng(x2,y2)
yelp:
restaurant C, address C, latlng(x3,y3) ,restaurant B1, address B1, latlng(x2.1,y2.1)
the situation is restaurant B and B1 are actually the same. A and C are different. and I need to display in my app with A, B, C restaurants.
How can I identify the difference of the result based on the name, address and latlng?
my solution is
compare the name with string first, if 100% same then return.
compare the address with street number, street name, zipcode, if 100% same then return
compare the coordinate, if the distance((x1,y1),(x2,y2)) < 10m then return.
I would like to ask if any better solution?

Contact address format for different countries

In an app, I am displaying the details of the contacts using ABRecordRef. I am using the keys kABPersonAddressCityKey, kABPersonAddressStateKey, kABPersonAddressZIPKey, kABPersonAddressCountryKey. Everything works fine. But I don't know in which format to display the addresses. What I mean is, if you see the Contacts app, the addresses are displayed in a particular format for different countries. Some examples,
US
Street
City State ZIP
Country
India
Street
Province
City PIN
Country
Australia
Street
Suburb State ZIP
Country
Now I don't know how to find the format for different countries.
1.Is there any way to find the address format based on country/country codes?
2.Is there a way we can get the fully formatted address using a single function, like we use ABRecordCopyCompositeName() to get the full name?
From iOS 9.0 / macOS 10.11 / watchOS 2.0 on you should use CNPostalAddressFormatter instead:
The CNPostalAddressFormatter class formats the postal address in a contact. This class handles international formatting of postal addresses.
Below code is in Swift 3 but it is trivial to convert it to Objc
let postalAddress = CNMutablePostalAddress()
postalAddress.street = street
postalAddress.postalCode = zipCode
postalAddress.city = city
postalAddress.state = state
postalAddress.country = country
postalAddress.isoCountryCode = countryCode
let formattedAddress = CNPostalAddressFormatter.string(from: postalAddress, style: .mailingAddress)
Make sure you set the ISO country code property, this is used to determine the format of the address.
Example:
postalAddress.street = "Main Street 1"
postalAddress.postalCode = "67067"
postalAddress.city = "Ludwigshafen"
postalAddress.state = "Rhineland-Palatinate"
postalAddress.country = "Germany"
postalAddress.isoCountryCode = "DE"
leads to this
Main Street 1
67067 Ludwigshafen
Germany
whereas
postalAddress.isoCountryCode = "US"
leads to
Main Street 1
Ludwigshafen Rhineland-Palatinate 67067
Germany
Try this link
ABCreateStringWithAddressDictionary
It looks like you need to use: ABCreateStringWithAddressDictionary that will return:
Returns a formatted address from an address property. (From Apple)
Good luck

What are the names of administrativeArea, subAdministrativeArea, etc called outside of the United States?

I am working on a geographically aware high score server, and would like to be able to list scores like "First place in Dutchess County" or "Third place in the State of New York". I can reverse geocode the user's location and get a placemark that lists AdministrativeArea, etc.
The reverse geocoder used by iOS and Google would return "Dutchess" and "New York" for the above examples, so I need to supply "County" and "State" for the United States.
However, the game is global, so I need to know the names of each geographic organization level in other English-speaking countries.
So, in the United States, Google / iOS placemark levels would be described as following:
AdministrativeArea = "State"
SubAdministrativeArea = "County" (or "Parish" in Louisiana)
Locality = "City" or "Town"
Sublocality = (I'm calling this "Neighborhood")
PostalCode = "Zip Code"
What are all of these levels called in other English-speaking countries? (Canada, UK, Australia, New Zealand, Singapore, etc). If there's a resource that lists all these, I would love to know it. I think I may just not know what to search for on the web.
I'm not entirely sure of the effort/value ratio of this exercise. It could get rather difficult, especially with unitary authority areas in England.
In most of the United Kingdom,
country is "United Kingdom" [ie the country name]
administrative_area_level_1 could be "England" or "Scotland" etc [ie the country name]
administrative_area_level_2 might be "East Sussex" [county]
locality might be "Hailsham" [town]
postal_code is a postcode
However in London,
administrative_area_level_2 is "London" which isn't a county
administrative_area_level_2 might be "Greater London" too
administrative_area_level_3 might be "London Borough of Lewisham" [yay! Borough makes sense]
locality is "London" which isn't a locality
In unitary authority areas in England,
administrative_area_level_2 might be "Medway"
Unitary authorities replace county council and borough/district councils, but they are located within a "ceremonial county" which is what most people will use ordinarily. Places in Medway Council's area are in Kent. Unfortunately these county names aren't returned by the geocoder. Some counties (eg Berkshire) were abolished completely and replaced entirely by unitary authorities. However the old county name (Kent, or Berkshire) is the right name to use.

Resources