Opened 11 years ago

Last modified 11 years ago

#10674 closed defect

ConcurrentModificationException when addind multiple marker — at Initial Version

Reported by: yaghianth@… Owned by: The111
Priority: normal Milestone:
Component: JMapViewer Version: latest
Keywords: ConcurrentModificationException addMapMarker Cc:

Description

I am using a for loop to add markers about hotels to my map. But I am getting a ConcurrentModificationException when addind multiple marker.
this is the stack trace:

Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException

at java.util.LinkedList$ListItr.checkForComodification(Unknown Source)
at java.util.LinkedList$ListItr.next(Unknown Source)
at org.openstreetmap.gui.jmapviewer.JMapViewer.paintComponent(JMapViewer.java:629)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager$4.run(Unknown Source)
at javax.swing.RepaintManager$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$1300(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Here is the code :

for(int i=0; i < len; i++){

hotel = hotelsList.getJSONObject(i);
lat = hotel.getDouble("lat");
lng = hotel.getDouble("lng");
name = hotel.getString("name");
JMAP.addHotel(lat, lng, name);
}

and this is the addHotel method in JMAP class:

public static void addHotel(double lat, double lng, String name){
map.addMapMarker(

new MapMarkerDot(name, new Coordinate(lat,lng)));

}

JMAP is a class created from the DEMO class you offer.

Change History (0)

Note: See TracTickets for help on using tickets.