There doesn‘t seem to be a built in method to do this, but you can do the following :
marker.setProperties(new HashMap<String, Object> ());
marker.setProperty(new String(„Text“), new String(„TextForMyLocation“));
This would set a property „Text“ that you could use to display the text… as for really displaying it, that‘s a bit harder…
This should work :
public class SimpleTextPointMarker extends AbstractMarker {
protected float diameter = 20f;
/**
* Creates an empty point marker. Used internally by the MarkerFactory.
*/
public SimplePointMarker() {
this(null, null);
}
/**
* Creates a point marker for the given location.
*
* @param location
* The location of this Marker.
*/
public SimplePointMarker(Location location) {
this(location, null);
}
/**
* Creates a point marker for the given location and properties.
*
* @param location
* The location of this Marker.
* @param properties
* Some data properties for this marker.
*/
public SimplePointMarker(Location location, HashMap<String, Object> properties) {
super(location, properties);
}
/**
* Draws this point marker as circle in the defined style. If no style has been set, Unfolding's default one is
* used.
*/
@Override
public void draw(PGraphics pg, float x, float y) {
if (isHidden())
return;
pg.pushStyle();
pg.strokeWeight(strokeWeight);
if (isSelected()) {
pg.fill(highlightColor);
pg.stroke(highlightStrokeColor);
} else {
pg.fill(color);
pg.stroke(strokeColor);
}
pg.ellipse((int) x, (int) y, diameter, diameter);
if (this.getStringProperty(„TextWeight“) != null)
pg.strokeWeight(this.getStringProperty(„TextWeight“);
if (this.getStringProperty(„TextStroke“) != null)
pg.stroke(this.getStringProperty(„TextStroke“);
if (this.getStringProperty(„Text“) != null)
pg.text(this.getStringProperty(„Text“), (int) x, (int) y-diameter/2);
pg.popStyle();
}
@Override
public boolean isInside(float checkX, float checkY, float x, float y) {
PVector pos = new PVector(x, y);
return pos.dist(new PVector(checkX, checkY)) < diameter / 2;
}
/**
* Sets the radius of this marker. Used for the displayed ellipse and hit test.
*
* @param radius The radius of the circle in pixel.
* @deprecated Fixed behavior! (value was wrongly used as diameter). Use {@link #setDiameter(float)} instead.
*/
public void setRadius(float radius) {
this.diameter = radius * 2;
}
/**
* Sets the diameter of this marker. Used for the displayed ellipse and hit test.
*
* @param diameter The diameter of the circle in pixel.
*/
public void setDiameter(float diameter) {
this.diameter = diameter;
}
}
I spaced out the important part, so you should see it. If you can think of additional properties, you can add them like that. (If you want things to be drawn, like Text, or changing the shape of the marker or stuff…)
Also, Note that this is a new class, so you have to replace your current SimplePointMarker class variables with this one. All the other Code should still work though. Hope this help