var alarmsLayer;
// Go get the alarms
GetAlarms();
$(document).ready(function () {
//When the document finishes, start the timer
setInterval(function () {
//remove the alarms
map.removeLayer(alarmsLayer);
// Get and add the new alarms
GetAlarms();
}, 5000);
});
function GetAlarms() {
// Call the asmx code from the C# code behind
Power.GetJsonAlarms(GotJsonAlarms);
};
function GotJsonAlarms(currentAlarms) {
// Format and display the alarms using fancy leaflet markers
jqAlarms = jQuery.parseJSON(currentAlarms);
alarmsLayer = L.geoJson(jqAlarms, {
style: function (feature) {
return { color:feature.properties.markercolor };
},
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {
icon:
L.AwesomeMarkers.icon({
icon: feature.properties.iconname,
prefix: 'fa',
markerColor: feature.properties.iconcolor
})
})
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.Warning + " \r\n" + feature.properties.CLLI);
}
});
map.addLayer(alarmsLayer);
};