Blame view
src/main/kotlin/map/MapDisplayer.kt
7.14 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) |
78935bd62 slider bind to al... |
8 |
clearMarker(map) |
9e952e84e add message clust... |
9 10 11 12 13 |
} fun clearMapCluster(map: LeafletMapView) { map.execScript( """ |
79b001037 heat map |
14 15 |
|myMap.removeLayer(markerClusters); |var markerClusters = L.markerClusterGroup({spiderfyOnMaxZoom: false, disableClusteringAtZoom: 10}); |
9e952e84e add message clust... |
16 17 18 |
""".trimMargin() ) } |
43370abfe clear map canvas ... |
19 |
fun clearMapCanvas(map: LeafletMapView) { |
9e952e84e add message clust... |
20 21 |
map.execScript( """ |
79b001037 heat map |
22 |
|myRenderer.removeFrom(myMap); |
43370abfe clear map canvas ... |
23 |
|var myRenderer = L.canvas({ padding: 0.5 }); |
9e952e84e add message clust... |
24 25 |
""".trimMargin() ) |
53f01ecc3 display message o... |
26 |
} |
79b001037 heat map |
27 28 29 30 31 32 33 34 |
fun clearHeatMap(map: LeafletMapView) { map.execScript( """ |heatLayer.removeFrom(myMap); |var heatLayer = L.heatLayer([]).addTo(myMap); """.trimMargin() ) } |
78935bd62 slider bind to al... |
35 36 37 38 39 40 41 42 43 44 |
fun clearMarker(map: LeafletMapView) { map.execScript( """ |for(var i = 0; i < markers.length; i++){ |myMap.removeLayer(markers[i]); |} |markers = [] """.trimMargin() ) } |
9e952e84e add message clust... |
45 46 |
fun displayAllMessageOnMap(map: LeafletMapView) { clearMap(map) |
2bbe36a1b addd the possibil... |
47 |
observableVessel.vessels.forEach { (_, value) -> |
53f01ecc3 display message o... |
48 |
value.messages.forEach { (_, message) -> |
513c0341c add chart |
49 |
map.execScript("L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}).addTo(myMap)") |
53f01ecc3 display message o... |
50 51 |
} } |
2bbe36a1b addd the possibil... |
52 |
} |
78935bd62 slider bind to al... |
53 54 55 56 57 58 59 |
fun displayTimedAllMessageOnMap(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> val message = value.messageToDisplay ?: return@forEach map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 0.01, color: '#${message.getHexColorStroke()}'}).addTo(myMap))") } } |
f39d90e60 Select/deselect MMSI |
60 |
fun displayAllMessageOnMap(map: LeafletMapView, selectedMMSI: String) { |
9e952e84e add message clust... |
61 |
clearMap(map) |
2bbe36a1b addd the possibil... |
62 63 |
observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
64 |
if (selectedMMSI == message.mmsi.value) { |
dd1ce7fe8 add button to swi... |
65 |
map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 2, color: '#ff4040'}).addTo(myMap))") |
79b001037 heat map |
66 |
} else { |
dd1ce7fe8 add button to swi... |
67 |
map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}).addTo(myMap))") |
79b001037 heat map |
68 69 70 71 |
} } } } |
78935bd62 slider bind to al... |
72 73 74 75 76 77 78 79 80 81 82 |
fun displayTimedAllMessageOnMap(map: LeafletMapView, selectedMMSI: String) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> val message = value.messageToDisplay ?: return@forEach if (selectedMMSI == message.mmsi.value) { map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 2, color: '#ff4040'}).addTo(myMap))") } else { map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}).addTo(myMap))") } } } |
79b001037 heat map |
83 84 85 86 |
fun displayClusterMessageOnMap(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
87 |
map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}));") |
79b001037 heat map |
88 89 90 91 |
} } map.execScript("myMap.addLayer(markerClusters);") } |
78935bd62 slider bind to al... |
92 |
fun displayTimedClusterMessageOnMap(map: LeafletMapView) { |
3b26be8f9 controle the time... |
93 94 95 |
clearMap(map) observableVessel.vessels.forEach { (_, value) -> val message = value.messageToDisplay ?: return@forEach |
78935bd62 slider bind to al... |
96 |
map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 0.01, color: '#${message.getHexColorStroke()}'}));") |
3b26be8f9 controle the time... |
97 98 99 |
} map.execScript("myMap.addLayer(markerClusters);") } |
f39d90e60 Select/deselect MMSI |
100 |
fun displayClusterMessageOnMap(map: LeafletMapView, selectedMMSI: String) { |
79b001037 heat map |
101 102 103 |
clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
104 |
if (selectedMMSI == message.mmsi.value) { |
dd1ce7fe8 add button to swi... |
105 |
map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 2, color: '#ff4040'}).addTo(myMap));") |
79b001037 heat map |
106 |
} else { |
513c0341c add chart |
107 |
map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColorStroke()}'}));") |
79b001037 heat map |
108 109 110 111 112 |
} } } map.execScript("myMap.addLayer(markerClusters);") } |
78935bd62 slider bind to al... |
113 114 115 116 117 118 119 120 121 122 123 124 |
fun displayTimedClusterMessageOnMap(map: LeafletMapView, selectedMMSI: String) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> val message = value.messageToDisplay ?: return@forEach if (selectedMMSI == message.mmsi.value) { map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 2, color: '#ff4040'}).addTo(myMap));") } else { map.execScript("markerClusters.addLayer(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 0.01, color: '#${message.getHexColorStroke()}'}));") } } map.execScript("myMap.addLayer(markerClusters);") } |
79b001037 heat map |
125 126 127 128 |
fun displayHeatMapOnMap(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
129 |
map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") |
79b001037 heat map |
130 131 |
} } |
79b001037 heat map |
132 |
} |
78935bd62 slider bind to al... |
133 134 135 136 137 138 139 |
fun displayTimedHeatMapOnMap(map: LeafletMapView) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> val message = value.messageToDisplay ?: return@forEach map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") } } |
f39d90e60 Select/deselect MMSI |
140 |
fun displayHeatMapOnMap(map: LeafletMapView, selectedMMSI: String) { |
79b001037 heat map |
141 142 143 |
clearMap(map) observableVessel.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> |
513c0341c add chart |
144 |
if (selectedMMSI == message.mmsi.value) { |
dd1ce7fe8 add button to swi... |
145 |
map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 2, color: '#ff4040'}).addTo(myMap));") |
9e952e84e add message clust... |
146 |
} else { |
513c0341c add chart |
147 |
map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") |
2bbe36a1b addd the possibil... |
148 149 150 |
} } } |
79b001037 heat map |
151 |
map.execScript("myMap.addLayer(markerClusters);") |
78935bd62 slider bind to al... |
152 153 154 155 156 157 158 159 160 161 162 163 |
} fun displayTimedHeatMapOnMap(map: LeafletMapView, selectedMMSI: String) { clearMap(map) observableVessel.vessels.forEach { (_, value) -> val message = value.messageToDisplay ?: return@forEach if (selectedMMSI == message.mmsi.value) { map.execScript("markers.push(L.circleMarker([${message.latitude.value}, ${message.longitude.value}], {radius: 2, color: '#ff4040'}).addTo(myMap));") } else { map.execScript("heatLayer.addLatLng([${message.latitude.value}, ${message.longitude.value}]);") } } |
53f01ecc3 display message o... |
164 |
} |