-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathapp.js
69 lines (55 loc) · 1.84 KB
/
app.js
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
var os = require('os');
var gui = require('nw.gui');
var win = gui.Window.get();
var http = require('http');
var LocalAPI = require("./tilecache/local");
// Create default menu items for OSX
if (process.platform === 'darwin') {
var mb = new gui.Menu({ type: "menubar" });
mb.createMacBuiltin(gui.App.manifest.productName);
win.menu = mb;
}
//setup Vue
var App = new Vue({
el: '#pinpoint',
components: {
'alert': VueStrap.alert,
'sidebar': VueStrap.aside,
'accordion' : VueStrap.accordion,
'panel': VueStrap.panel,
'radio': VueStrap.radioBtn,
'radio-group': VueStrap.radioGroup
},
data: {
showMenu: false,
currentMarker: ''
}
});
var pinpointMap = L.map('map', {zoomControl:false}).setView([34.5259,-92.1588], 7);
L.tileLayer("http://localhost:1337/api/tiles/{z}/{x}/{y}.png", {
maxZoom: 17,
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(pinpointMap);
//search control
var searchControl = L.control.search({});
searchControl.addTo(pinpointMap);
// draw control
var drawnItems = new L.FeatureGroup();
pinpointMap.addLayer(drawnItems);
// Initialise the draw control and pass it the FeatureGroup of editable layers
var drawControl = new L.Control.Draw({
edit: {
featureGroup: drawnItems
}
});
pinpointMap.addControl(drawControl);
pinpointMap.on('click', function(e) {
//alert(e.latlng);
});
pinpointMap.on('contextmenu',function(e){
if(pinpointMap._zoom >= 13){
pinpointMap.removeLayer(App.$get('currentMarker'));
App.$set('currentMarker',L.marker([e.latlng.lat, e.latlng.lng]).addTo(pinpointMap));
App.$get('currentMarker').bindPopup("<strong>Latitude:</strong>" + " " + e.latlng.lat + "<br>" + "<strong>Longitude: </strong>" + " " + e.latlng.lng + "<br>").openPopup();
}
});