We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import processing.core.PApplet;
import processing.core.PGraphics;
import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.providers.OpenStreetMap;
import de.fhpotsdam.unfolding.utils.MapUtils;
private UnfoldingMap map;
private PGraphics pg;
private int n = 1000;
public void setup() {
size(n, n, P2D);
map = new UnfoldingMap(this, new OpenStreetMap.OpenStreetMapProvider());
MapUtils.createDefaultEventDispatcher(this, map);
}
public void draw() {
background(0);
pg = map.mapDisplay.getOuterPG();
image(pg, 0, 0);
}
Greetings! When I try to convert maps into PGraphics and display it, I see only black background :( Can anyone explain why it is so? Thank you!
Answers
I can get it to work when I called map.draw() To compare what map.draw does to what the pg object holds, I draw both of them side by side. You can see what pg holds if you save the frame (uncomment the line with the saving action)
Kf
import processing.core.PApplet; import processing.core.PGraphics;
Many thanks! But I can not understand why the
does not work without
map.draw();
Can you explain?
@listopad The only way I was able to get it to work was by calling draw first. I'm not too familiar with unfolding maps. However @tnagel could provide you an answer. I guess you don't want the actual unfolding map features which allows the user to work on the loaded map. What you want is to have access to the title displaying the map? Can you elaborate in the details of what you would like to accomplish? Maybe somebody in the forum could provide some other ideas to approach your challenge.
Kf
I would like to mask the map into an ellipse. I achieved this by improving your method, but I had a problem - on canvas draws two maps (unfolding map and pg). I solved this problem by rendering unfolding map outside of the document.