Geoder.getFromLocationName doesn't give the same results as maps.google.nl - android

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".

Related

Mapbox - Reverse Geocoding - multiple language response

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

How to determine if lat long coordinates are on a road with Google Maps API v2

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

Android mapquest geocoder country-setting

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”.

Mobile web driving directions from current location

I'm building a mobile-version of a website, trying to have one-click link to launch Google Maps with driving directions to the business, from the user's current location. I have it working fine for the iPhone, but when testing on Android, it views 'Current%20Location' and tries to find a business called 'Current Location'. Here is my current code:
Get Directions
I need a universal string to search from the current location, and can't find a definitive answer anywhere online.
Thanks in advance for any help!
I am doing the same thing and now have it working on Android. I don't have an iPhone so I have no way of testing on that. You should leave the saddr parameter blank in the URL, and Google Maps will then prefill it with the user's current location. Also, use + signs instead of spaces in the destination address. Here's the corrected URL:
http://maps.google.com/maps?saddr=&daddr=123+Street+Rd,Cityville,MD,21098
Use the google gps api to get the currentlocation and pass it to maps. Even better I think there's an action to open the built-in maps application asking it to route from current location to your address.
This article on location services should help http://developer.android.com/guide/topics/location/index.html
If you're trying to do it fully through the web, I think the user has to enable location services on the google webpage for it to work.
Also, check out this javascript library that provides a platform neutral api for gps services on most devices http://code.google.com/p/geo-location-javascript/
Google Maps with directions from current location
https://maps.google.com/maps?saddr=&daddr=35.658157,139.697174&sensor=TRUE
https://maps.google.com/maps?saddr=&daddr= PLUS
"location's_latitude" PLUS
"," PLUS
"location's_longitude" PLUS
"&sensor=TRUE" // for getting your current location
Probably the most accurate way using lat and long
<span class="addressAt">
<a href="http://maps.google.com/maps?f=d&hl=en&region=US&doflg=ptm&geocode=&saddr=&daddr=41.75553,-88.322048" target="_blank">213 S River St
Aurora, IL</a>
</span>
This is the only way to get an accurate "my location" on the google maps mobile site. Replace the coordinates(41.75553,-88.322048) with your locations coords. All other ways just wrote in my location as the start address without actually getting the real time location.

Android Geocoder - different results when called from different geographical locations

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.

Categories

Resources