Java Code Examples for com.google.android.gms.maps.model.Polyline#remove()

The following examples show how to use com.google.android.gms.maps.model.Polyline#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GglMapAiLineManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void clearMarker() {
    if (this.polylineList != null) {
        for (Polyline polyline : this.polylineList) {
            polyline.remove();
        }
    }
    if (this.limitCircle != null) {
        this.limitCircle.remove();
        this.limitCircle = null;
    }
    this.polylineList.clear();
    this.mMarkerList.clear();
    this.mMapPointList.clear();
    this.interestMarkerList.clear();
    this.arrowMarkerList.clear();
    this.mSelectMarker = null;
}
 
Example 2
Source File: DriverMapActivity.java    From UberClone with MIT License 6 votes vote down vote up
@Override
public void onRoutingSuccess(ArrayList<Route> route, int shortestRouteIndex) {
    if(polylines.size()>0) {
        for (Polyline poly : polylines) {
            poly.remove();
        }
    }

    polylines = new ArrayList<>();
    //add route(s) to the map.
    for (int i = 0; i <route.size(); i++) {

        //In case of more than 5 alternative routes
        int colorIndex = i % COLORS.length;

        PolylineOptions polyOptions = new PolylineOptions();
        polyOptions.color(getResources().getColor(COLORS[colorIndex]));
        polyOptions.width(10 + i * 3);
        polyOptions.addAll(route.get(i).getPoints());
        Polyline polyline = mMap.addPolyline(polyOptions);
        polylines.add(polyline);

        Toast.makeText(getApplicationContext(),"Route "+ (i+1) +": distance - "+ route.get(i).getDistanceValue()+": duration - "+ route.get(i).getDurationValue(),Toast.LENGTH_SHORT).show();
    }

}
 
Example 3
Source File: PlaceMapFragment.java    From RxGpsService with Apache License 2.0 6 votes vote down vote up
private Polyline drawPath(List<LatLong> latLongs, int color, float zIndex, Polyline polyline) {
    if (googleMap != null && latLongs != null && !latLongs.isEmpty()) {
        PolylineOptions polyLineOptions = new PolylineOptions();
        polyLineOptions.width(getResources().getDimension(R.dimen._2dp));
        polyLineOptions.color(color);
        polyLineOptions.zIndex(zIndex);

        for (LatLong latLong : latLongs) {
            polyLineOptions.add(new LatLng(latLong.latitude(), latLong.longitude()));
        }

        if (polyline != null) polyline.remove();
        return googleMap.addPolyline(polyLineOptions);
    }

    return null;
}
 
Example 4
Source File: NearbyLocationActivity.java    From FaceT with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onRoutingSuccess(ArrayList<Route> route, int j) {
    if (polylines.size() > 0) {
        for (Polyline poly : polylines) {
            poly.remove();
        }
    }

    polylines = new ArrayList<>();
    //add route(s) to the map.
    for (int i = 0; i < route.size(); i++) {

        //In case of more than 5 alternative routes
        int colorIndex = i % COLORS.length;

        PolylineOptions polyOptions = new PolylineOptions();
        polyOptions.color(getResources().getColor(COLORS[colorIndex]));
        polyOptions.width(10 + i * 3);
        polyOptions.addAll(route.get(i).getPoints());
        Polyline polyline = mMap.addPolyline(polyOptions);
        polylines.add(polyline);
    }
}
 
Example 5
Source File: GglMapAiLineManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void drawPointLine(LatLng latLngDevice) {
    if (this.gglMapLocationManager != null && this.gglMapLocationManager.getDevLocation() != null) {
        Polyline polyline;
        if (this.polylineList != null) {
            for (Polyline polyline2 : this.polylineList) {
                polyline2.remove();
            }
            this.polylineList.clear();
        }
        for (int i = 0; i < this.mMarkerList.size(); i++) {
            PolylineOptions polylineOptions = new PolylineOptions();
            if (i == 0) {
                polylineOptions.add(latLngDevice);
                polylineOptions.add(((Marker) this.mMarkerList.get(i)).getPosition());
            } else {
                polylineOptions.add(((Marker) this.mMarkerList.get(i - 1)).getPosition());
                polylineOptions.add(((Marker) this.mMarkerList.get(i)).getPosition());
            }
            polylineOptions.color(this.context.getResources().getColor(this.lineDefaultColor)).zIndex(3.0f);
            polylineOptions.width(4.0f);
            polyline2 = this.googleMap.addPolyline(polylineOptions);
            polyline2.setPattern(PATTERN_DASHED);
            try {
                this.polylineList.add(polyline2);
            } catch (Exception e) {
            }
        }
    }
}
 
Example 6
Source File: MultiPolyline.java    From geopackage-android-map with MIT License 4 votes vote down vote up
/**
 * Remove from the map
 */
public void remove() {
    for (Polyline polyline : polylines) {
        polyline.remove();
    }
}
 
Example 7
Source File: DriverMapActivity.java    From UberClone with MIT License 4 votes vote down vote up
private void erasePolylines(){
    for(Polyline line : polylines){
        line.remove();
    }
    polylines.clear();
}
 
Example 8
Source File: HistorySingleActivity.java    From UberClone with MIT License 4 votes vote down vote up
@Override
public void onRoutingSuccess(ArrayList<Route> route, int shortestRouteIndex) {

    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    builder.include(pickupLatLng);
    builder.include(destinationLatLng);
    LatLngBounds bounds = builder.build();

    int width = getResources().getDisplayMetrics().widthPixels;
    int padding = (int) (width*0.2);

    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);

    mMap.animateCamera(cameraUpdate);

    mMap.addMarker(new MarkerOptions().position(pickupLatLng).title("pickup location").icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pickup)));
    mMap.addMarker(new MarkerOptions().position(destinationLatLng).title("destination"));

    if(polylines.size()>0) {
        for (Polyline poly : polylines) {
            poly.remove();
        }
    }

    polylines = new ArrayList<>();
    //add route(s) to the map.
    for (int i = 0; i <route.size(); i++) {

        //In case of more than 5 alternative routes
        int colorIndex = i % COLORS.length;

        PolylineOptions polyOptions = new PolylineOptions();
        polyOptions.color(getResources().getColor(COLORS[colorIndex]));
        polyOptions.width(10 + i * 3);
        polyOptions.addAll(route.get(i).getPoints());
        Polyline polyline = mMap.addPolyline(polyOptions);
        polylines.add(polyline);

        Toast.makeText(getApplicationContext(),"Route "+ (i+1) +": distance - "+ route.get(i).getDistanceValue()+": duration - "+ route.get(i).getDurationValue(),Toast.LENGTH_SHORT).show();
    }

}
 
Example 9
Source File: HistorySingleActivity.java    From UberClone with MIT License 4 votes vote down vote up
private void erasePolylines(){
    for(Polyline line : polylines){
        line.remove();
    }
    polylines.clear();
}
 
Example 10
Source File: PlaceMapFragment.java    From RxGpsService with Apache License 2.0 4 votes vote down vote up
private Polyline removePath(Polyline polyline) {
    if (polyline != null) {
        polyline.remove();
    }
    return null;
}
 
Example 11
Source File: PolylineManager.java    From android-maps-utils with Apache License 2.0 4 votes vote down vote up
@Override
protected void removeObjectFromMap(Polyline object) {
    object.remove();
}