1

I want to use Unfolding Maps to write to a PGraphics in Processing.

import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.utils.*; 
import de.fhpotsdam.unfolding.providers.*;

UnfoldingMap map;
PGraphics g;

void setup() {
    size(800, 600);
    map= new UnfoldingMap(this, new OpenStreetMap.OpenStreetMapProvider( ));
    map.zoomAndPanTo(new Location(52.5f, 13.4f), 10);    
    g = createGraphics(width, height);
}

void draw() {
    map.draw();
    g.beginDraw();
    //g.map.draw();no
    //map.draw(g);nope
    g.endDraw();
}

At map.draw() how do I make this print to the buffer g?

1 Answers1

0

Not the most straight-forward, but the current way of doing that would be

g.image(map.mapDisplay.getOuterPG().get(), 0, 0);
tnagel
  • 483
  • 2
  • 9
  • This does not seem to work: Does `map.draw()` have to be within the main `draw()`? Because changing `setup` and `draw` as below yields a blank screen: `void setup() { size(800, 600); map= new UnfoldingMap(this, new OpenStreetMap.OpenStreetMapProvider( )); map.zoomAndPanTo(new Location(52.5f, 13.4f), 10); g = createGraphics(width, height); g.beginDraw(); g.background(color(0,255,0)); g.image(map.mapDisplay.getOuterPG().get(), 0, 0); g.endDraw(); map.draw(); } void draw() { image(g, 0, 0); }` – jackoverflow Jan 26 '17 at 15:07
  • Yes, all drawing in Processing has to be within draw(). You don't necessarily have to do that each frame, but it should not go into setup(). – tnagel Jan 27 '17 at 16:19