CircleMarkerGenerator.kt 573 Bytes
package map

import application.model.observableMessages

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)")
        }
    }
}