简体   繁体   中英

Assign ID's to Polylines in Android Google Maps

I want to assign ID's to multiple Polylines that I am making based on coordinates. The reason is so that I can refer to a particular Polyline when needed.

Here is my sample code for making Polylines.

 PolylineOptions lineoption = new PolylineOptions().add(new LatLng(a1, b1))
                .add(new LatLng(a2, b2))
                .color(Color.GREEN);
        line = mMap.addPolyline(lineoption);

What data-structure would be best for storing multiple Polylines with their respective ID's?

thanks in advance!

Take ArrayList to save the coordinates you can directly give that arraylist to polyoptions for drawing polyline on map. If you want index of the polyline then take one HashMap integer holds index for polyline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM