how to know if a polyline is showing on the map?

0

my android project contains some markers, my idea is that by clicking on a marker a polyline is generated up to the marker from my current position, the problem that I have, is how to know if the polyline exists to erase it and add the new polyline, I hope you can help me

This is what I have, I do not know how to make the if that determines if the polyline exists

 map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
            @Override
            public boolean onMarkerClick(Marker marker) {
                if (!location.hasLocationEnabled()) {
                    // ask the user to enable location access
                    SimpleLocation.openSettings(RutaHasta.this);
                }

                LatLng marcador= new LatLng(marker.getPosition().latitude,marker.getPosition().longitude);
                LatLng posicion=new LatLng(location.getLatitude(),location.getLongitude());

                Polyline polyline=map.addPolyline(new PolylineOptions().add(marcador,posicion).geodesic(true).color(Color.GREEN).width(7));

                return false;
            }
        });
    
asked by zhet 14.12.2016 в 04:45
source

0 answers