forked from benbahrenburg/benCoding.Map
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheiffel_tower_sample.js
More file actions
89 lines (70 loc) · 2 KB
/
eiffel_tower_sample.js
File metadata and controls
89 lines (70 loc) · 2 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var win = Titanium.UI.currentWindow;
var flexSpace = Ti.UI.createButton({ systemButton:Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE });
//Bring the module into the example
var map = require('bencoding.map');
//Create mapView
//We support all of the same functions the native Ti.Map.View does
var mapView = map.createView({
mapType: Ti.Map.STANDARD_TYPE,
animate:true,
userLocation:true
});
//Add to Window
win.add(mapView);
var bZoomIn = Ti.UI.createButton({
title:'+', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
var bZoomOut = Ti.UI.createButton({
title:'-', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
bZoomIn.addEventListener('click',function() {
mapView.zoom(1);
});
bZoomOut.addEventListener('click',function() {
mapView.zoom(-1);
});
var bRemoveAll = Ti.UI.createButton({
title:'Remove All', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
var flexSpace = Ti.UI.createButton({ systemButton:Ti.UI.iPhone.SystemButton.FLEXIBLE_SPACE });
var zoomControl = Ti.UI.iOS.createToolbar({
items:[bZoomIn,bZoomOut],
top:0,width:Ti.UI.FILL
});
win.add(zoomControl);
var bAddTower = Ti.UI.createButton({
title:'Add Tower', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
var bRemoveTower = Ti.UI.createButton({
title:'Remove Tower', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
bRemoveAll.addEventListener('click',function(){
mapView.removeAllImageOverlays();
});
bRemoveTower.addEventListener('click',function(){
mapView.removeImageOverlay({tag:42});
});
bAddTower.addEventListener('click',function() {
var paris = {latitude:48.85995,longitude:2.2957,animate:true,latitudeDelta:0.04, longitudeDelta:0.04};
mapView.setLocation(paris);
mapView.addImageOverlay(
{
tag:42,
title:'foo',
image:'eiffel_tower2.png', //Image path
coordBox:{
coords:
{
upperRight:{
latitude:48.85995,
longitude:2.2957
},
bottomLeft:{
latitude:48.85758,
longitude:2.2933
}
}
}
});
});
win.setToolbar([bAddTower,flexSpace,bRemoveTower,flexSpace,bRemoveAll]);