How to remove a marker in unfolding?

Hi, I was wondering, how to remove a marker in unfolding map with processing 3. The following is some code:

import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.marker.SimplePointMarker;

float x = 53.25; 
float y = -6.26;

Location location = new Location(x,y);
SimplePointMarker marker = new SimplePointMarker(location);

UnfoldingMap map;

void setup() {
  size(1000,1000,P2D);
  map = new UnfoldingMap(this);
  MapUtils.createDefaultEventDispatcher(this,map);
  
}

void draw(){
    
    Location location = new Location(x,y);
    SimplePointMarker marker = new SimplePointMarker(location);
    
    map.addMarkers(marker);
    map.draw();
    
    for (int i=0; i<100; i++){
      x = x + 0.0001;
      y = y + 0.0001; 
    } 
    map.deleteMarkers(marker);
  
}
1 Like

This should do the trick :

map.getMarkerManager(0).removeMarker(marker);

Markers are stored in the markermanager inside the map. A map has one markerManager by default, but you can add more with map.addMarkerManager(new MarkerManager()).
You can then work with the markers stored in the markermanager by accessing the corresponding markermanager directly by refering to the index (0 by default) in the getMarkerManager() method. For the removeMarker(marker) method, you need to have the marker class object you want to delete as a reference.

You can find information on every method/class you need here :

http://unfoldingmaps.org/javadoc/de/fhpotsdam/unfolding/UnfoldingMap.html#addMarker(de.fhpotsdam.unfolding.marker.Marker)

2 Likes

You could also use the convenience method

map.getDefaultMarkerManager().removeMarker(marker);

and remove all markers by using

map.getDefaultMarkerManager().clearMarkers();

2 Likes