I want to draw navigation path like google navigation path of blue line . How should I draw?
-
Possible duplicate of [Android: How to draw route directions google maps API V2 from current location to destination](https://stackoverflow.com/questions/14444228/android-how-to-draw-route-directions-google-maps-api-v2-from-current-location-t) – Stanislav Bondar Jul 10 '17 at 11:20
-
I don't want to use the google api ,I just want to implement the function that draw a blue path – Crazy Zhang Jul 10 '17 at 11:28
-
Create a Custom View and Draw the line using Canvas and Paint by providing Path of the line. – Abbas Jul 10 '17 at 11:30
-
I have a special demand that I have a lot of points, about one hundred thousand. I need to connect them to a path, but this will lead to stutters here .What's the best way to solve it? – Crazy Zhang Jul 12 '17 at 03:07
2 Answers
Use the following code for Pass intent to google Map.
String url = "http://maps.googleapis.com/maps/api/directions/xml?"
+ "origin=" + start.latitude + "," + start.longitude
+ "&destination=" + end.latitude + "," + end.longitude
+ "&sensor=false&units=metric&mode=driving";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(url);
startActivity(intent);
Hope It will Help You..

- 701
- 1
- 6
- 20
-
I have a special demand that I have a lot of points, about one hundred thousand. I need to connect them to a path, but this will lead to stutters here .What's the best way to solve it? – Crazy Zhang Jul 12 '17 at 03:08
-
You mean you have to connect multiple points (destinations) in gmap. If i am right, google allows you to connect only 10 point freely. More then ten you have buy key. Please refer the following link. It will help you. http://wptrafficanalyzer.in/blog/route-between-two-locations-with-waypoints-in-google-map-android-api-v2/ – Suresh Jul 12 '17 at 09:20
-
Maybe my English is not good, the problem description is not very clear. I do not want to use Google Map's api. I want to achieve the function that he painted the path but without success. I draw the path is very vague and ugly after enlarged. So I want to know if there is no way to draw the beautiful path like Google Map (ps: I have a lot of points).Thank you very much. – Crazy Zhang Jul 13 '17 at 10:12
Considering your specific question to just draw the blue path I would confine my answer to just drawing of blue path as one of the comments has already included the use of Google API to draw the route.
It is pretty simple:
// PolylineOptions that defines the characteristics of line
PolylineOptions mPolylineOptions = new PolylineOptions();
// points of line
mPolylineOptions.addAll(points);
// width of line that will be drawn
mPolylineOptions.width(16);
// and add the color of your line and other properties
mPolylineOptions.color(Color.parseColor("#1976D2")).geodesic(true).zIndex(8);
// finally draw the lines on the map
Polyline line1 = mMap.addPolyline(mPolylineOptions);
// change the width and color
mPolylineOptions.width(14);
mPolylineOptions.color(Color.parseColor("#2196F3")).geodesic(true).zIndex(8);
Polyline line2 = mMap.addPolyline(mPolylineOptions);
The points
are calculated using the Google Maps API for Android. What we are doing here is that we are not just making one line but two line with varying width and color. The line1
is the bottom line of dark color which will become the boundary (or stroke) of the line2
which is of the light color.
The .geodesic(true)
tells that the path to be drawn should be smooth on turns instead of sharp edges and .zIndex
specifies the stack order of this line, relative to other lines on the map. The default z-index value is 0.
The above code gives following line output:

- 4,222
- 2
- 20
- 29
-
I have a special demand that I have a lot of points, about one hundred thousand. I need to connect them to a path, but this will lead to stutters here .What's the best way to solve it? – Crazy Zhang Jul 12 '17 at 03:08
-
"One hundred thousand" is a great big deal! First let me know whether they are the points of the same path (i.e., they all lie on the same path) or they are just random points. If former is the case then the array list that you are using to store these points before adding it to the PolylineOptions reduce the size of the list by a factor of 4 or 5 and see whether the "stutters" are there if they still persist reduce them by a greater factor. If latter is the case then you may have to pay GOOGLE or visit the link that @Suresh provided. – patrick.1729 Jul 12 '17 at 17:50
-
Maybe my English is not good, the problem description is not very clear. I do not want to use Google Map's api. I want to achieve the function that he painted the path ,but without success. I draw the path is very vague and ugly after enlarged. So I want to know if there is no way to draw the beautiful path like Google Map (ps: I have a lot of points).Thank you very much. – Crazy Zhang Jul 13 '17 at 10:13