This is the problem with Graphic object. The object can have a Map of data that can be retrieved when the user clicks on the drawn Graphic on the map. One of the constructor of the Graphic class has a parameter with type Map<String, Object> to store data, but somehow, when I retrieved it using Graphic.getAttributes() and access the value inside the Map, it returns a string (or ClassCastException when I try to cast it to an object of desired type, which of course, is derived from Object class)
It seems that the method cast all the Map values into string (maybe using toString() method). This is quite problematic, especially when the user wants to put a custom Object type to the Map as value.
The Graphic object should be able to store and return back the object without changing it to String
HashMap<String, Object> data = new HashMap<String, Object>()
MyObject obj = new MyObject();
Graphic g = new Graphic(point, image, data);
MyObject selected = (MyObject) g.getAttributes().get("data"); // Exception here