Commit 43370abfea7cd24e86ea747adf23c021031c24dc

Authored by lsagona
1 parent 53f01ecc34
Exists in master and in 1 other branch dev

clear map canvas when importing new data set

Showing 2 changed files with 7 additions and 3 deletions Side-by-side Diff

src/main/kotlin/map/CircleMarkerGenerator.kt View file @ 43370ab
... ... @@ -2,11 +2,15 @@
2 2  
3 3 import application.model.observableMessages
4 4  
5   -fun clearMap(map: LeafletMapView) {
6   - map.clearAllLayer()
  5 +fun clearMapCanvas(map: LeafletMapView) {
  6 + map.execScript("""
  7 + |myRenderer.removeFrom(myMap)
  8 + |var myRenderer = L.canvas({ padding: 0.5 });
  9 + """.trimMargin())
7 10 }
8 11  
9 12 fun displayMessageOnMap(map: LeafletMapView) {
  13 + clearMapCanvas(map)
10 14 observableMessages.vessels.forEach { (_, value) ->
11 15 value.messages.forEach { (_, message) ->
12 16 map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01}).addTo(myMap)")
src/main/kotlin/map/LeafletMapView.kt View file @ 43370ab
... ... @@ -92,7 +92,7 @@
92 92 | zoomControl: false,
93 93 | layers: [layer1]
94 94 |});
95   - |L.control.scale().addTo(mymap);
  95 + |L.control.scale().addTo(myMap);
96 96 |var myRenderer = L.canvas({ padding: 0.5 });""".trimMargin()
97 97 )
98 98