diff --git a/CHANGELOG.md b/CHANGELOG.md index 25465d1..bc635ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.2.10 ### New Features +* Posibility to display sensor data on map ### Bugfixes * Parse also all Doublevalues as Int ### Changes @@ -14,6 +15,7 @@ * Display GateCounting Boxes in a line not a collumn * Create Aliases for Camera Count * Filter Fight under level +* Refactoring ## 1.2.9 ### New Features diff --git a/Lora-Map/resources/css/global.css b/Lora-Map/resources/css/global.css index 69b38ff..b128005 100644 --- a/Lora-Map/resources/css/global.css +++ b/Lora-Map/resources/css/global.css @@ -27,6 +27,9 @@ padding: 5px; border-radius: 10px; } +#bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor.alert { + border: 2px solid red; +} #bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor span { display: block; text-align: center; @@ -37,6 +40,9 @@ #bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor .wind { font-size: 18px; } +#bigmap .leaflet-map-pane .leaflet-marker-pane .mapsensor.alert { + color: red; +} /* Optional: Makes the sample page fill the window. */ html, body { diff --git a/Lora-Map/resources/js/map.js b/Lora-Map/resources/js/map.js index da9ec20..1592afb 100644 --- a/Lora-Map/resources/js/map.js +++ b/Lora-Map/resources/js/map.js @@ -255,6 +255,7 @@ } }); } + MarkerObject.ScaleSensors("zoom"); }); }, _SetupClickHandler: function () { diff --git a/Lora-Map/resources/js/marker.js b/Lora-Map/resources/js/marker.js index ac833f9..adc5c8d 100644 --- a/Lora-Map/resources/js/marker.js +++ b/Lora-Map/resources/js/marker.js @@ -98,7 +98,6 @@ if (this._SensorSettings.hasOwnProperty(sensorid)) { var sensordata = sensorjson[sensorid]; var sensorsettings = this._SensorSettings[sensorid]; - if (!this._Sensors.hasOwnProperty(sensorid)) { //Sensor is not drawn until now var sensor = null; var sensorIcon = L.divIcon({ @@ -110,15 +109,40 @@ '' + sensordata.Windspeed + ' m/s' + '' + sensordata.Humidity + ' %rl' }); - sensor = L.marker(sensorsettings.Coordinates, { 'title': sensorsettings.Alias, 'icon': sensorIcon }); + sensor = L.marker(sensorsettings.Coordinates, { 'title': sensorsettings.Alias, 'icon': sensorIcon, interactive: false }); this._Sensors[sensorid] = sensor.addTo(MapObject.Map); + this.ScaleSensors(document.getElementById('MapSensor_id_' + sensorid)); } else { //Sensor refresh! - + document.getElementById('MapSensor_id_' + sensorid).innerHTML = '' + sensorsettings.Alias + '' + + '' + sensordata.Temperature + ' °C' + + '' + sensordata.Windspeed + ' m/s' + + '' + sensordata.Humidity + ' %rl'; } + document.getElementById('MapSensor_id_' + sensorid).className = "mapsensor" + (sensordata.Windspeed > sensorsettings.Level ? ' alert' : ''); } } } }, + ScaleSensors: function (el) { + if (el === "zoom") { + for (var sensorid in this._Sensors) { + this.ScaleSensors(document.getElementById('MapSensor_id_' + sensorid)); + } + return; + } + var currentZoom = MapObject.Map.getZoom(); + var scale = 1; + if (currentZoom < 14) { + scale = 0; + } else if (currentZoom === 14) { + scale = 0.2; + } else if (currentZoom === 15) { + scale = 0.5; + } else if (currentZoom >= 16) { + scale = 1; + } + el.style.cssText = "transform: scale(" + scale + ");"; + }, _ParseAJAXSettings: function(json) { this._SensorSettings = json["Sensors"]; },