0

I was reading the documentation for polygons and polylines What is not clear to me is how could I keep a state associated with a polygon?
E.g. if I want to do an action on click that depends on whether the polygon was already clicked on or not how could I know that?
Could I use e.g. tag to add arbitrary info including if the polygon is in click/state?

Jim
  • 3,845
  • 3
  • 22
  • 47

1 Answers1

0

you can use setTag() with custom object which include click state and other data like

CustomDefinedObject data = new CustomDefinedObject ();// your defined object
data.isClicked=true
data.otherProperty=false
polyline.setTag(data);

and to retrieve info

CustomDefinedObject retrievedData = (CustomDefinedObject)polyline.getTag(data);
Mohammed Alaa
  • 3,140
  • 2
  • 19
  • 21
  • What happens to the `tag` during the activity lifecycle? Is it kept or not? – Jim Aug 14 '20 at 10:13
  • I came across this [thread](https://stackoverflow.com/questions/26518614/maintaining-dynamically-set-view-tag-on-orientation-change) ,to be honest I also suggest you to try to test it and see result in action – Mohammed Alaa Aug 14 '20 at 11:07