diff options
author | Christopher Baines <cb15g11@soton.ac.uk> | 2014-07-05 20:20:31 +0100 |
---|---|---|
committer | Christopher Baines <cb15g11@soton.ac.uk> | 2014-07-05 20:20:31 +0100 |
commit | a236f4f4147caa9b06ed17baf625f26dde738679 (patch) | |
tree | 9558c1c05e388b44862b29d51cbf34bba2573de6 /src | |
parent | ed09134c1d99ea806cbdf9f8953493e7211b89d2 (diff) | |
download | leaflet-soton-a236f4f4147caa9b06ed17baf625f26dde738679.tar leaflet-soton-a236f4f4147caa9b06ed17baf625f26dde738679.tar.gz |
Include the library data in data.js
Instead of loading seperately
Diffstat (limited to 'src')
-rw-r--r-- | src/leaflet-soton.js | 82 |
1 files changed, 4 insertions, 78 deletions
diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js index 31a7748..d134ff4 100644 --- a/src/leaflet-soton.js +++ b/src/leaflet-soton.js @@ -4,14 +4,11 @@ var LS = window.LS = L.extend({}, L.Mixin.Events, { dataPath: 'data.json', - libraryDataPath: '../resources/hartley-library-map-data/data.json', imagePath: 'images/', data: null, _dataFetchInProgress: false, workstationData: null, _workstationDataFetchInProgress: false, - libraryData: null, - _libraryDataFetchInProgress: false, getData: function(callback) { if (this.data !== null) { @@ -41,24 +38,6 @@ } } }, - getLibraryData: function(callback) { - if (this.libraryData !== null) { - callback(this.libraryData); - } else { - this.addOneTimeEventListener("libraryData", callback); - - if (!this._libraryDataFetchInProgress) { - this._libraryDataFetchInProgress = true; - - getJSON({url: LS.libraryDataPath} , function(data) { - LS.libraryData = data; - LS._libraryDataFetchInProgress = false; - - LS.fire("libraryData", data); - }); - } - } - }, getRoomFor: function(uri) { var parts = LS.data.buildingParts.features; @@ -694,10 +673,6 @@ SELECT * WHERE {\ map.removeLayer(map.indoorLayer); } - if (map.hasLayer(map.libraryIndoorLayer)) { - map.removeLayer(map.libraryIndoorLayer); - } - if (options.workstations && !map.hasLayer(workstationMarkerLayer)) { map.addLayer(workstationMarkerLayer); } @@ -711,66 +686,17 @@ SELECT * WHERE {\ map.addLayer(map.indoorLayer); } - if (!map.hasLayer(map.libraryIndoorLayer)) { - map.addLayer(map.libraryIndoorLayer); - } - if (options.workstations && map.hasLayer(workstationMarkerLayer)) { map.removeLayer(workstationMarkerLayer); } } }; - LS.getLibraryData(function(data) { - - map.libraryIndoorLayer = L.indoor(data.features, { - level: map._startLevel, - style: function(feature) { - return { - fillColor: 'white', - weight: 1, - color: '#666', - fillOpacity: 1 - }; - }, - markerForFeature: function(part) { - var myIcon = L.divIcon({ - className: 'ls-room-marker', - html: part.properties.label, - iconSize: new L.Point(100, 30), - iconAnchor: new L.Point(50, 15) - }); - - // TODO: Switch to a better method - var points = part.geometry.coordinates[0]; - - var lat = 0; - var lon = 0; - - points.forEach(function(point) { - lat += point[0]; - lon += point[1]; - }); - - var coords = [lon / points.length, lat / points.length]; - - var marker = L.marker(coords, {icon: myIcon}); - - return marker; - }, - onEachFeature: function(feature, layer) { - return; - } - }); - - map.levelControl.addEventListener("levelchange", map.libraryIndoorLayer.setLevel, map.libraryIndoorLayer); - - setIndoorContent(map.getZoom()); - - map.on('zoomend', function(e) { - setIndoorContent(this.getZoom()); - }); + map.on('zoomend', function(e) { + setIndoorContent(this.getZoom()); }); + + setIndoorContent(map.getZoom()); } else { if (options.workstations) { map.addLayer(workstationMarkerLayer); |