Commit 14bb42c8 authored by Pierre-antoine Comby's avatar Pierre-antoine Comby

improve map readability

parent 8c3c70fc
......@@ -22,19 +22,24 @@
html, body, #map{
height: 100%;
width: 100%;
}
null}
</style>
</head>
<body>
<script type="text/javascript">
function geoJson2heat(geojson, intensity) {
{% if allssid %}
var spyder = 24;
{% else %}
var spyder = 18;
{% endif %}
function geoJson2heat(geojson) {
return geojson.features.map(function(feature) {
return [
feature.geometry.coordinates[1],
feature.geometry.coordinates[0],
(100+feature.properties[intensity])/100,
10^(feature.properties["puissance"]/20),
];
});
}
......@@ -42,15 +47,35 @@
function onEachFeature(feature,layer){
if (feature.properties && feature.properties.popupContent) {
layer.bindPopup(feature.properties.popupContent);
}
}
function createCircleMarker(feature,latlng){
let lowIn = -100;
let highIn = -50;
let lowOut= 0;
let highOut = 240;
let options ={
radius:5,
fillColor:'hsl('+(lowOut+(highOut-lowOut)*(feature.properties["puissance"]-lowIn)/(highIn-lowIn))+',100%,50%)',
color: "",
weight:1,
opacity:1,
fillOpacity:0.8
};
return L.circleMarker(latlng,options);
}
function map_init(map,options){
var collection = {{ queryset|geojsonfeature:"popupContent:point"|safe }};
var collection = {{ queryset|geojsonfeature:"popupContent,puissance:point"|safe }};
var geoData = geoJson2heat(collection);
var markerslayer = L.markerClusterGroup({disableClusteringAtZoom: 18});
var heatlayer = L.heatLayer(geoData,{radius:25,minOpacity:0.7});
L.geoJson(collection, {onEachFeature:onEachFeature}).addTo(markerslayer);
var markerslayer = L.markerClusterGroup({disableClusteringAtZoom: spyder});
var heatlayer = L.heatLayer(geoData,{radius:40,
blur: 40,
maxOpacity:0.9});
L.geoJson(collection,
{onEachFeature:onEachFeature,
pointToLayer:createCircleMarker}).addTo(markerslayer);
var overlays = {
"mesure": markerslayer,
......@@ -58,7 +83,7 @@
};
map.addLayer(markerslayer);
map.addLayer(heatlayer);
L.control.layers(null,overlays).addTo(map);
L.control.layers(overlays).addTo(map);
}
</script>
{% leaflet_map "map" callback="map_init" %}
......
......@@ -11,14 +11,15 @@ class NetworkView(TemplateView):
def get_context_data(self, **kwargs):
ssid = self.kwargs.get("ssid")
bssid = self.kwargs.get("bssid")
allssid = False
if ssid:
queryset = Mesure.objects.filter(ssid=ssid)
elif bssid:
queryset = Mesure.objects.filter(bssid=bssid)
else:
queryset = Mesure.objects.all()
return {"queryset":queryset}
allssid = True
return {"queryset":queryset,"allssid":allssid}
pass
class HeatMapView(NetworkView):
template_name = 'maps/heat.html'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment