guys.
Method getFromLocationName(..) in Geocoder class return Addresses by "a user-supplied description of a location". And if I'm calling it with "London" string or "Statue of Liberty" it returns addresses and I can animate the Map to found coordinates. But iI need to find latitude and longitude based on ZIP CODE. If I call method with "33040" string (zip of Key West region) - Geocoder returns some another addresses (of course!), because it can't associate this string with zip.
I have made some trick: adding "usa " prefix if user enters decimal value. And it returns currect locations by string "usa 33040" and others in 70%. Is any idea how to find location by ZIP in 100% cases? Thanks!
Have you tried strings like "33040, United States"? That format certainly works in Google Maps, so it may work on Android, though the Android geocoder is not as good as that Google Maps uses.
Related
I am using the GeoCoder for getting lat and long coordinates by giving him street adress, post code, and country. I have only adresses for Germany.
There is a street called "Sandgrubenstraße" with its post code but he is adding a marker somewhere in Austria. But it should be added in Germany.
I found out, that there is the same street in Autria called "Sandgrubenstraße" but how does that work when I use the post code which is unique?
How can I prevent GeoCoder to add markers that are NOT in Germany? How can I restrict this behaviour ? Do you have an example?
Postcodes are not globally unique, different countries can and do have overlapping post codes and different standards. Adding the country name to geocode prevents this happening, so you should add "country" when filtering for address components.
components=country:DE should solve this.
In Android's Geocoder, method getFromLocation can return more than one address for a given lat long. But lat long uniquely represents a location on earth surface, so why does it return multiple objects?
Reverse geocoding translates latitude, longitude into a human-readable address. However, there are different objects that you may be interested in. For example, you can search the nearest street address, the nearest postal code, the neighborhood, the city, etc. For this reason reverse geocoder returns more than one result.
Please look at this example in the Geocoder tool.
As you can see the first result has a type street_address, the second result has a type bus_station, the third has a type neighborhood, and so on until the country level.
Hope my answer addresses your doubts.
Because a lat long position might not have a proper name, or it might refer to different names altogether.
Let's say, it points to the exact center of a square of undeveloped land, surrounded by 4 streets.
Depending on a country's rules & regulations, the owner of the land might be forced to 'attach' that piece of land to one of the 4 streets... or the land might be 'address-less' (only defined by its boundaries). In the latter case, the land might be attached to all 4 streets, allowing future purchaser/developer to choose the most 'catchy' address.
Or, a building just got renamed. For awhile, people won't recognize the new name. It's just wiser for reverse geocoding to return both the old name and the new name.
Another possibility is for the reverse geocoding to return "defined" names within X meters around the lat long position.
I'm using Android's Geocoder to get street and suburb for my App, however on some roads, it will return State Route 60 for example, rather than the actual road name.
I'm in Western Australia if that makes any difference.
Is there a way around that ?
Or will I have to guess the street based on latitude and longitude ?
And in the same vein - the Geocoder returns streets as "St" and Roads as "Rd".
I can't find a default way of expanding that. If there is one, I would love to know about it.
I ended up changing the amount of addresses that the getFromLocation method returned to 2, and then adding logic in to detect when the first address is returned contained State Route.
When the first address returned State Route, it would use the second returned address instead.
In my app, I have a list of locations, and I want to create filter settings. I am looking for a way so that a user can pick maybe a continent or country or address and then filter out the locations from the list if the location is within the continent or country or close to the address.
Is there a google maps v2 api for android that can do something like:
public Boolean AddressIsContained(String address, String place);
which returns true if address is within place (place could be like a country or continent). And also like
public Boolean AddressCloseTo(String address1, String address2, int distance);
which returns true if address1is within distance amount of kilometers to address2. And this would just be a straight line between the addresses, nothing like a bike, walk, car or plane route.
Also for the list of locations, I am also able to access its lat/long if that makes it easier.
Thanks
For the start I assume you are familiar with the GeoCoder and / or GeoCoding API to get the addresses for your locations.
If you use the GeoCoder you will get a List of Address objects. The Address class provides some methodes to get the country or city name f.e. These methods you can use for your filter.
The Location class includes the methods distanceBetween() and distanceTo(). These you can use to check the distance between your locations.
Why if I take the andress with this code List<Address> loc = getFromLocation(lat,long,1); the address is correct but the civic number is wrong because if I put the latitude e longitude into Sygic it give me another civic number.
Example :
Via Merulana 19,Roma (with getFromLocation)
Via merulana 15/16,Roma
(with sygic when I put the longitude and latitude)
Because they are different services. getFromLocation uses the reverse geocoding provided by Google, as for Sygic, they probably use their own service. Reverse geocoding isn't expected to have that degree of accuracy (ie match the exact house number).