Since I own an app key for mapquest (community edition), all geocoding requests end up in US only. Before I entered the app key geocoding european locations was possible.
I couldn't find a method to set a default country. Even initializing the geocoder object with a Locale didn't work.
Any suggestions?
Currently the mapquest Android API doesn't support single line international geocoding.
This is the reply I got from mapquest:
I checked at our Android API is still using our v1 geocoder which does
not support single line international geocoding. My support suggested
you use our geocoding web service for the geocoding first:
http://developer.mapquest.com/web/products/dev-services/geocoding-ws
Again just make sure the request says “v2”.
Related
I'm using Mapbox to Reverse geocode a latitude, longitude location and wanted the city name(Place name) response with multiple languages.
The documentation says,
'If more than one language tag is supplied, text in all requested languages will be returned'
But I'm getting the response only in the first language specified.
MapboxGeocoding.builder()
.accessToken("xyz..."),
.query(Point.fromLngLat(-123.1207, 49.2827))
.languages("zh-CN,ru")
.geocodingTypes(GeocodingCriteria.TYPE_PLACE)
.mode(GeocodingCriteria.MODE_PLACES)
.build();
This returns the place name in Chinese and not Russian.
Documentation : https://www.mapbox.com/android-docs/api/mapbox-java/libjava-services/4.0.0/index.html
Verison used: 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.1.0' and also 'com.mapbox.mapboxsdk:mapbox-sdk-services:4.1.0-SNAPSHOT'
I have contacted the Mapbox team. Apparently, this is a bug in their Mobile SDK but their API works fine. Have reported this here. https://github.com/mapbox/mapbox-java/issues/446
I have used Google geo address and using lat/long have got the address. How do I determine if I am on road on not? Basically hit-test for road? I am currently using location manager for lat/long and the GeoAddress is same for on road and next to road.
Final Solution
Use reverse geocoding via the Google Geocoding API.
The term geocoding generally refers to translating a human-readable
address into a location on a map. The process of doing the converse,
translating a location on the map into a human-readable address, is
known as reverse geocoding.
The Geocoding API supports reverse geocoding directly using the latlng
parameter. For example, the following query contains the
latitude/longitude value for a location in Brooklyn:
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false
The docs explain how to interpret the json results but StackOverflow has various answers addressing more efficient ways to parse the data.
https://stackoverflow.com/a/8095967/1085891
https://stackoverflow.com/a/8314094/1085891
https://stackoverflow.com/a/6335080/1085891
Possible Solutions
Getting the nearest street/road coordinates in android - the answer to this question may point you in the right direction.
You can use directions api directly: http://maps.googleapis.com/maps/api/directions/json?origin=51,19&destination=51,19&sensor=false
Could you use the API to find directions which would then provide the closest road?
Stick position to road on android maps v2
GPSLocator - App to Find Current (Nearest) Location using GPS - possibly helpful; not so sure on this one.
Snap to Roads Android - Exact same question
Quick Search Results
Snap to nearest street
Maps API Blog using GDirections.loadFromWaypoints
Finding nearest street given a lat-long location
Driving route from my location to destination in Google Maps Android API V2
Unsolved Similar Questions
Trace the location only on Road in Google maps V2 android
https://stackoverflow.com/questions/18081417/google-maps-v2-snap-to-road-issue
See fiddle.
It can be done so much easier with OSRM (nearest) webservice. Make a GET request like:
const url = '//router.project-osrm.org/nearest/v1/driving/';
fetch(url + coord.lon + ',' + coord.lat).then(function(response) {
return response.json();
}).then(function(json) {
if (json.code === 'Ok') {
console.info(json.waypoints[0].location);
}
});
Which is a road/street coordinate.
References — Project-OSRM
I'm developing a map application in Android. I'm using Google maps API to show results in Autocomplete textview dropdown .The results this API is returning is of the places of the entire world . I want to show results o provide solutions to places only of a particular country eg .UK
How should I do it . Is there any specific flag to be set for it .
My URL :
private static String SUGGETION_URL = "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=%s&types=geocode&sensor=true&key=xxxxx.xxx-xxxxx";
Please suggest ways by which this url will return results to places only in UK ?
There's no way to force the API to restrict it's results to a region like you can in some of the other Google Maps Web Service APIs. If you really need that functionality then maybe you should be using the Geocoding API or the Places Autocomplete API as included in the Google Maps JS V3 API.
If you can't use either of those two suggestions your options are limited to:
You can use the location / radius parameters like you found, but there are treated as more like "suggestions" than absolutes.
I'd try setting the language parameter to en-GB which might favor UK-based results slightly over others.
First of all: Geocoder is present and works fine on my android application. It gives results for the examples from the android documentation:
"Dalvik, Iceland", an address such as "1600 Amphitheatre Parkway, Mountain View, CA", an airport code such as "SFO", etc..
But when I search a restaurant or something like that in my own country, the Netherlands, geocoder won't find anything. But if I type the same query string into maps.google.nl it gives me directly the restaurant I was looking for.
I already have tried to restrict the geocoder within two long/lat points, but that doesn't make any difference. So it seems that I can find anything in de US easily, but finding a location of a restaurant in the Netherlands doesn't work
The Google Geocoding API (which I think is what your Android app is querying) will only return geographical features, not business listings. Those are available on Google Maps because that's an application and uses more search backends than the Geocoding API.
Appending the country name won't help, what you'll get in your Android app (using the geocoder) is the same you will get from the Google Maps API v3 Geocoder Tool. It does include some POIs, but not all business listings (restaurants, hotels, etc.).
Some time ago I had a similar problem with UK adresses, I believe it's because the web app has more context than just the portion of the map you're looking at (like which countries are in view).
If I recall correctly, I solved it by appending ", UK" or ", GB" (or ", United Kingdom" / ", Great Britain") to all queries, so in your case try appending ", Netherlands".
I have the following code in my Android program
List<Address> addressList = geoCoder.getFromLocation(37.790551,-122.433931, 1);
if (!addressList.isEmpty()) {
address = addressList.get(0);
String number = address.getSubThoroughfare();
String streetName = address.getThoroughfare();
.....
}
This is a request to essentially get a street name (hence the 1) from a latitude and longitude in San Francisco.
When I execute this program on a phone in Europe (specifically Ireland) number is returned as 2250-2290 and streetname is returned as Fillmore St.
When I get a friend to run the same code on his phone in California number is null and streetname is still Fillmore st.
I've seen other SO questions allude to region settings but is this possible that the geographical location can affect the query in the Android API?
The Javascript Geocoding API mentions region bias. I wonder is it possible to do something similar in the Android API. I did try creating the Geocoder as
Geocoder geoCoder = new Geocoder(getApplicationContext(), Locale.US);
but this does not re-recreate the California based result.
From getting people to run identical code on different continents it seems that location is indeed a factor.
The Javascript geocoding allows you to specify a region though
Are the phones running different versions of android? Also, another thing to keep in mind is that "The Geocoder class requires a backend service that is not included in the core android framework." So, if the two phones are calling upon different backend services to query for the Geocoder, that may explain the output you are seeing.
I think with Android 1.5, they included a Google API backend service implementation for Geocoder. I don't know if newer versions of Android and the Google API made changes to the Geocoder implementation that may be giving you different results or it's coming from some other backend service.