Pārlūkot izejas kodu

fix: Modify map component for multi instance hslayers

fzadrazil 3 gadi atpakaļ
vecāks
revīzija
aec0c4d97b
1 mainītis faili ar 11 papildinājumiem un 6 dzēšanām
  1. 11 6
      src/app/dashboard/components/map/map.component.ts

+ 11 - 6
src/app/dashboard/components/map/map.component.ts

@@ -110,7 +110,9 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges {
       //    multiWorld: false,
           //zoom: 6
       })
-    });
+    },
+      null
+    );
   }
 
   ngOnInit(): void {
@@ -121,13 +123,14 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges {
       //this.dataReady = true;
 
       //if (this.mapReady)
-      this.HsMapService.loaded().then((map) => {
+      this.HsMapService.loaded(null).then((map) => {
         this.initMap();
+        let mapObj = this.HsMapService.getMap(null);
 
         let unitsExtent: Extent = this.unitsLayer.getSource().getExtent();
-        this.HsMapService.map.getView().fit(unitsExtent, { size: this.HsMapService.map.getSize() });
+        mapObj.getView().fit(unitsExtent, { size: mapObj.getSize() });
 
-        this.HsMapService.map.on("pointermove", function (evt) {
+        mapObj.on("pointermove", function (evt) {
           var hit = this.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
             return true;
           });
@@ -148,8 +151,10 @@ export class MapComponent implements OnInit, OnDestroy, OnChanges {
   }
 
   initMap(): void {
-    this.unitsLayer = this.initUnitsLayer(this.HsMapService.map);
-    this.HsMapService.map.addLayer(this.unitsLayer);
+    let mapObj = this.HsMapService.getMap(null);
+
+    this.unitsLayer = this.initUnitsLayer(mapObj);
+    mapObj.addLayer(this.unitsLayer);
 
   //  this.HsMapService.map.on('click', function (evt) {
   //    var feature = this.HsMapService.map.forEachFeatureAtPixel(evt.pixel,