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

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)

Related

How to create a custom Get Location button for a Google Maps App and conduct a search?

I'm new to Android App Development and wanted to create a very simple Google Maps based App.
So far I have created a basic App which immediately shows your location via GPS on a map as soon as you start the App. I have also managed to get the Google location button on screen, which goes to your current location when pressed.
However, I have made a custom button image and wanted to replace the default button with my own. Is that possible, and if so, what is the best way of going about that?
Also, I require my App to conduct a search upon opening using Taxis as the search criteria, is this also possible?
Sorry if these are such noobish questions, I'd appreciated any help I can get.
Many thanks, Bill.
Answer 1 - I have made a custom button image and wanted to replace the default button with my own. Is that possible, and if so, what is the best way of going about that?
Yes. You can change default image to your own custom image.
Put address that saved your image like this pattern "#[package:]drawable/drawable_resource" to android:src= in <ImageView>.
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="#drawable/myimage" />
Then you should declare your location button, event, method.
If you need more specific information, refer to this Google map for android my location custom button.
In addition, if you need information about custom control, refer to this.
Answer 2 - I require my App to conduct a search upon opening using Taxis as the search criteria, is this also possible?
When you calculate directions, you may specify the transportation mode to use. By default, directions are calculated as driving directions. Refer to this Travel Modes.
You can access additional information for the VehicleType objects as described below.
<VehicleType.SHARE_TAXI>: Share taxi is a kind of bus with the ability to drop off and pick up passengers anywhere on its route.
If you need more specific, Refer to this How to specify “VehicleType”.
Sorry for the delay in getting back to you. Those are great answers and will help a lot.
Now to have fun creating this thing (or at least attempting!).
Thanks again and take care, Billy.

How to rerequest specific route alternative using Google Maps API

I am working on a service where a user plans his route using the Google Direction Service. GDS returns (if available) alternatives and the users can choose one of these for later usage. This part works: I know how to do the first request including getting alternatives back.
My problem is: how do I rerequest that specific alternative. For instance: if I want to redisplay the route and send the request to Google, it serves me the three alternatives... But I want to show the chosen one. I thought GDS would give the discriminating waypoints it uses to make the alternative, but it doesn't. As far as I see there is nothing discriminating, but I'd like to hear your thoughts on this.
A different approach would be to either remember the summary or the route index or both. I would then use one of those (or both) to select the alternative from the set. But this is only possible if the summary and/or the index does not change. And it is a bit of a cumbersome way.
Another approach is to try to find the discriminating waypoints ourselves, but this seems too hard to handle...
Any thougts on this are welcomed!
Frank

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.

Android, preferred method for accessing 10,000+ record database on server

So I am in need of some assistance in trying to determine what I am going to need in order to accomplish a task.
Plain and simple...I am looking at accessing multiple databases some of which may contain over 10,000 records via Android. From what I have seen web services that return JSON is the way to go for something of this nature, but I don't think that fully answers my question or know if this is the preferred way to go about this.
Digging a bit deeper...I have a few apps on the market now, but this will be my first attempt at an enterprise style app, and I have accessed public web services with a lot smaller footprint than what this is going to be. I have little to no experience within the realm of server/network administration which is where I am getting tripped up. This is from the ground up and I have to ability to obtain almost any resources I need to complete this task.
It appears that there is a SQL Server 2008 on the back end if that helps. If I need to provide further details let me know. I am looking at a solution that will handle organizational growth, scalability, authentication and ease of user...so keep that in mind too.
So what is the best practice/preferred method for doing an enterprise application with a substantial data set? What are the big dogs doing, and how? Both on the client side and server side. I am trying not to "screw the pooch" out of the gates on this, and this is one of those measure twice and cut once situations which is why I am trying to garner plenty of input and assistance.
Thanks in advance!
If you don't have an API/service yet, you need to write one on top of your database.
I can think of two approaches, depending upon your use case.
Paging: Setup an API that supports paging, and show the results page by page. The user can't possibly view 10000 records in one go.
Search and suggest: Try creating a suggestion list, when the user starts typing out something. Fetch results that start with the initial characters entered. However, the API should limit the results to a comfortable number, so that you don't have to parse a lot.
Depending on your use case, you could try one of these.

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

Categories

Resources