Reputation: 21
[enter image description here]
1I want to draw the dotted line in android using map box to show a route to user. Something like that image when I click on the marker it should show that dotted line.
Upvotes: 2
Views: 1567
Reputation: 2546
See the following examples that are related to what you want to achieve
Upvotes: 0
Reputation: 1049
One marker requires one LatLng point information only, therefore it's working perfectly. However, a line connects between two points or more, polyline connects two or more consecutive points. In your code, you only put one point, which is not enough to make even one (poly)line. You need to add more points to the PolylineOptions, like the following example:
ArrayList<LatLng> points = new ArrayList<>();
// add two or more different LatLng points
points.add(new LatLng(-7.955, 112.613));
points.add(new LatLng(-7.956, 112.616));
points.add(new LatLng(-7.958, 112.619));
// or add from other collections
for(TrackPoint trackPoint: this.trackPoints)
points.add(new LatLng(trackPoint.latitude, trackPoint.longitude));
// create new PolylineOptions from all points
PolylineOptions polylineOptions = new PolylineOptions()
.addAll(points)
.color(Color.RED)
.width(3f);
// add polyline to MapboxMap object
this.mapboxMap.addPolyline(polylineOptions);
Hope this helps.
Upvotes: 0