Geocode searchText with State and Country provided shows results outside of State - here-api

When using the Nokia Here Geocoding Service the State parameter is ignored when searching by searchText: 315 NE 14th Street, State: FL and Country: US.
The only result returned is a location in Louisiana. Adding the State to the end of the searchText doesn't work either.
Google and MapQuest properly return the result in Florida. The client does not want to include a city but rather an address, state and country.
I know that the Nokia Here algorithm does not filter down a closely as Google and MapQuest but expected that the inclusion of the State parameter would force the result search.

You can try setting a search area, so you can further narrow down the results. The following Android example will return one result in Homestead, Florida City:
String query = "315 NE 14th Street Florida US";
GeocodeRequest geocodeRequest = new GeocodeRequest(query);
GeoCoordinate areaCenterCoordinate = new GeoCoordinate(27.82353, -81.760254);
geocodeRequest.setSearchArea(areaCenterCoordinate , 15000);
According to documentation GeocodeRequest processes text string queries, so I believe you can omit state or country parameters and add state or country as part of the search term. Please note that multiple results can be returned if they all match to the given search term.
An example on how to use GeoCoder can be found here.
Depending on your use case, maybe consider to use SearchRequest instead. If this does not help it would be great if you can provide more details in your question, e.g. what API flavor you are referring to.

Related

Google places API returns rating for properties searched using property name, but not with an address

I am using a Google Places API to return ratings for an entered property. When I enter the property name as the search term, a rating is returned, but if I attempt to return a rating by using an address (which is supported by the text input) I do not receive a response. I have tried searching an address through the API, returning a Place ID and then using the Place ID to return a rating, but that does not work.
This API returns a rating: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=The+Shops+At+Chestnut+Hill&inputtype=textquery&fields=rating&key=[MY API_KEY]
This is the same property, but searched by address, which does not: https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=199+Boylston+St+Chestnut+Hill+MA&inputtype=textquery&fields=rating&key=[MY API_KEY]
Is there something different with the formatting of address inputs I am not doing correctly?
The places API has separate ids for the address/building and the establishment in it. The address/building won't have the rating, the place/establishment will.
From the PlaceId Finder
The Shops at Chestnut Hill
Place ID: ChIJkcWRbZF444kRJUJjXdUFIOw
199 Boylston St
Place ID: ChIJ4TgqFZF444kR2XHKhTgsiNs
(although I do see an entry in the dropdown for the "place" when I enter the address)
The Places API nearbySeach only returns places, not address place ids. The geocoder returns the place_id of the address. But the nearbySearch takes a set of coordinates, not an address, so to get those results from an address requires two calls, one to geocode the address, one to get the nearbySearch results from that location.
Note that there are multiple results at the location of that address (4 exactly at the location returned from geocoding "199 Boylston St Chestnut Hill MA", and 15 other places that are nearby and in the footprint of "The Shops at Chestnut Hill"), more if you use pagination to get more than 20 results.

Google Places API: How to go from address to "good" place_id?

On the google places api site, they have an example query that returns a load of detail:
site:
https://developers.google.com/places/web-service/details
query:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=My-API-Key
Place_id appears to be the key here. So I'm trying to reverse-engineer this example, starting from information that a human being would actually have, to end up with this place_id.
Address from the example:
48 Pirrama Rd, Pyrmont NSW 2009, Australia
Places API query from the address:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=48+Pirrama+Rd,+Pyrmont+NSW+2009,+Australia&key=My_API_Key
The result contains a different place_id:
ChIJ8UadyjeuEmsRDt5QbiDg720
And the place details with that place_id are much poorer than the original example:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ8UadyjeuEmsRDt5QbiDg720&key=My-API-Key
So what am I missing here? How do I start from human-place information and get to the place_id that has the great place details?
EDIT: why the down votes? Am I trying to do something that isn't allowed?
Thanks,
sff
I think your text search is returning the office building, whereas your first search is returning the Google office within the office building. You can fix your text search by adding the name of the company and removing some of the search terms.
I'm not sure why just adding 'google' to the search term doesn't return the result you want though.

google trip planner auto-fill

We are currently using the google trip planning feature on our transit website. The issue we are running into is the fact that when a customer types in a starting point (for example "Queensway" in Kelowna, BC Canada) we get auto-fill results from all over North America. Can the auto-fill results be restricted to a specific province or state? Thanks!
Try using Component Filtering
In a geocoding response, the Google Maps Geocoding API can return address results restricted to a specific area. The restriction is specified using the components filter. A filter consists of a list of component:value pairs separated by a pipe (|). Only the results that match all the filters will be returned. Filter values support the same methods of spelling correction and partial matching as other geocoding requests. If a geocoding result is a partial match for a component filter it will contain a partial_match field in the response.
The components that can be filtered include:
route matches long or short name of a route.
locality matches against both locality and sublocality types.
administrative_area matches all the administrative_area levels.
postal_code matches postal_code and postal_code_prefix.
country matches a country name or a two letter ISO 3166-1 country code.
Note: Each address component can only be specified either in the address parameter or as a component filter, but not both. Doing so may result in ZERO_RESULTS.
A geocode for "Santa Cruz" with components=country:ES will return Santa Cruz de Tenerife in Canary Islands, Spain. Request:
https://maps.googleapis.com/maps/api/geocode/json?address=santa+cruz&components=country:ES&key=YOUR_API_KEY
See this sample: Place Autocomplete Hotel Search for code implementation.
Hope it helps!

How does Google Maps decide when to use a specific icon?

I am using the Google Maps Places library to do a search for nearby hospitals, but it returns results that aren't necessary hospitals (but have 'hospital' as one of their types). However, I've noticed that actual hospitals have a hospital icon on the map, so Google must somehow know which establishments are actually hospitals. Does anyone know if the public has access to this data?
This is the icon I'm referring to: https://www.dropbox.com/s/1jfqcayxavjhlyi/Screenshot%202015-03-17%2017.20.19.png?dl=0
Example of request I'm making:
var request = {
location: self.location,
radius: 20000,
types: ['hospital'],
keyword: 'hospital'
};
Example result that isn't a hospital:
{"geometry":{"location":{"k":44.815958,"D":-68.808244}},
"icon":"http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png","id":"de6e60bd70b90ba4cb86afe149a60169553607f1",
"name":"Penobscot Community Health Center",
"opening_hours":{"open_now":true,"weekday_text":[]},
"photos":[{"height":320,"html_attributions":[],"width":320}],"place_id":"ChIJj--4INRKrkwRN0z2XkoJtVU",
"rating":3.1,
"reference":"CoQBdAAAADmf3YA0659efzMbCSPOK6SZttkfus7aWBDhrZZyX63Szl256BRcpz81LH6rIuONldYv256tsN7Zv-N6ZkOkJadlD2VS01bs7C4ierKvGUMyJOJu657xL5MvidF3Tgs9iejeJcXsxjDJYOwtN3m3sbfClfWYVnnIL4hMLYV8P9TnEhBurfJv_30CAG2wp1V73POVGhR-7fz1mCdh4OYWSa3Pw0mPupckoQ",
"scope":"GOOGLE",
"types":["hospital","pharmacy","store","health","establishment"],
"vicinity":"1012 Union Street, Bangor",
"html_attributions":[]}
My guess is there are a couple ways to get around this. You might remove the keyword argument from the API, which acts like a search term rather than a specific match on a type of location like the type field does.
You may want to be careful about your radius value choice.
Next, if you do a search on Google Maps in general you'll get a broad assortment of results. Do you need every result to be an actual hospital or can you do your own filtering afterwards?
If you do your own filtering it looks like type information and even icons are embedded in the result JSON. You might see if there's a distinguishing characteristic between the types of results you want and filter by that. Otherwise, any additional graphical data would not be accessible via the API.

Geocoder Request No Response - Fail

Is it possible to have the Geocoding API works and sometimes doesn't work for some reason?
Here is the detail what I am trying to request:
http://geocoder.cit.api.here.com/6.2/geocode.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&gen=4&country=Australia&state=Tas&district=Wynyard&postalcode=7321&street=86 Jackson Street
and Here is the demo version from the official website:
http://geocoder.cit.api.here.com/6.2/geocode.xml
?app_id=DemoAppId01082013GAL
&app_code=AJKnXv84fjrb0KIHawS0Tg
&gen=7
&housenumber=425
&street=W+Randolph
&city=Chicago
I am using the Free version of it and I have no idea why it works sometimes and doesn't in other times.
Thank you
When you are making a structured address query, by default, all parts of the address need to match. Given that there is no international standard for addresses, the HERE geocoder could be placing parts of the address in an alternative part of the structure.
In your case Wynard is recognized as a city, not a district. Now it is possible you could want this to fail as an invalid address, but it is also possible to tell the Geocoder to be a little more lenient by using the FlexibleAdminValues parameter in the AdditionalData
see the User Guide here
FlexibleAdminValues
N (positive integer <= 1). Customizes flexibility in the input values
for the admin hierarchy defined in LocationFilterType. The value is a
bitmask defining which hierarchies might be swapped without impacting
the match level:
0: No swapping at all (default). Exact admin hierarchy values are
expected as input
1: City and District swapping
Please note this
option is for geocoding addresses and needs at least street level
input to work as designed. It will not return expected results when
the input is a named place only (e.g. city or district name).
So the following url will work for you provided you have a street address:
http://geocoder.cit.api.here.com/6.2/geocode.xml?app_id=APP_ID&app_code=APP_CODE&gen=7&AdditionalData=FlexibleAdminValues,1&country=Australia&state=tas&district=Wynyard&...etc
Another alternative is to not use the structured input parameters but let the HERE Geocoder sort out the identification and categorization of the input tokens.
By using the searchtext parameter and providing all your data as the input value the Geocoder can match and score the tokens.
E.g.: http://geocoder.cit.api.here.com/6.2/geocode.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&gen=7&searchtext=Australia%20Tas%20Wynyard%207321%2086%20Jackson%20Street

Resources