/
MapView.pde
58 lines (49 loc) · 1.26 KB
/
MapView.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import processing.opengl.*;
import com.modestmaps.*;
import com.modestmaps.core.*;
import com.modestmaps.geo.*;
import com.modestmaps.providers.*;
class MapView extends View {
InteractiveMap mmap;
MapView(float x_, float y_, float w_, float h_)
{
super(x_, y_, w_, h_);
mmap = new InteractiveMap(papplet, new Microsoft.HybridProvider(), w, h);
mmap.setCenterZoom(new Location(45.536382, -106.644490), 4);
airplaneImage.resize(20,20);
}
void drawContent()
{
imageMode(CORNER); // modestmaps needs this - I sent a patch, but who knows when it'll be committed
mmap.draw();
smooth();
noStroke();
Point2f p = mmap.locationPoint(new Location(41.881944, -87.627778));
println(p);
println(mmap.pointLocation(p));
image(airplaneImage,p.x,p.y);
}
boolean contentMouseWheel(float lx, float ly, int delta)
{
float sc = 1.0;
if (delta < 0) {
sc = 1.05;
}
else if (delta > 0) {
sc = 1.0/1.05;
}
float mx = lx - w/2;
float my = ly - h/2;
mmap.tx -= mx/mmap.sc;
mmap.ty -= my/mmap.sc;
mmap.sc *= sc;
mmap.tx += mx/mmap.sc;
mmap.ty += my/mmap.sc;
return true;
}
boolean mouseDragged(float px, float py)
{
mmap.mouseDragged();
return true;
}
}