tillnagel / unfolding

A library to create interactive maps and geovisualizations in Processing and Java
http://unfoldingmaps.org
Other
478 stars 245 forks source link

Adding new MarkerManager removes an old one #89

Closed antjkennedy closed 10 years ago

antjkennedy commented 10 years ago

When adding new MarkerManagers (in AbstractMapDisplay) before any markers have been added anywhere in an Unfolding application the first entry is always removed. See below

public void addMarkerManager(MarkerManager<Marker> markerManager) {
        // Replace default MarkerManager, if only default exists and has no entries
        if (markerManagerList.size() == 1 && markerManagerList.get(0).getMarkers().size() == 0) {
            markerManagerList.remove(0);
        }

        markerManagerList.add(markerManager);
    }

Prehaps this could change to

public void addMarkerManager(MarkerManager<Marker> markerManager) {
        // Replace default MarkerManager, if only default exists and has no entries
        if (markerManagerList.size() == 1) {
            MarkerManager<?> mm = markerManagerList.get(0);
            if (mm.getMarkers().size() == 0 && mm.equals(this.defaultMarkerManager)) {
                markerManagerList.remove(0);
            }
        }

        markerManagerList.add(markerManager);
    }