aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorKatie Filbert <filbertk@gmail.com>2012-12-01 18:18:49 +0100
committerKatie Filbert <filbertk@gmail.com>2012-12-01 18:18:49 +0100
commit3fef504fd23b6ac69fde72f242b50a33114c93f5 (patch)
treeff6e38ab4b2569fbde524b88d067d60a3a4e0fe7 /resources
parent6b34be2d9eb536d18ed9094e69e7be3237f453b6 (diff)
downloadhealth-map-3fef504fd23b6ac69fde72f242b50a33114c93f5.tar
health-map-3fef504fd23b6ac69fde72f242b50a33114c93f5.tar.gz
display hospital points
Diffstat (limited to 'resources')
-rw-r--r--resources/map.js22
1 files 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 &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> 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;