Blame view
src/main/kotlin/map/MapDisplayer.kt
4.34 KB
53f01ecc3 display message o... |
1 |
package map |
2bbe36a1b addd the possibil... |
2 |
import application.model.observableVessel |
53f01ecc3 display message o... |
3 |
|
9e952e84e add message clust... |
4 5 6 |
fun clearMap(map: LeafletMapView) { clearMapCanvas(map) clearMapCluster(map) |
79b001037 heat map |
7 |
clearHeatMap(map) |
9e952e84e add message clust... |
8 9 10 11 12 |
} fun clearMapCluster(map: LeafletMapView) { map.execScript( """ |
79b001037 heat map |
13 14 |
|myMap.removeLayer(markerClusters); |var markerClusters = L.markerClusterGroup({spiderfyOnMaxZoom: false, disableClusteringAtZoom: 10}); |
9e952e84e add message clust... |
15 16 17 |
""".trimMargin() ) } |
43370abfe clear map canvas ... |
18 |
fun clearMapCanvas(map: LeafletMapView) { |
9e952e84e add message clust... |
19 20 |
map.execScript( """ |
79b001037 heat map |
21 |
|myRenderer.removeFrom(myMap); |
43370abfe clear map canvas ... |
22 |
|var myRenderer = L.canvas({ padding: 0.5 }); |
9e952e84e add message clust... |
23 24 |
""".trimMargin() ) |
53f01ecc3 display message o... |
25 |
} |
79b001037 heat map |
26 27 28 29 30 31 32 33 |
fun clearHeatMap(map: LeafletMapView) { map.execScript( """ |heatLayer.removeFrom(myMap); |var heatLayer = L.heatLayer([]).addTo(myMap); """.trimMargin() ) } |
9e952e84e add message clust... |
34 35 |
fun displayAllMessageOnMap(map: LeafletMapView) { clearMap(map) |
2bbe36a1b addd the possibil... |
36 |
observableVessel.vessels.forEach { (_, value) -> |
53f01ecc3 display message o... |
37 |
value.messages.forEach { (_, message) -> |
513c0341c add chart |
38 |
map.execScript("L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}).addTo(myMap)") |
53f01ecc3 display message o... |
39 40 |
} } |
2bbe36a1b addd the possibil... |
41 |
} |
f39d90e60 Select/deselect MMSI |
42 |
fun displayAllMessageOnMap(map: LeafletMapView, selectedMMSI: String) { |
9e952e84e add message clust... |
43 |
clearMap(map) |
2bbe36a1b addd the possibil... |
44 45 |
observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
46 47 |
if (selectedMMSI == message.mmsi.value) { map.execScript("L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 2, color: '#ff4040'}).addTo(myMap)") |
79b001037 heat map |
48 |
} else { |
513c0341c add chart |
49 |
map.execScript("L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}).addTo(myMap)") |
79b001037 heat map |
50 51 52 53 54 55 56 57 58 |
} } } } fun displayClusterMessageOnMap(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
59 |
map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}));") |
79b001037 heat map |
60 61 62 63 |
} } map.execScript("myMap.addLayer(markerClusters);") } |
3b26be8f9 controle the time... |
64 65 66 67 68 69 70 71 |
fun displayTargetedVessels(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> val message = value.messageToDisplay ?: return@forEach map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}));") } map.execScript("myMap.addLayer(markerClusters);") } |
f39d90e60 Select/deselect MMSI |
72 |
fun displayClusterMessageOnMap(map: LeafletMapView, selectedMMSI: String) { |
79b001037 heat map |
73 74 75 |
clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
76 77 |
if (selectedMMSI == message.mmsi.value) { map.execScript("L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 2, color: '#ff4040'}).addTo(myMap);") |
79b001037 heat map |
78 |
} else { |
513c0341c add chart |
79 |
map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}));") |
79b001037 heat map |
80 81 82 83 84 85 86 87 88 89 |
} } } map.execScript("myMap.addLayer(markerClusters);") } fun displayHeatMapOnMap(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
90 |
map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") |
79b001037 heat map |
91 92 |
} } |
79b001037 heat map |
93 |
} |
f39d90e60 Select/deselect MMSI |
94 |
fun displayHeatMapOnMap(map: LeafletMapView, selectedMMSI: String) { |
79b001037 heat map |
95 96 97 |
clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
98 99 |
if (selectedMMSI == message.mmsi.value) { map.execScript("L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 2, color: '#ff4040'}).addTo(myMap);") |
9e952e84e add message clust... |
100 |
} else { |
513c0341c add chart |
101 |
map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") |
2bbe36a1b addd the possibil... |
102 103 104 |
} } } |
79b001037 heat map |
105 |
map.execScript("myMap.addLayer(markerClusters);") |
53f01ecc3 display message o... |
106 |
} |