tillnagel / unfolding

A library to create interactive maps and geovisualizations in Processing and Java
http://unfoldingmaps.org
Other
477 stars 245 forks source link

Dynamic position on Unfolding #179

Closed juaxs closed 4 years ago

juaxs commented 4 years ago

Hi there!

This definitely is possible with Unfolding. But this is not something Unfolding provides out of the box. Roughly, you need to update the position in some event listener (which gets called when new coordinates arrive, or on some specified interval). When you want to show some trajectory (i.e. a trail behind the most recent coordinates) you need to store them somewhere.

Do you have any example showing that? I tried to only show one location with variable lat/lon like this and the location doesnt updates. It only works if i put a number/coordenate on the lat/lon variable.

`` UnfoldingMap map; float lat; float lon; Location locationLocal = new Location(lat, lon);

setup(){ String portName = "COM4"; myPort = new Serial(this, portName, 57600); myPort.bufferUntil('\n'); map = new UnfoldingMap(this, 19, 359, 635, 266, new Microsoft.AerialProvider()); map.setTweening(false); map.zoomToLevel(16); map.panTo(locationLocal); MapUtils.createDefaultEventDispatcher(this, map); }

void draw() { sensor = split(dato, '\t'); lat = float(sensor[18]); lon = float(sensor[19]); drawMap(); }

void drawMap() { map.draw(); fill(255, 0, 0); ScreenPosition posLocal = map.getScreenPosition(locationLocal); float s = map.getZoom(); ellipse(posLocal.x, posLocal.y, s/2000, s/2000); }

void serialEvent(Serial myPort) { dataReading = myPort.readStringUntil('\n'); dato=dataReading; } `` All values are always updating on the sensor array, but i dont get the map moving according to the movment of the gps location.

Originally posted by @juaxs in https://github.com/tillnagel/unfolding/issues/178#issuecomment-663233526

tillnagel commented 4 years ago

Let's keep the discussion in #178