Geocode Autocomplete mobile - android

I am trying to set up autocomplete with geocoding. If the user is typing in a name of a city, I want him get a few cities as a result. Vice versa with postal codes.
The new policy from google seems way too expensive (70.000 autocomplete requests = 200$ ?? )
I tried to solve it with the Xamarin.Forms.Maps.Geocoding implementation, but this does not seem to work at all... at least not under iOs. The result of GetPositionsForAddressAsync or GetAddressesForPositionAsync does return a List, but no matter what input I provides, it only contains just one value.
So in your opinion: What ist the best and cheapest way to accomplish a geocoding autocomplete solution? I have no problem spending money for it... I am just looking for the best solution.

You can take a look at OpenStreetMap based geocoders with autocompletion support, e.g. Photon. It's open-source as well.

Related

Android geocoder API

I'm trying to create an autocomplete textview to search for addresses and display them on my map, but i'm having some problems with the suggestion fetching.
For this i'm using the geocoder function getFromLocationName.
In order to get a response (and sometimes a pretty bad one) i have to input into the search a whole word plus a number, and for it to suggest something even close, the string has to be almost the same as the google name for that street.
Is there any other way yo make a street suggestion text field? So far i've solved the need for a number by adding " 1" to the input string if it didn't have any numbers in it, but it's still pretty far off of the way the suggestions work on google maps.
Thanks in advance for any tips you can give me.
The Geocoder APis aren't designed for this type of request. Usually you feed the full name of the street/city/etc to it and it will translate it into coordinates.
Use the Google Places Autocomplete instead. It will respones some suggestions for your input, which can be anything between one letter and the full address.
Note that you need to have a valid key to use this API.

Getting the nearest results in Geocoder and show them and some other questions about Geocoder

I am working on an application which will have a textview/searchview or a more preferrable way to take a String, make a search of that string and show some results. And whenever the user clicks one of the result it will take user to the another Intent which have a map that points to the clicked results.
I am searching this for days, I read many articles in here, or in Google Developer pages, I know that I need to use Geocoder, and for this I think the best one for my app is this Google API
http://maps.googleapis.com/maps/api/geocode/json?address="+geocodingSearch+"&components=country:TR&sensor=false";
geocodingSearch will be the String that written by user.
*My first question is does sensor=true makes a big difference? Do you prefer to use it? Or do you prefer something else?
*In Google's example it uses region=es in one of them and components=country:ES in another of them. What are the differences between them? Also does it works perfectly, or using borders is better?
*I don't have any problem of parsing JSON answer, but I am not sure about how to show the results. I want it to be seen as the way that search results as in the bottom. It doesn't need to make a search as the user types, but the result part will be better like this. Do I need to use a SearchView or something else?
*And the final question is written in the title. Is it possible to get the nearest results at top in Google API part (I am able to get the Location), I don't want to limit by borders, but getting the nearest results will be better. If this is not possible I will try to sort them by making calculations with LatLong values.
Thanks in advance, and I will be greatful by your helps.

Querying the time using Google Search Results

This one is puzzling me...
For my Android application I want to be able to return the current time in any location the user requests (right down to city level). The request itself comes from a voice command, so I cannot use alternative methods.
The most obvious way (so I thought) was to query Google, but I need your brains to help me solve how to extract the data I want please!
In Google, query:
"What's the time in China"
You should see a 'widget' at the top displaying the answer nicely. View the page source and search on 'China' and it's there - I thought great, this is going to be easy!
But...
"What's the time in London"
Although the display in Google appears the same, there is no result for 'London' when searching the source HTML...?
Using Google Chrome, I inspect the element of the 'widget' and can then view the contents I wish to extract in all cases.
So, my questions is firstly, am I missing something obvious (Google don't want us to be able to do this for example)? Or is there a way to 'force' the result to be in the HTML by structuring the query perhaps?
Secondly, is there a way to access the specific 'element container' and return the results to my Android Application?
I thank you in advance...
You should really use an API instead of parsing html.
I guess there are many many API which will give you the time in a given city.
http://www.worldweatheronline.com/time-zone-api.aspx for example (havnt tried it myself)
If you still want to extract data from the google result (which is html), check for html parsers like in this post : Parse HTML in Android

Location-aware geocoding on Android (just like Google Maps)

It seems that the search in the Google Maps app is location aware. For example, if I search for "Pitt St" while in Sydney, it finds the right street straight away. Clicking "Did you mean..." brings a list of other "Pitt St" close in nearby suburbs.
Is there a way to ge a similar experience in our apps? I tried the standard Geocoder, but a similar search returns "Pitt St, New York" as the first match.
Is there a set of options I'm missing?
Is there a different API we can use for this?
As a last resort, do you think it's reasonable to implement this manually, for example by querying the Geocoder with a max radius of 1km, 10km, 100km, and then sorting the results by distance?
Cheers
Romain
Which function did you use? Geocoder.getFromLocationName() takes a bounding box that allows you to limit the results to a certain region, so you could get the current GPS position first and pass that in.
Alternatively, you could go through the Geocoder API which is more flexible, but also more restrictive in terms of the TOS, not to mention a lot more work to use. (I'm not sure if using it from an Android app is covered in the TOS, I haven't looked at it much).

How to implement a search like the google maps address search?

I would like to create a search in my app which acts like the map search in the Google Maps app.
I have creates an an auto complete text view which updates dynamically based on the results of the Geocoder.GetLocationByName() Method.
However the results retrieved from this function are really bad and not at all consistent with the text I pass to it.
Is there a better method of doing this to achieve accurate results?
So it's not the geosearch that's your problem, but the autocompletion, right? Well I assume you need the whole set of possible values in order to obtain a decent auto-completion. Another way would be to take apart the google javascript code that performs the auto-completion and talk to their servers, pretending you're typing into one of "their" fields. However, this isn't only probably against their terms of service but also a bit shaky because they might a) detect and prevent this or b) change their interface in the future.
Your best guess would be to get a list of all cities, streets, etc in question.
hopefully this should be able to do the trick :=)
https://developers.google.com/places/documentation/autocomplete
good luck (testing it myself right now)

Categories

Resources