Comments (3)
Just wanna share what I have done
`
//put List on declaration
List<Polyline> polylines = new ArrayList<Polyline>();
@Override
public void onDirectionSuccess(Direction direction, String rawBody) {
if (direction.isOK()) {
for (int i = 0; i < direction.getRouteList().size(); i++) {
Route route = direction.getRouteList().get(i);
mMap.addMarker(new MarkerOptions().position(origin));
mMap.addMarker(new MarkerOptions().position(destination));
ArrayList<LatLng> directionPositionList = route.getLegList().get(0).getDirectionPoint();
polylines.add(mMap.addPolyline(DirectionConverter.createPolyline(this, directionPositionList, 5, Color.RED)));
}
setCameraWithCoordinationBounds(direction.getRouteList().get(0));
//btnRequestDirection.setVisibility(View.GONE);
} else {
//Snackbar.make(btnRequestDirection, direction.getStatus(), Snackbar.LENGTH_SHORT).show();
}
}`
And then when I want to remove polylines, I create a button to clear all my polylines
public void Clear(View view){ for(Polyline line : polylines) { line.remove(); } polylines.clear(); }
I hope it helps
from googledirectionlibrary.
When you call googleMap.addPolyline()
it returns the instance reference. Assign it to a variable, and then you can use the methods within the Polyline
class. With the reference you can call Polyline.remove()
.
private Polyline directionsPath;
directionsPath = googleMap.addPolyline();
directionsPath.remove();
from googledirectionlibrary.
Thank you @starr0stealer wasn't aware that an instance is returned!
from googledirectionlibrary.
Related Issues (20)
- Does this lib caches API calls? HOT 1
- This API project is not authorized to use this API. HOT 1
- Directions rawBody is created on main thread HOT 1
- how to change marker icon place A and place B HOT 2
- OVER_QUERY_LIMIT Error HOT 1
- How can I get total distance?
- java.lang.NumberFormatException: Expected an int but was ...
- How to show marker text HOT 1
- KEEP GETING REQUEST DENIED HOT 9
- com.google.maps.android.BuildConfig is defined multiple times
- GOOGLE DIRECTION :: ISSUE WHEN ADD DEPARTURE TIME TO REQUEST HOT 1
- Support for parameter "traffic_model" HOT 1
- dptopx got nulled exception in v1.1.1 HOT 2
- After add waypoint with .and, it stop draw polyline after 1st waypoint in route HOT 5
- HIGH USAGE
- Production release with pro guard enabled NPE HOT 1
- How to update polyline according to the user current location? HOT 5
- how to turn-by-turn navigation in app? HOT 2
- how to calculate speed for TransportMode.DRIVING?
- How we use header for you SDK
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from googledirectionlibrary.