AW-6046 Fix open layers 8 issues
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
parent
023048a5bb
commit
97d6d569a0
@ -19,6 +19,7 @@ import VectorTileLayer from 'ol/layer/VectorTile';
|
|||||||
import {GeoJSON,MVT} from 'ol/format';
|
import {GeoJSON,MVT} from 'ol/format';
|
||||||
import { Geometry } from 'ol/geom';
|
import { Geometry } from 'ol/geom';
|
||||||
import BaseLayer from 'ol/layer/Base';
|
import BaseLayer from 'ol/layer/Base';
|
||||||
|
import Feature from 'ol/Feature';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'fm-map-item-layers',
|
selector: 'fm-map-item-layers',
|
||||||
@ -180,9 +181,9 @@ export class ItemLayersComponent extends LayerGroupComponent implements OnChange
|
|||||||
const source = new VectorSource({
|
const source = new VectorSource({
|
||||||
strategy: loadingstrategy.bbox,
|
strategy: loadingstrategy.bbox,
|
||||||
loader: function (extent: Extent, resolution: number, projection: Projection) {
|
loader: function (extent: Extent, resolution: number, projection: Projection) {
|
||||||
const source = this as VectorSource<Geometry>;
|
const source = this as VectorSource<Feature<Geometry>>;
|
||||||
__this.itemService.getItemFeatures(item.code, extent, projection.getCode(), layerIndex).subscribe(function (data) {
|
__this.itemService.getItemFeatures(item.code, extent, projection.getCode(), layerIndex).subscribe(function (data) {
|
||||||
const features = format.readFeatures(data);
|
const features = format.readFeatures(data).filter(feature => feature instanceof Feature) as Feature[];
|
||||||
for (const f of features) {
|
for (const f of features) {
|
||||||
if (f.get("code")) {
|
if (f.get("code")) {
|
||||||
f.setId(f.get("code"));
|
f.setId(f.get("code"));
|
||||||
|
@ -29,7 +29,7 @@ import { formatNumber } from '@angular/common';
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnDestroy, OnChanges {
|
export class ItemVectorSourceComponent extends SourceVectorComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
instance: Vector<Geometry>;
|
instance: Vector<Feature<Geometry>>;
|
||||||
private _format: GeoJSON;
|
private _format: GeoJSON;
|
||||||
private _select: Select;
|
private _select: Select;
|
||||||
private _hoverSelect: Select;
|
private _hoverSelect: Select;
|
||||||
|
@ -3,6 +3,7 @@ import { LayerVectorComponent, MapComponent } from 'ng-openlayers';
|
|||||||
import RenderType from 'ol/layer/Vector';
|
import RenderType from 'ol/layer/Vector';
|
||||||
import { Vector as VectorSource } from 'ol/source';
|
import { Vector as VectorSource } from 'ol/source';
|
||||||
import { Geometry } from 'ol/geom';
|
import { Geometry } from 'ol/geom';
|
||||||
|
import Feature from 'ol/Feature';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'fm-map-aol-layer-vector-image',
|
selector: 'fm-map-aol-layer-vector-image',
|
||||||
@ -14,7 +15,7 @@ export class LayerVectorImageComponent extends LayerVectorComponent implements O
|
|||||||
//public source: Vector;
|
//public source: Vector;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
renderMode: RenderType<VectorSource<Geometry>> | string = "image";
|
renderMode: RenderType<VectorSource<Feature<Geometry>>> | string = "image";
|
||||||
|
|
||||||
constructor(map: MapComponent) {
|
constructor(map: MapComponent) {
|
||||||
super(map);
|
super(map);
|
||||||
|
@ -133,7 +133,7 @@ export class MapEffects {
|
|||||||
f.id = f.properties["code"];
|
f.id = f.properties["code"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return of(new mapActions.StartSearchSuccess(this._geojsonFormat.readFeatures(features), a.queryState));
|
return of(new mapActions.StartSearchSuccess(this._geojsonFormat.readFeatures(features).filter(feature => feature instanceof Feature) as Feature[], a.queryState));
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
catchError(error => of(new commonActions.Fail(error))));
|
catchError(error => of(new commonActions.Fail(error))));
|
||||||
@ -218,7 +218,7 @@ export class MapEffects {
|
|||||||
if (!this.overrideSelectedItemLayer) {
|
if (!this.overrideSelectedItemLayer) {
|
||||||
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
return this.itemService$.getFeature(action.item.code, "EPSG:3857").pipe(
|
||||||
map((feature: any) => {
|
map((feature: any) => {
|
||||||
const f = this._geojsonFormat.readFeature(feature);
|
const f = this._geojsonFormat.readFeature(feature) as Feature;
|
||||||
f.setId(action.item.code);
|
f.setId(action.item.code);
|
||||||
return new mapActions.AddFeatureSuccess(f);
|
return new mapActions.AddFeatureSuccess(f);
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user