Comments (3)
with the newest PR and the implemented listener this is getting easy =)...by assigning the polyline to a variable (to keep track) I can then remove the old line before adding the new one like this:
if ( route != null ) {
// remove any existing routes to other markers
route.remove();
}
route = map.addPolyline(polyoptions);
from google-directions-android.
Hi, thanks for this library that works perfect. I have a question and i hope you can get me into the right way.
I draw a route from two point (fixed), and clicking in the infoview the route (polyline) will drawn into the map and it works. By the way i have 20 different marker, and i want to draw a route only when click on the infoview. I mean, if there is already a route in the map, clicking in one other infoview, this route have to be removed and the new one has to be added in the map.
I have a Switch-case method to call each route by clicking in the infoview of the marker, this is a snippet of my code:
switch (markerIndex){
case 0:
start = new LatLng(22.28861858, 11.32771726);
end = new LatLng(22.48861858, 11.36779726);
Routing routing = new Routing(Routing.TravelMode.WALKING);
routing.registerListener(ActivityOutdoor.this);
routing.execute(start, end);
break;
case 1:
start = new LatLng(21.48861858, 11.32771726);
end = new LatLng(23.48861858, 13.36779726);
Routing routing1 = new Routing(Routing.TravelMode.WALKING);
routing1.registerListener(ActivityOutdoor.this);
routing1.execute(start, end);
break;
default:
break;
}
Do you know how to remove the previous route, when click the other infoview?
I used map.clear(); but it will delete all the content of the map
Thanks in advance
Brus
from google-directions-android.
I'm not sure if this would work.. Though try to free the routing object object before plotting routing1
Or
rather than declaring routing1.. Overwrite routing and the previous one should disappear
Hope this gives u a slight idea ..
One more thing.. There's a lot of redundancy,. U can declare start, end and routing outside the switch statement..
Have the switch cases involve with start and end only .. once the values are selected.. Initialize routing outside the switch and start calling routing functions. Note that This way you are only storing one route.
I am not a contributor, though I got a similar project.
Sent from my iPhone
On 14 May 2015, at 8:43 pm, brusasu [email protected] wrote:
Hi, thanks for this library that works perfect. I have a question and i hope you can get me into the right way.
I draw a route from two point (fixed), and clicking in the infoview the route (polyline) will drawn into the map and it works. By the way i have 20 different marker, and i want to draw a route only when click on the infoview. I mean, if there is already a route in the map, clicking in one other infoview, this route have to be removed and the new one has to be added in the map.
I have a Switch-case method to call each route by clicking in the infoview of the marker, this is a snippet of my code:
switch (markerIndex){
case 0:start = new LatLng(22.28861858, 11.32771726); end = new LatLng(22.48861858, 11.36779726); Routing routing = new Routing(Routing.TravelMode.WALKING); routing.registerListener(ActivityOutdoor.this); routing.execute(start, end); break; case 1: start = new LatLng(21.48861858, 11.32771726); end = new LatLng(23.48861858, 13.36779726); Routing routing1 = new Routing(Routing.TravelMode.WALKING); routing1.registerListener(ActivityOutdoor.this); routing1.execute(start, end); break; default: break; }
Do you know how to remove the previous route, when click the other infoview?
I used map.clear(); but it will delete all the content of the map
Thanks in advance
Brus—
Reply to this email directly or view it on GitHub.
from google-directions-android.
Related Issues (20)
- getDistanceValue and getDurationValue always return 0
- Optimize is not working HOT 1
- LatLng[ ] on a waypoints not working
- How to solve gradle syn failed error:(2, 0) defaultmavenfactory HOT 2
- Issue when using the gradle library and the RoutingListener
- Do not work AutoComplete HOT 2
- Cannot resolve prediction.getDescription
- Error HOT 2
- Unable to run project,downloaded zip
- More than Two location HOT 1
- Segment have no getPoint, why ?
- cloned built & get this error: HOT 2
- Traffic mode
- Check if user has deviated from the route?
- Which License
- Alternatives HOT 1
- java.lang.ClassNotFoundException(Api$ClientKey)
- How to get route exactly country? HOT 1
- Creating ANR While using this Lib
- Not working if Api key is restricted
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 google-directions-android.