How to put a marker at a specific position using unfolding map?

Location center = new Location(64, 20);
Integer zoom_start = 9;  

AbstractMapProvider provider5;
UnfoldingMap map;
String provider5Attrib;
String attrib;
Float attribWidth;
PImage clock;
PImage calendar;
int totalFrames = 3600;
Integer screenfillalpha = 120;
import de.fhpotsdam.unfolding.*;
import de.fhpotsdam.unfolding.core.*;
import de.fhpotsdam.unfolding.data.*;
import de.fhpotsdam.unfolding.events.*;
import de.fhpotsdam.unfolding.geo.*;
import de.fhpotsdam.unfolding.interactions.*;
import de.fhpotsdam.unfolding.mapdisplay.*;
import de.fhpotsdam.unfolding.mapdisplay.shaders.*;
import de.fhpotsdam.unfolding.marker.*;
import de.fhpotsdam.unfolding.providers.*;
import de.fhpotsdam.unfolding.texture.*;
import de.fhpotsdam.unfolding.tiles.*;
import de.fhpotsdam.unfolding.ui.*;
import de.fhpotsdam.unfolding.utils.*;
import de.fhpotsdam.utils.*;

// Import some Java utilities
import java.util.Date;
import java.text.SimpleDateFormat;



void setup(){
  size(1000,1000,P2D);
  provider5 = new OpenStreetMap.OpenStreetMapProvider();
  provider5Attrib = "OpenStreetMap";
  smooth();
  
  map = new UnfoldingMap(this,provider5);
  MapUtils.createDefaultEventDispatcher(this,map);
  
  attrib = "© Prehosp Care | Unfolding Maps | Basemap by " + provider5Attrib;
  attribWidth = textWidth(attrib);
  
  map.zoomAndPanTo(zoom_start, center);
  clock = loadImage("clock_icon.png");
  clock.resize(0, 10);
  calendar = loadImage("calendar_icon.png");
  calendar.resize(0, 10);
} 

void draw(){
  if (frameCount < totalFrames) {
    map.draw();
    noStroke();
    fill(0, screenfillalpha);
    rect(0, 0, width, height);
  } 
  
}

I was trying to put the clock and calendar images at specific locations and it did not work, because some kind of java errors…

at processing.core.PApplet.loadBytes(PApplet.java:7353)
	at processing.core.PApplet.loadImage(PApplet.java:5559)
	at de.fhpotsdam.unfolding.tiles.TileLoader.getTileFromUrl(Unknown Source)
	at de.fhpotsdam.unfolding.tiles.TileLoader.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://tile.openstreetmap.org/9/286/138.png
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
	at processing.core.PApplet.loadBytes(PApplet.java:7345)
	... 4 more

Any comments are greatly appreciated.

1 Like

If you encounter such problems, start by commenting out the most like causes for those errors until you find the exact line that causes the first problem. Especially when you use 3rd-Party libraries.

2 Likes

My first advice would be to carefully read the errors, even if they seem over-detailed: You have a 403 (Forbidden) URL. Why are you connecting to that URL? If the URL is correct, what would you need to do for the connection to be allowed? For example, do you need credentials such as an API key?

@jeremydouglass This is a duplicate. Edited Code/question is here :

Creating a simple map using a given map provider does not work in unfolding map

(The url is set by the openstreetmap class and can‘t be changed)