Blame view

src/main/kotlin/map/MapDisplayer.kt 1.55 KB
53f01ecc3   lsagona   display message o...
1
  package map
2bbe36a1b   lsagona   addd the possibil...
2
  import application.model.observableVessel
53f01ecc3   lsagona   display message o...
3

9e952e84e   lsagona   add message clust...
4
5
6
7
8
9
10
11
12
13
14
15
16
  fun clearMap(map: LeafletMapView) {
      clearMapCanvas(map)
      clearMapCluster(map)
  }
  
  fun clearMapCluster(map: LeafletMapView) {
      map.execScript(
          """
          |myMap.removeLayer(markerClusters)
          |var markerClusters = L.markerClusterGroup({spiderfyOnMaxZoom: false, disableClusteringAtZoom: 9});
      """.trimMargin()
      )
  }
43370abfe   lsagona   clear map canvas ...
17
  fun clearMapCanvas(map: LeafletMapView) {
9e952e84e   lsagona   add message clust...
18
19
      map.execScript(
          """
43370abfe   lsagona   clear map canvas ...
20
21
          |myRenderer.removeFrom(myMap)
          |var myRenderer = L.canvas({ padding: 0.5 });
9e952e84e   lsagona   add message clust...
22
23
      """.trimMargin()
      )
53f01ecc3   lsagona   display message o...
24
  }
9e952e84e   lsagona   add message clust...
25
26
  fun displayAllMessageOnMap(map: LeafletMapView) {
      clearMap(map)
2bbe36a1b   lsagona   addd the possibil...
27
      observableVessel.vessels.forEach { (_, value) ->
53f01ecc3   lsagona   display message o...
28
          value.messages.forEach { (_, message) ->
52321443a   lsagona   different color f...
29
              map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColor()}'}).addTo(myMap)")
53f01ecc3   lsagona   display message o...
30
31
          }
      }
2bbe36a1b   lsagona   addd the possibil...
32
  }
9e952e84e   lsagona   add message clust...
33
34
  fun displayAllMessageOnMap(map: LeafletMapView, selectedMMSI: Int) {
      clearMap(map)
2bbe36a1b   lsagona   addd the possibil...
35
36
      observableVessel.vessels.forEach { (_, value) ->
          value.messages.forEach { (_, message) ->
9e952e84e   lsagona   add message clust...
37
38
39
              if (selectedMMSI == message.mmsi) {
                  map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 2, color: '#ff001e'}).addTo(myMap)")
              } else {
2bbe36a1b   lsagona   addd the possibil...
40
41
42
43
                  map.execScript("L.circleMarker([${message.latitude}, ${message.longitude}], {renderer: myRenderer, radius: 0.01, color: '#${message.getHexColor()}'}).addTo(myMap)")
              }
          }
      }
53f01ecc3   lsagona   display message o...
44
  }