I am trying to get the city name from what is returned by geocode but seem to not working in any way I've tried. Can anyone help me pleasE?
here is where I get the location data which returns an object with an array of region, street, city etc like this
This line:
<Text>Location: {this.state.locationResult}</Text>
Returns this
[{"region":"England","street":"Holborn street","city":"London"}]
I've tried with locationResult[0].city but still doesn't work.
Тry this:
let obj = this.state.locationResult;
<Text>Location: {obj[0].city}</Text>
Related
Using the Google places API I am trying to fetch place_id's. I have issues when trying to fetch a place_id when multiple parts of the place location have the same name. For example: The city Utrecht (in the Netherlands) lies in the municipality of Utrecht, Which lies in the province of Utrecht. They all have the same name.
When I fetch Utrecht from the places service it returns the place_id for city (which is the default for maps incase there are multiple options)
I found a hack/solution to fetch the administrative areas: adding localised name of the thing i'm trying to fetch. For example I can use Gemeente(municipality) or Provincie(province)
Is there a way to request specifically the type of region I want to fetch from the API?
I see that the places API has all this information, but sofar my attempts to fetch the place_id for the administrative_area_level_2 or administrative_area_level_1 without modifying the address are futile.
My "fix" works for the Netherlands but I have 12 more European countries with similar issues hence my question.
The most common solution is using the reverse geocoding with a result type filter.
For example, your sample request for Utrecht returns the following coordinate 52.09073739999999,5.1214201
Now use reverse geocoding with result type.
https://maps.googleapis.com/maps/api/geocode/json?latlng=52.09073739999999%2C5.1214201&result_type=administrative_area_level_1&key=YOUR_API_KEY
This returns place ID ChIJPzM8M01oxkcRsFwejVreAAM for admin area level 1
https://maps.googleapis.com/maps/api/geocode/json?latlng=52.09073739999999%2C5.1214201&result_type=administrative_area_level_2&key=YOUR_API_KEY
This returns place ID ChIJA9Xkz5BoxkcRzAM9YkCZGTs for admin area level 2
Hope it helps!
Too much useless json data is being fetched when I request a specific country cities by hitting this URL:
http://api.geonames.org/searchJSON?username=ksuhiyp&country=us&maxRows=1000
This returns too many json fields as you can see, question is hot to play with the query to get only city, country name ?
You can try with the additional parameter style=SHORT
http://api.geonames.org/searchJSON?username=ksuhiyp&country=us&maxRows=1000&style=SHORT
The docs says: style, String SHORT,MEDIUM,LONG,FULL (optional), verbosity of returned xml document, default = MEDIUM
I have used this API :
https://api.foursquare.com/v2/venues/search?ll=39.320980,-111.093735&radius=2&limit=10&oauth_token=Z1NASAZ5IEUSDJAJG1VMQO5YX410DJXUKBKAHXN0FYIB15BQ&v=20150402
But, i cant able to get city param for all the venues.
For example, this venue 520f5bf211d224524d449989, Vihara Cahaya Dharma. i cant able to get the City Param
Pls suggest us any API call to get City param for all FQ venues
Thanks,
Suhanya.M
I am using google geocode api for fetching lat long using postal code of singapore
I have tried following to fetch data:
(1) http://maps.googleapis.com/maps/api/geocode/json?address=505468&sensor=false
(2) http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false
(3) http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false®ion=sg
But it returns location from India
https://developers.google.com/maps/documentation/geocoding/?hl=fr#RegionCodes
Any other way to get only country specific (Singapore) result.
I have tried following it returns correct result
http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20133224&sensor=false
The correct way of doing this is by providing componentRestrictions
For example:
var request = {
address: address,
componentRestrictions: {
country: 'UK'
}
}
geocoder.geocode(request, function(results, status){
//...
});
To restrict results to a specific country use the component-filtering.
The url should be http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false&components=country:SG
But that's not the issue here, the geocoder-result is wrong, because the result has the country set to SG, but the location is wrong(placed in india).
I'm afraid with the given address(it appears that the postcode doesn't exists), the only thing you can do is to report the wrong result to google.
you can set single country or multiple countries
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Raf&sensor=false&types=(regions)&key=YOUR_API_KEY&components=country:ESP
or
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Raf&sensor=false&types=(regions)&key=YOUR_API_KEY&components=country:ESP|country:uk|country:us
You should be able to use this approach
http://maps.googleapis.com/maps/api/geocode/json?components=country:US|postal_code:5037
remove the address and to the component pass the postal code and make sure if the address has a value let pass another value selected by the user with the postal code to validate your api or else without postal code passed it will leak to another address
i have a city ALMA but it can be more then 5 in the whole world so user can be confused. how i can show the all place who have a word ALMA in their location.
i want to get all city name who have word ALMA. are any api can give me all city , county name match to my name ALMA.
if i can use GMAP API [google] then how i can retrieve all city name who have word "ALMA"
take a look at Yahoo PlaceFinder API ... That should help you out. If you suffix a near by location to the city name as in district etc it will help you drill down to the one you want.
http://developer.yahoo.com/geo/placefinder/