diff --git a/src/main/kotlin/map/CircleMarkerGenerator.kt b/src/main/kotlin/map/CircleMarkerGenerator.kt index c08da33..e30ebc0 100644 --- a/src/main/kotlin/map/CircleMarkerGenerator.kt +++ b/src/main/kotlin/map/CircleMarkerGenerator.kt @@ -2,11 +2,15 @@ package map import application.model.observableMessages -fun clearMap(map: LeafletMapView) { - map.clearAllLayer() +fun clearMapCanvas(map: LeafletMapView) { + map.execScript(""" + |myRenderer.removeFrom(myMap) + |var myRenderer = L.canvas({ padding: 0.5 }); + """.trimMargin()) } fun displayMessageOnMap(map: LeafletMapView) { + clearMapCanvas(map) observableMessages.vessels.forEach { (_, value) -> value.messages.forEach { (_, message) -> map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01}).addTo(myMap)") diff --git a/src/main/kotlin/map/LeafletMapView.kt b/src/main/kotlin/map/LeafletMapView.kt index 1228dc0..238805c 100644 --- a/src/main/kotlin/map/LeafletMapView.kt +++ b/src/main/kotlin/map/LeafletMapView.kt @@ -92,7 +92,7 @@ class LeafletMapView : StackPane() { | zoomControl: false, | layers: [layer1] |}); - |L.control.scale().addTo(mymap); + |L.control.scale().addTo(myMap); |var myRenderer = L.canvas({ padding: 0.5 });""".trimMargin() )