Added redmarkers

This commit is contained in:
feliciaan 2014-12-11 18:10:30 +01:00
parent 04c2d1b8ed
commit 9cfcf6125f
2 changed files with 20 additions and 2 deletions

View file

@ -82,13 +82,30 @@
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
var popuptemplate = Handlebars.compile($('#popup-template').html()); var popuptemplate = Handlebars.compile($('#popup-template').html());
var RedIcon = L.Icon.Default.extend({
options: {
iconUrl: 'red-marker.png'
}
});
var redIcon = new RedIcon();
var BlueIcon = L.Icon.Default.extend({});
var blueIcon = new BlueIcon();
function onEachFeature(feature, layer) { function onEachFeature(feature, layer) {
if (feature.properties) { if (feature.properties) {
layer.bindPopup(popuptemplate(feature.properties)); layer.bindPopup(popuptemplate(feature.properties));
} }
} }
function pointToLayer(feature, latlng) {
if (feature.properties) {
if (!feature.properties.hours.saturday && !feature.properties.hours.sunday) {
return L.marker(latlng, {icon:blueIcon});
}
}
return L.marker(latlng, {icon: redIcon});
}
$(document).ready(function() { $(document).ready(function() {
var map = L.map('map').setView([51.0475378, 3.7261835], 13); var map = L.map('map').setView([51.0475378, 3.7261835], 13);
var googleLayer = new L.Google('TERRAIN'); var googleLayer = new L.Google('TERRAIN');
@ -97,7 +114,8 @@
$.getJSON('data.json') $.getJSON('data.json')
.done(function(data) { .done(function(data) {
var geojson = L.geoJson(data, { var geojson = L.geoJson(data, {
onEachFeature: onEachFeature onEachFeature: onEachFeature,
pointToLayer: pointToLayer
}); });
map.addLayer(geojson); map.addLayer(geojson);
}); });

BIN
red-marker.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB