简体   繁体   中英

I can't add more than one line (overlay) to Android google-map?

I'm having problems with adding lines to the map in my android project. Basically, when I want to draw lines from point A to point B android is painting them just fine, but when I want to add another line later (say from point B to point C) android is removing the old line and drawing a new one. I guess it has something to do with collections because I'm using the ItemizedOverlay class to collect all markers and it seems to work, but how to do the same with lines or anything else I would like to draw? How to prevent android from refreshing the map? ItemizedOverlays seems to do the trick, but only with markers/drawables. Can someone please give me some help or at least point me in the right direction with this? I would greatly appreciate it.

See my reply with code samples at How to draw a path on a map using kml file? , it describes how to draw routes (consisting of multiple lines). Especially look at the Drawing / drawPath() section.

I have one class witch extends from Overlay that draws a line between X points in the draw method. i'have a for loop that creates one LineOverlay each time and adds it to mapView.getOverlays() with no problem.

If you want to remove one determined overlay you have to store somewhere in the class when you create them to call later to mapView.getOverlays().remove(LineOverlay item)

Hope i helped you.

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