forked from benbahrenburg/benCoding.Map
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_overlay_file.js
More file actions
85 lines (70 loc) · 2.28 KB
/
image_overlay_file.js
File metadata and controls
85 lines (70 loc) · 2.28 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
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
});
bRemoveAll.addEventListener('click',function(){
mapView.removeAllImageOverlays();
});
var zoomControl = Ti.UI.iOS.createToolbar({
items:[bZoomIn,bZoomOut,flexSpace,bRemoveAll],
top:0,width:Ti.UI.FILL
});
win.add(zoomControl);
var bAddFile = Ti.UI.createButton({
title:'Add File', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
bAddFile.addEventListener('click',function(e){
mapView.addImageOverlayFile('./image_overlay_file_sample.json');
});
var bBen = Ti.UI.createButton({
title:'Ben', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
bBen.addEventListener('click',function(e){
var regionBigBen = {latitude:51.500611,longitude:-0.124611,animate:true,latitudeDelta:0.04, longitudeDelta:0.04};
mapView.setLocation(regionBigBen);
});
var bEiffel = Ti.UI.createButton({
title:'Eiffel', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
bEiffel.addEventListener('click',function(e){
var regionEiffelTower = {latitude:48.85995,longitude:2.2957,animate:true,latitudeDelta:0.04, longitudeDelta:0.04};
mapView.setLocation(regionEiffelTower);
});
var bRemove = Ti.UI.createButton({
title:'Remove', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
bRemove.addEventListener('click',function(){
//Remove Eiffel Tower
mapView.removeImageOverlay({tag:42});
//Remove Big Ben
mapView.removeImageOverlay({tag:21});
});
var bottomToolbar = Ti.UI.iOS.createToolbar({
items:[bAddFile,bBen,bEiffel,bRemove],
bottom:0
});
win.add(bottomToolbar);