-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
47 lines (37 loc) · 1.64 KB
/
main.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
/*jslint indent:4*/
/*global $, require, L, window*/
require([
// 'tmp-lines',
// 'tmp-heatmap'
], function () { // tmpLayer, tmpheatmap
// -43.527, 172.64 = chch
var map = L.map('map').setView([-43.527, 172.64], 13);
var googleTiles = new L.Google();
var osmTiles = new L.TileLayer('http://{s}.tile.cloudmade.com/884b2cab686b4b29950f2b8a151ceced/106694/256/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>'
});
osmTiles.addTo(map);
var tileLayers = {
'Street Map': osmTiles,
'Satellite': googleTiles
};
var dataLayers = {};
// var dataLayers['Restrictions'] = tmpLayer;
// if (tmpheatmap !== null) {
// dataLayers['Restrictions Heatmap'] = tmpheatmap;
// }
//Called when an item in the layer control box is ticked
map.on('overlayadd', function (leafletEvent) {
if (leafletEvent.layer.options.shouldLoad()) {
// Load the data
$.get(leafletEvent.layer.options.urlBase, leafletEvent.layer.options.urlParams)
.done(function (layerData, statusString, jqXHR) {
leafletEvent.layer.options.onLoad(leafletEvent.layer, layerData);
})
.fail(function (jqXHR) {
window.alert('Failed to load data. Status code: ' + jqXHR.status);
});
}
});
L.control.layers(tileLayers, dataLayers, {collapsed: false, autoZIndex: true}).addTo(map);
});