在处理编辑器上使用展开地图库 - 红色标记不会出现在地图上

问题描述 投票:0回答:1

在这种情况下,我怎样才能使一个非常基本的红色标记(即红色椭圆)出现在地图(集成了展开库)的避难所提供的位置(坐标)上。

这是代码草图:

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 
}

我试过在没有地图集成的情况下运行草图。这似乎是我的椭圆显示的唯一方式(但没有地图,这是该草图的组成部分)。

不确定为什么这不起作用,因为这是一个非常低调的例子。

java geolocation processing google-maps-markers unfoldingmap
1个回答
0
投票

以下源代码是您代码的简化版本,因为我无法使用多伦多的 .mbtiles。您从 size() 参数中遗漏了 P2D;应该看到一个红色圆圈覆盖在多伦多的 Covenant House。

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();
}
© www.soinside.com 2019 - 2024. All rights reserved.