Skip to content Skip to sidebar Skip to footer

How To Get The Specific Data In Click Of Polyline?

At the time of multiple data with the help of that I am plotting the polyline with lat and long value. Now when I'm plotting it, I'm to specific the line also because that the time

Solution 1:

You can maintain a structure (a Map for example) to store the data associated to the Polylines. For example (storing a String for each Polyline):

final Map<Polyline, String> polylines = new HashMap<>();

PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.addAll(coordinateList);
polylineOptions.width(10);
polylineOptions.color(Color.parseColor("#800080"));
polylineOptions.clickable(true);

polylines.put(mMap.addPolyline(polylineOptions), "Polyline data");

mMap.setOnPolylineClickListener(new GoogleMap.OnPolylineClickListener() {
    @Override
    public void onPolylineClick(Polyline polyline) {
        Toast.makeText(MapsActivity.this, polylines.get(polyline), Toast.LENGTH_SHORT).show();
    }
});

Post a Comment for "How To Get The Specific Data In Click Of Polyline?"