Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private tryAddFeatureToMap(layer: SearchResult) {
if (layer.meta.dataType !== FEATURE) {
return undefined;
}
// Somethimes features have no geometry. It happens with some GetFeatureInfo
if (layer.data.geometry === undefined) {
return;
}
this.map.overlay.setFeatures(
[layer.data] as Feature[],
FeatureMotion.Default
);
}
private tryAddFeatureToMap(result: SearchResult) {
if (result.meta.dataType !== FEATURE) {
return undefined;
}
const feature = (result as SearchResult).data;
// Somethimes features have no geometry. It happens with some GetFeatureInfo
if (feature.geometry === undefined) {
return;
}
this.map.overlay.setFeatures([feature], FeatureMotion.Default);
}
ngOnInit() {
const loadingStrategy = new FeatureStoreLoadingStrategy({});
this.store.addStrategy(loadingStrategy);
const selectionStrategy = new FeatureStoreSelectionStrategy({
map: this.map,
motion: FeatureMotion.Default
});
this.store.addStrategy(selectionStrategy);
this.store.load([
{
meta: { id: 1 },
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [-72, 47.8]
},
projection: 'EPSG:4326',
properties: {
id: 1,
name: 'Name 1',
description: 'Description 1'
this.resultSelected$.next(result);
const features = [];
for (const feature of this.store.all()) {
feature.data === this.resultSelected$.getValue().data ?
feature.data.meta.style = this.getSelectedMarkerStyle(feature.data) :
feature.data.meta.style = this.getMarkerStyle(feature.data);
features.push(feature.data);
}
this.map.overlay.setFeatures(features, FeatureMotion.None);
if (this.zoomAuto) {
const olFeature = this.format.readFeature(this.resultSelected$.getValue().data, {
dataProjection: this.resultSelected$.getValue().data.projection,
featureProjection: this.map.projection
});
moveToOlFeatures(this.map, [olFeature], FeatureMotion.Default);
}
this.isResultSelected$.next(true);
this.initialized = false;
}