data to json

This commit is contained in:
Gilles Jacobs 2014-12-09 20:10:10 +01:00
parent e70e8eee1c
commit ac9366cb91
2 changed files with 31 additions and 28 deletions

23
data.json Normal file
View file

@ -0,0 +1,23 @@
[{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [3.726759, 51.045660]
},
"properties": {
"name": "Studentenrestaurant De Brug",
"address": "Sint-Pietersnieuwstraat 45",
"capacity": 700,
"period": { "start": "18/08/2014", "end": "12/09/2014" },
"hours": {
"monday": "8u - 22u",
"tuesday": "8u - 22u",
"wednesday": "8u - 22u",
"thursday": "8u - 22u",
"friday": "8u - 22u",
"saturday": false,
"sunday": false
},
"extra": "2 aparte zaaltjes doorlopend beschikbaar (120 plaatsen)."
}
}]

View file

@ -37,30 +37,6 @@
</div> </div>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
var data = [{
'type': "Feature",
'geometry': {
'type': "Point",
'coordinates': [3.726759, 51.045660]
},
'properties': {
'name': "Studentenrestaurant De Brug",
'address': "Sint-Pietersnieuwstraat 45",
'capacity': 700,
'period': { 'start': "18/08/2014", 'end': "12/09/2014" },
'hours': {
'monday': "8u - 22u",
'tuesday': "8u - 22u",
'wednesday': "8u - 22u",
'thursday': "8u - 22u",
'friday': "8u - 22u",
'saturday': false,
'sunday': false
},
'extra': '2 aparte zaaltjes doorlopend beschikbaar (120 plaatsen).'
}
}];
var popuptemplate = Handlebars.compile($('#popup-template').html()); var popuptemplate = Handlebars.compile($('#popup-template').html());
function onEachFeature(feature, layer) { function onEachFeature(feature, layer) {
@ -74,11 +50,15 @@
var osm = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { var osm = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Made by <a href="http://zeus.ugent.be">Zeus</a> with ❤!' attribution: 'Made by <a href="http://zeus.ugent.be">Zeus</a> with ❤!'
}).addTo(map); }).addTo(map);
$.getJSON('data.json')
.done(function(data) {
var geojson = L.geoJson(data, { var geojson = L.geoJson(data, {
onEachFeature: onEachFeature onEachFeature: onEachFeature
}); });
map.addLayer(geojson); map.addLayer(geojson);
}); });
});
</script> </script>
</body> </body>
</html> </html>