I want to activate pop up for a selected feature, move the map to show the popup location, and then if i choose to use the zoom to function to go to the feature.
Unfortunately it throws an error: "Cannot center at a location without a target and view."
Here is what i have so far:
var fl = this.view?.map.findLayerById(data.featureLayerGroup.id);
fl.queryFeatures({ where: "id = '" + data.id + "'" }).then(results => {
if (results.features.length) {
this.view?.popup.open({
features: results.features
});
}
}
);
I been going through the docs but cannot find the solution
Solved! Go to Solution.
Figured it out, simple yet couldn't find it in docs.
If you want the popup to point to the feature at hand, you need to ensure the query returns the geometry AND updateLocationEnabled is enabled.
new code:
var fl = this.view?.map.findLayerById(data.featureLayerGroup.id);
fl.queryFeatures({ where: "id = '" + data.id + "'", returnGeometry: true }).then(results => {
if (results.features.length) {
this.view?.popup.open({
features: results.features,
updateLocationEnabled: true
});
}
}
);
Figured it out, simple yet couldn't find it in docs.
If you want the popup to point to the feature at hand, you need to ensure the query returns the geometry AND updateLocationEnabled is enabled.
new code:
var fl = this.view?.map.findLayerById(data.featureLayerGroup.id);
fl.queryFeatures({ where: "id = '" + data.id + "'", returnGeometry: true }).then(results => {
if (results.features.length) {
this.view?.popup.open({
features: results.features,
updateLocationEnabled: true
});
}
}
);