Using Unfolding Maps library on Processing editor - Red Marker will not appear on the map

92 Views Asked by At

How can I make a very basic red marker (i.e., Red Ellipse) appear on the map (which integrates unfolding library) at the provided location (coordinates) for the shelter in this case.

Here's the code sketch:

import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.marker.*;
import de.fhpotsdam.unfolding.tiles.*;
import de.fhpotsdam.unfolding.interactions.*;
import de.fhpotsdam.unfolding.ui.*;
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.core.*;
import de.fhpotsdam.unfolding.mapdisplay.shaders.*;
import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.texture.*;
import de.fhpotsdam.unfolding.events.*;
import de.fhpotsdam.utils.*;

String shelterMainFile = "toronto-daily-shelter-occupancy.csv"; 
//String shelterData = shelterMainFile; 

UnfoldingMap map; 
SimplePointMarker shelterMarker; 

void setup() {
  size(800, 600);
  smooth();

  //--MAP INITIATE 
  // Creating a map anchored around downtown core Toronto
  String mbTilesString = sketchPath("data/black_yellow.mbtiles");  //in the data folder of the current sketch
  map = new UnfoldingMap(this, new MBTilesMapProvider(mbTilesString));
  // Grab your desired map
  map = new UnfoldingMap(this, new Microsoft.RoadProvider()); // default cleaner
  //SET ZOOM & ANCHOR to specified location here
  map.zoomAndPanTo(18, new Location(43.6595035, -79.3814353));
  // LAUNCH
  MapUtils.createDefaultEventDispatcher(this, map);
  map.setTweening(true);
  
  //--LOCATION MARKER 
  Location covenantHouseLocation = new Location(43.6595035, -79.3814353);
  shelterMarker = new SimplePointMarker(covenantHouseLocation);  
  shelterMarker.setColor(color(255, 0, 0)); // set marker color to red
  
  //--MAP MARKERS 
  map.addMarker(shelterMarker);
  
  //--DATA
  // coming soon... 
}
void draw() {

  // Draw Map 
  map.draw();

  // Draw the marker hovering above Covenant House
  ScreenPosition shelterPos = map.getScreenPosition(shelterMarker.getLocation());
  strokeWeight(1);
  stroke(255, 0, 0);
  fill(255, 0, 0, 100);
  ellipse(shelterPos.x, shelterPos.y, 36, 36); //--red marker supposed to show up at this x, y 
}

I have tried running the sketch without the map integrating. That seems to be the only way my ellipse will show (but no map, which is integral part of this sketch).

Not sure why this isn't working considering it is very toned-down example.

1

There are 1 best solutions below

0
On

The following source code is a simplified version of your code since the .mbtiles for Toronto is unavailable to me. You left out P2D from your size() parameters; should see a red circle overlying the Covenant House in Toronto.

import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.unfolding.marker.*;
import de.fhpotsdam.unfolding.interactions.*;
import de.fhpotsdam.unfolding.ui.*;
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.mapdisplay.shaders.*;
import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.texture.*;
import de.fhpotsdam.unfolding.events.*;
import de.fhpotsdam.utils.*;

UnfoldingMap map; 
SimplePointMarker shelterMarker; 

void setup() {
  size(800, 600, P2D);
  map = new UnfoldingMap(this, 0, 0, width, height);
  map.zoomAndPanTo(18, new Location(43.6595035, -79.3814353)); 
  Location covenantHouseLocation = new Location(43.6595035, -79.3814353);
  shelterMarker = new SimplePointMarker(covenantHouseLocation);  
  shelterMarker.setColor(color(255, 0, 0));
  map.addMarker(shelterMarker);
  
}
void draw() {
  map.draw();
}