Giter Club home page Giter Club logo

Comments (3)

exside avatar exside commented on June 30, 2024

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.

albersmc avatar albersmc commented on June 30, 2024

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.

alhinai-hamed avatar alhinai-hamed commented on June 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.