From 3fef504fd23b6ac69fde72f242b50a33114c93f5 Mon Sep 17 00:00:00 2001 From: Katie Filbert Date: Sat, 1 Dec 2012 18:18:49 +0100 Subject: display hospital points --- resources/map.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/map.js b/resources/map.js index e14022a..2a2d279 100644 --- a/resources/map.js +++ b/resources/map.js @@ -5,15 +5,20 @@ $(document).ready(function() { fetchLayers(); var map = L.map( 'map', { zoom: 12, - layers: [self.tileLayer, self.hospitalLayer] + layers: [self.tileLayer] }); - $('body').bind('hospitalsfetched', renderHospitalIcon); + function addHospitalLayer(){ + L.control.layers(null, { + "Hospitals" : self.hospitalLayer + }).addTo(map); + } + + $('body').bind('hospitalsfetched', addHospitalLayer); map.on('locationfound', onLocationFound); map.on('locationerror', onLocationError); map.locate({setView: true, maxZoom: 12}); - initLayerControl(); function geojsonLayer() { url = "http://overpass-api.de/api/interpreter?data=[out:json];node[amenity=hospital](52.34,13.3,52.52,13.6);out;"; @@ -32,12 +37,13 @@ $(document).ready(function() { layer.bindPopup(feature.properties.name); } }); - return layer; + self.hospitalLayer = layer; + $('body').trigger('hospitalsfetched'); }); } function fetchLayers() { - self.hospitalLayer = geojsonLayer(); + geojsonLayer(); self.tileLayer = L.tileLayer('http://{s}.www.toolserver.org/tiles/osm-no-labels/{z}/{x}/{y}.png', { maxZoom: 18, attribution: 'Map data © OpenStreetMap contributors' @@ -50,12 +56,6 @@ $(document).ready(function() { // }) } - function initLayerControl() { - L.control.layers(null, { - "Hospitals" : self.hospitalLayer - }).addTo(map); - } - function onLocationFound(e) { self.currentLocation = e.latlng; var radius = e.accuracy / 2; -- cgit v1.2.3