Display geo position of a mouse pointer in a unfolding map

Hi, I have the following code to accomplish a simple task, to display the geo-posiition of a mouse in a map.

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

UnfoldingMap map;

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

void draw() {
  map.draw();
  Location location = map.getLocation(mouseX, mouseY);
  fill(0);
  text(location.getLat() + "," + location.getLon(), mouseX, mouseY);
}

I tried this out. Yet, it does not work. I mean, I click a position of the map, yet the latitude and longitude pair do not appear at all.
I was wondering, does anyone know what might be wrong in the code?

1 Like

better use P2D, and you see the GPS coordinates

2 Likes

What exactly is the meaning of P2D?

you not see it in the picture i uploaded?
that is a test on a Raspberry Pi / Raspbian / processing 3.5.3 / Unfolding Maps 0.9.9beta /
with your code, mod:

  size(800,800,P2D);
1 Like

For render selection, check the size() function as it describes available renderers in Processing. As Kll has mentioned before, Unfolding seems to only work with P2D and not the default JAVA2D renderer.

Kf

1 Like