Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter 在处理中显示地图,并根据其纬度和经度坐标显示推文?_Twitter_Processing - Fatal编程技术网

Twitter 在处理中显示地图,并根据其纬度和经度坐标显示推文?

Twitter 在处理中显示地图,并根据其纬度和经度坐标显示推文?,twitter,processing,Twitter,Processing,有谁能帮我在处理过程中显示一张世界地图,然后在相应的位置绘制推文吗?这不是一个完整的答案,但应该说明如何在世界地图上绘制位置。注意执行笛卡尔坐标的getPoint()方法(在处理过程中,您可以使用map()函数执行相同的操作。还要注意,构造函数执行计算,以将您使用的地球图像调整到草图窗口的大小 WorldMap world; Point[] cities = new Point[6]; void setup() { size(800, 480); background(255);

有谁能帮我在处理过程中显示一张世界地图,然后在相应的位置绘制推文吗?

这不是一个完整的答案,但应该说明如何在世界地图上绘制位置。注意执行笛卡尔坐标的getPoint()方法(在处理过程中,您可以使用map()函数执行相同的操作。还要注意,构造函数执行计算,以将您使用的地球图像调整到草图窗口的大小

WorldMap world;
Point[] cities = new Point[6];

void setup() {
  size(800, 480);
  background(255);
  stroke(0);
  strokeWeight(1.5);
  ellipseMode(CENTER);
  smooth();

  // World
  world = new WorldMap(0, 0, width, height);

  // Cities
  cities[0] = world.getPoint(45.24, -75.43);  // Ottawa
  cities[1] = world.getPoint(38.53, -77.02);  // Washington
  cities[2] = world.getPoint(51.32, 0.50);    // London
  cities[3] = world.getPoint(48.48, 2.20);    // Paris
  cities[4] = world.getPoint(39.55, 116.25);  // Beijing
  cities[5] = world.getPoint(35.40, 139.45);  // Tokyo

}

void draw() {

  world.drawBackground();

  for (int i = 0; i < cities.length; i++) {
    ellipse(cities[i].x, cities[i].y, 10, 10);
  }

}

//-------------------------------

class WorldMap {

  int x, y, w, h;
  PImage raster;

   WorldMap(int x, int y, int w, int h) {
     // Scale Image
     if (h >= w/2) {
       this.w = w;
       this.h = w/2;
       this.x = x;
       this.y = (h - this.h)/2;
     } 
     else {
       this.h = h;
       this.w = 2*h;
       this.x = (w - this.w)/2;
       this.y = y;
     }

     // Load Image
     raster = loadImage("world_longlatwgs3.png");
  }

 void drawBackground() {
   image(raster, x, y, w, h);
  }

 Point getPoint(float phi, float lambda) {
   Point pt = new Point(x + ((180 + lambda) / 360) * w, y + h - ((90 + phi) / 180) * h);
   return pt;
  }

}

//-------------------------------

class Point extends Point2D {
  Point(float x, float y) { 
    super(x, y); 
  }
}

class Point2D {
  float x, y;
  Point2D(float x, float y) {
    this.x = x; this.y = y;
  }
}
世界地图世界;
点[]城市=新点[6];
无效设置(){
尺寸(800480);
背景(255);
冲程(0);
冲程重量(1.5);
ellipseMode(中心);
光滑的();
//世界
世界=新世界地图(0,0,宽度,高度);
//城市
城市[0]=world.getPoint(45.24,-75.43);//渥太华
城市[1]=world.getPoint(38.53,-77.02);//华盛顿
城市[2]=world.getPoint(51.32,0.50);//伦敦
城市[3]=world.getPoint(48.48,2.20);//巴黎
城市[4]=world.getPoint(39.55116.25);//北京
城市[5]=world.getPoint(35.40139.45);//东京
}
作废提款(){
世界。退税地();
for(int i=0;i=w/2){
这个.w=w;
这个h=w/2;
这个.x=x;
this.y=(h-this.h)/2;
} 
否则{
这个,h=h;
这是w=2*h;
this.x=(w-this.w)/2;
这个。y=y;
}
//加载图像
光栅=加载图像(“world_longlatwgs3.png”);
}
无效退税地(){
图像(光栅、x、y、w、h);
}
点获取点(浮点φ,浮点λ){
点pt=新点(x+((180+λ)/360)*w,y+h-((90+φ)/180)*h);
返回pt;
}
}
//-------------------------------
类Point扩展了Point2D{
点(浮动x,浮动y){
super(x,y);
}
}
类Point2D{
浮动x,y;
点2D(浮点x、浮点y){
这个.x=x;这个.y=y;
}
}

这是一个很大的问题。你有一个比较好的方法吗?大概你想把它放在一个网页上吗?在这种情况下,我推荐D3.JS,如果不是网络的话,可以很方便。我已经用这个工具做了。@ BBELD3是一个很好的推荐,但是Fari说他们不会使用处理……如果有帮助的话,请回答——如果你解决了这个问题,请发布你自己的答案!承认他人的工作对于让人们在将来回答你的问题有很大帮助!