In my android project I want to draw route on Google maps. I have coordinates of start and end points. On this points I get km-file from Google web service with points witch across route. For drawing parts of route I use instances of Overlay class. And this solution works, but very slowly. Are there another methods to do that? May be exists ability use built-in Google maps application or any another way?
Right, you can use the built-in google maps application via an intent like this:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345"));
startActivity(intent);
see this question for more details
there's a tutorial for using KML here:
http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html
and some sample code here:
How to draw a path on a map using kml file?
it all looks like a lot of overly-complicated hard work - Google should provide API's for this instead.
Related
I am looking for a way to open turn-by-turn navigation on Google Maps. I know that from this google article it can only be defined by start and end points.
First option (preferred):
I haven't find any intent in Google Maps that does exactly what I want. Does anyone know if there is one?
Second option:
I have tried other ways to reach what I want. I have tried to create a custom route on maps.google.com (from desktop browser) and open it from Android device.
The link has the following format
https://www.google.com/maps/dir/37.7851009,-122.4049193/37.7817261,-122.4008209/#37.7815141,-122.4059922,16z/data=!4m19!4m18!1m15!3m4!1m2!1d-122.4055931!2d37.7834466!3s0x808580868ad307fd:0xa75b816ccbe984a0!3m4!1m2!1d-122.4061769!2d37.7812298!3s0x80858086b49a3cfb:0x23f20e98c029217c!3m4!1m2!1d-122.4031591!2d37.7817777!3s0x80858080cb0a7eb1:0xdc77f5df810aebcd!1m0!3e2
Instead of opening turn by turn navigation, it open Google Map Android application with the route displayed on the map. This is the nearest of what I want because there is the button that can show turn-by-turn navigation.
I don't know if it is possible to create link of this type from a collection of (lat,lng) geographical points. I see that data parameter is the one containing the route.
Does anyone know how to reach it? If it is possible, I think that I can create links in my Android app to open with Google Maps App. (Actually I haven't tried to put this link manually to my app, but I assume this to work.)
Update:
I don't want to find a route from point A (start point) to point B (end point). I have all the route from start to finish in geographical coordinates. So, any solution that is of the form direction from A to B are not solution to my problem.
As of 2018, you can open Google Maps app in navigation mode using the Google Maps URLs. Google Maps URLs build a universal, cross-platform URL to launch Google Maps, so you can use them with your intents.
The Google maps URLs in navigation mode support origin, destination and waypoints.
E.g.
String url = "https://www.google.com/maps/dir/?api=1&destination=Madrid,Spain&origin=Barcelona,Spain&waypoints=Zaragoza|Huesca&travelmode=driving&dir_action=navigate";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
I hope this helps!
This is from the Documentation:
Alternatively, you can supply an encoded set of coordinates using the
Encoded Polyline Algorithm. This is particularly useful if you have a
large number of waypoints, because the URL is significantly shorter
when using an encoded polyline.
Encoded polylines must be prefixed
with enc: and followed by a colon (:).For example:
waypoints=enc:gfo}EtohhU:
You can also include multiple encoded
polylines, separated by the pipe character (|). For example:
waypoints=via:enc:wc~oAwquwMdlTxiKtqLyiK:|enc:c~vnAamswMvlTor#tjGi}L:|via:enc:udymA{~bxM:
The following URL initiates a Directions request for a route between
Boston, MA and Concord, MA with stopovers in Charlestown and
Lexington, in that order:
https://maps.googleapis.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&key=YOUR_API_KEY
Source: https://developers.google.com/maps/documentation/directions/intro#Waypoints
You can try to check this documentation/tutorial on how to use turn by turn directions with the Google Maps API. It uses Google Maps Javascript to provide advanced functionality.
And about voice navigation feature, I think this SO question and link can help you.
Voice navigation possible in google map api?
Turn-by-Turn Navigation for Walking and Driving
I need to implement a map for a shopping mall in my app. This map needs to have a way to visually mark the fastest path to go from one place to another.
I currently have two options in mind. I could use the Google Maps API, overlay the shopping mall's picture and try to use some algorithm to mark the best route. Or, I could just place the picture and manually make an algorithm to mark the path (probably Dijkstra).
Yet, it's my first time working with Android, and I don't really know which one could work the best, and which libraries I could use.
I'd appreciate any tip or suggestion.
Google map has an android api that you can directly embed google maps into your application. You can also draw overlays using its api. Take a look at
google map android api
do you know how can we create our map and show the ways from a certain locations to destinations ? Without using google map , just using a picture of a map , is there any way to draw routes on it?I am not asking projects or codes , just need some suggestions related to drawings and considering the obstacles in the way ?Thank you
You should have your way points in somewhere(maybe in db or in xml file etc) and also for getting map base you should have a map provider like yahoo, bing, google or openstreetmap(which is free to use - no api key needed considering others)
after having these two sources you can use Geoserver(which is opensource map data manipulater and provider) to put these sources together and get them as map base image.
considering your "just using a picture of a map" is an owerwellming issue. Because you will have to do some calculation to find where to put your points programatically. So Geoserver does that automatically.
also I suggest you to hava a look at osmdroid and osmbonuspack they may help.
I am doing the project about map navigation. Currently I work fine with the mapview with GPS and singal route directing. But I can not find anyway that, show the all possible choices on the map, like google map on web.
For example I like to search what restaurants are around my area, so I type "Restaurant" in search bar and search it, the map shold display my current position (I have done this) and also show all the possible restaurants that near my area. After that I pick up one restaurant, and the map will draw the route from my position to the restaurant (I have done this too)
I have spent many time search on internet but couldn't find any critical example explain about this, is there any tutorial I can refer to?
Should I use "webview" to directly show the google map web page on app?
I also meet other problem, I use the way below to directe my route on map, it suppose to draw the route on my app, but insted of that the phone will directly oepn google map and drawn the route on google map, am I do this wrong? Is there any better way?
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setData(
Uri.parse("http://maps.google.com/maps?f=d&saddr="
+GeoPointToString(fromGeoPoint)
+"&daddr="
+GeoPointToString(toGeoPoint)
+"&hl=cn")
);
startActivity(intent);
I am the very new beginner of android programming, hope this is not a silly question, wish you can help me. thanks
If you're trying to make an app using Google Maps, you should use the Google Maps API!
https://developers.google.com/maps/documentation/android/
You should be able to download it via your SDK manager in eclipse, or manually install it. I'm using it at work right now, but be wary that you cannot make a commercial app for navigation using these maps.
I want to integrate Google Sky Map in my application. Does it have an API?
What steps should be taken to integrate with this service, and how can I integrate it in an application?
Was also looking for a way, but didn't find one.
One of the developers said this 6-7 months ago about integration/API
I'm one of the developers on the Sky Map project. At present there
are no intents defined beyond the search intents. If you just want to
point at a particular named target you could try those. At the moment
we don't support kml or other Intents though.
If you do happen to find some new information, please share.
To call Google Sky Map from within your application:
Intent i = new Intent(Intent.ACTION_SEARCH);
i.setPackage("com.google.android.stardroid");
i.putExtra(SearchManager.QUERY, "mars");
startActivity(i);