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
|
Map.UI = Map.UI || {}
Map.UI.Ortho = function(map){
var base = this
base.creating = base.dragging = base.resizing = false
base.mouse = new mouse({
el: map.el,
down: function(e, cursor){
cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
base.tools[currentTool].down(e, cursor)
},
move: function(e, cursor){
cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
base.tools[currentTool].move(e, cursor)
},
drag: function(e, cursor){
cursor.x.b = ((cursor.x.b/map.dimensions.a)+0.5) * map.dimensions.a / map.zoom + map.center.a
cursor.y.b = ((cursor.y.b/map.dimensions.b)-0.5) * map.dimensions.b / map.zoom - map.center.b
base.tools[currentTool].drag(e, cursor)
},
up: function(e, cursor, new_cursor){
new_cursor.x.div(map.dimensions.a).add(0.5).mul(map.dimensions.a / map.zoom).add(map.center.a)
new_cursor.y.div(map.dimensions.b).sub(0.5).mul(map.dimensions.b / map.zoom).sub(map.center.b)
base.tools[currentTool].up(e, cursor, new_cursor)
}
})
var currentTool = "polyline"
base.setTool = function(s){
currentTool = s
}
base.tools = {
polyline: new PolylineTool,
position: new PositionTool,
}
base.wheel = new wheel({
el: map.el,
update: mousewheel,
})
function mousewheel (e, deltaY, deltaX){
map.set_zoom(map.zoom_exponent - deltaY/20)
}
}
|