I'm trying to get the path between two geo points on my android app, i don't need any driving directions - just path. What I've already found myself is to draw the straight line between two geopoints (http://djsolid.net/blog/android---draw-a-path-array-of-points-in-mapview). Is it possible to get the actual path? I mean path which I can really walk, road path - not just straight line between two geopoints without parsing the google maps web URL ?
I think the best solution is called android internal map activity to show route between two geo points. Please refer to the code below:
String uri = "http://maps.google.com/maps?saddr=" + currentLatitude+","+currentLongitude+"&daddr="+fixedLatitude+","+fixedLongitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
It's called built in map activity and draws a route path between current and fixed latitude and longitude.
Related
I want to draw a path on map between known points(lat, long) using:
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr="+source_latitude+","+source_longitude+"&daddr="+destination_latitude+","+destination_longitude;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
But instead of just drawing route, Google Maps shows menu Car/Bus/By foot, trying to make a route from my current location to those points. What am I doing wrong? Is it still possible to draw route on map using the method above?
By running this intent you are basically opening an "outside" application - Google Maps that is not related to your application. the behavior you are receiving is the behavior that should be for the version of Google Maps you have in your phone. You can't edit the way it behaves, only the things that you are allowed to change using the settings screen of this application.
You have to parse the xml or json that your are using in the url in an Asynctask class and draw it on the map.
I want to draw routes on Google Maps (walk or drive), I want to give intent the current user coordinates and the destination coordinates, to draw and navigate the route, as this image
I used this code
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);
but I got "No route found"
Thanks a lot
You can't do that with intent. You should use JSON request with http://maps.googleapis.com/maps/api/directions/output?parameters. If you use JSON request, you must make it like this example, just add your coordinates : String url = "http://maps.googleapis.com/maps/api/directions/json?origin="yourlat","yourlong"&destination="secondlat","secondlong"&sensor=false";
This may help: Android draw route on a Mapview with twoo POI-s and this How do I draw a KML file on a MapView in Android?
I want to set paths on a Google maps. I’ve done some coding and able to draw single paths on a Google map. I want to know if there is any method to accomplish my objective. How can I do this?
want to show multiple paths between two Geo coordinators.
I’m new to this and can you please help me to do this. Thank you.
try this
String uri = "http://maps.google.com/maps?saddr=" + (srcLocation.getLatitude())+","+(srcLocation.getLongitude())+"&daddr="+destLat+","+destLon;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
Draw route using this. This is for one route.
I want to draw path from one location to other location. How to plot the path between the two locations. I have coordinates(latitude,longitude) for both locations. How can i achieve this functionality? I am working on android sdk 2.2 . I don't want to use kml.
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://maps.google.com/maps?saddr="+ latitude + "," + Longitude+ "&daddr="+latitudeDb+","+longitudeDb+""));
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);
You Can Use Following Intent and pass Your Source and destination latitude and longitude ,and
Next Actvity shows Path Between your geo points.
Perhaps this will server your need (from google) - http://code.google.com/apis/maps/documentation/javascript/
Can i draw three route in my application(use google map api),i can draw a route with kml,
now i want to draw three different route between two points,such as foot, bike, bus and so
on.
String uri = "http://maps.google.com/maps?saddr=" + lat+","+lon+"&daddr="+lat1+","+lon1;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
I think this may help you.
Yes you can draw a route in Android on a map, you may want to start by saving your GPS points into a database.
You could also just use the Google Maps API to do this for you automatically.