I use the following code:
uri = "geo:"+lat+","+lon;
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
My questions are:
1. I understand I need internet connection to use this? Is there a way to show offline Maps?
2. It opens the map with location, but without showing the point on the map. Anyway to add this with code?
The android documentation is good here: MapView
You will need an internet connection. The map data is massive and couldn't possibly be entirely cached on your phone. Don't forget to add the line in the manifest that says your application uses internet. Maybe there is a way to cache a small area if you know you will always be working with the same area, but I don't know of a way.
To show a point on the map look into "overlays" in the link I added.
Hope this helps.
Related
in my android application I want the user will be able to choose some location and to get this location back to the application code.
something like startActivityForResults.
Does it's possible?
I know that it is possible with all the google service sdk and all of this,
but I want to use only the content intent, like described here:
https://developers.google.com/maps/documentation/android-api/intents#overview
and here (in the maps section):
http://developer.android.com/guide/components/intents-common.html
thanks a lot.
There is no requirement for an Android device to have an app that does what you want. There is no standard Intent structure for this, either.
I have an android app and I don't want to build my own maps.
I just want to send the address to Google Maps with:
Uri IntentUri = Uri.parse("geo:0,0?q=" + GETcity+ "," + GETstreet +" "+GEThouseNumber);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, IntentUri);
startActivity(mapIntent);
Do I need any permissions for that?
Is this an ok way to do it, or there a better way to build my own map?
does i need some permissions for that ?
When you launch another application to handle some task (such as taking a picture or getting the user's location), you do not need any permissions. The app you are launching is responsible for requesting the appropriate permissions.
that is ok to do it ? or its better to build my own map.. ?
This is completely up to you. If the defaults map applications provide all the functionality you want, then you probably don't need to worry about it. If you are worried that the user won't have a map app installed, or you want to provide some UI elements that the default applications don't offer, you may want to make one yourself.
Personally, I don't want to deal with the complexities that come with creating a mapping application.
No permissions needed.
If you wish to implement the Maps API, then you will need to add the specific dependencies and include the Locations permissions.
I know it is possible to start google maps with a route of 2 points but I really need to start it with many waypoints. How can this be done?
And another big wish would be: (I really doubt that this is possible but who knows?)
Can you somehow put those waypoints information into an intent so that it isn't necessarily for google maps but for ANY navigation app? So that the user can choose his own navigation app...?
Ok I found a way to do it with google maps:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("https://maps.google.ch/maps?saddr=[address1]&daddr=[address2] to:[address3] to: [address4]"));
startActivity(intent);
(Replace [address#] with the waypoints)
The problem is that the google maps app doesn't show all the waypoints but only the first and the last. I'd really like to make all waypoints visible and to make navigation actually navigate you to the points and telling you when you've reached one, but google doesn't seem to think that this is needed...
I'm new to Android; I'm able to get the current location using GPS but how do I get the surrounding location details using the current location obtained? Please guide me.
Use this :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=business+near+city");
startActivity(intent);
After geo you put your coordinates, and after q= you input your search tearms, like tourism+city. This will fire up the Google Maps app with the points of interest.
If you want to use a maps view inside your application, you would need to get the data from some service, like your own. However you could pull the data from Google's ajax search like this
http://ajax.googleapis.com/ajax/services/search/local?v=1.0&rsz=large&gl=pl&q=tourism+chicago
more info :
http://code.google.com/apis/websearch/docs/reference.html#_fonje_local
This will give you results that have geo-coordinates and you would need to make a way of parsing the results and maybe get them into a database.
hope it helps...
Some questions about Android and Google Directions Service:
Is there a native way on Android to use the Directions Service from Google or are there any nice Wrapper Frameworks?
I would like to retrieve the time needed to get from A to B and maybe show the route in a table and/or map.
As far as I know directions can only be retrieved for "walking" and "driving". Is there a way (maybe not from google) to get this Information also for public transports or "biking" ?
I don't know exactly if this is what you want, but you could fire up an intent like this:
String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
To get biking directions add "&dirflg=b" to the url. For public transport add "dirflg=r".
This will display the route in the google Maps app. If you want to get this in your app inside a mapview, please see this code at github. You could hack into the code to add biking and public transport functionality.
Hope this helps somehow.