Blame view
src/main/kotlin/map/MapDisplayer.kt
3.89 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 |
} |
9e952e84e add message clust... |
42 43 |
fun displayAllMessageOnMap(map: LeafletMapView, selectedMMSI: Int) { 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 64 65 66 67 68 |
} } map.execScript("myMap.addLayer(markerClusters);") } fun displayClusterMessageOnMap(map: LeafletMapView, selectedMMSI: Int) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
69 70 |
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 |
71 |
} else { |
513c0341c add chart |
72 |
map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}));") |
79b001037 heat map |
73 74 75 76 77 78 79 80 81 82 |
} } } map.execScript("myMap.addLayer(markerClusters);") } fun displayHeatMapOnMap(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
83 |
map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") |
79b001037 heat map |
84 85 |
} } |
79b001037 heat map |
86 87 88 89 90 91 |
} fun displayHeatMapOnMap(map: LeafletMapView, selectedMMSI: Int) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
92 93 |
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... |
94 |
} else { |
513c0341c add chart |
95 |
map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") |
2bbe36a1b addd the possibil... |
96 97 98 |
} } } |
79b001037 heat map |
99 |
map.execScript("myMap.addLayer(markerClusters);") |
53f01ecc3 display message o... |
100 |
} |