Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,19 @@ export class GeoengineRecord extends Component {
return {
context: this.props.record.context,
JSON,
record: this.props.record,
// The info-box template reads fields as `record.<field>.value`.
// `this.record` (built by createRecord) exposes every loaded field
// as `{value}`. Wrap it in a Proxy so fields referenced in the
// template but not loaded in the view resolve to
// `{value: undefined}` instead of throwing while rendering.
record: new Proxy(this.record, {
get(target, prop) {
if (typeof prop === "symbol" || prop in target) {
return target[prop];
}
return {value: undefined};
},
}),
read_only_mode: this.props.readonly,
selection_mode: this.props.forceGlobalClick,
user_context: user.context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,17 +599,25 @@ export class GeoengineRenderer extends Component {

zoomOnFeature(record) {
const feature = this.vectorSource.getFeatureById(record.resId);
// Records without geometry have no feature to zoom on.
if (!feature) {
return;
}
var map_view = this.map.getView();
if (map_view) {
map_view.fit(feature.getGeometry(), {maxZoom: 14});
}
}

getOriginalZoom() {
var extent = this.vectorLayersResult
.find((res) => res.values_.visible === true)
.getSource()
.getExtent();
const visibleLayer = this.vectorLayersResult.find(
(res) => res.values_.visible === true
);
// No visible vector layer means there is nothing to fit the view to.
if (!visibleLayer) {
return;
}
var extent = visibleLayer.getSource().getExtent();
var infinite_extent = [Infinity, Infinity, -Infinity, -Infinity];
if (JSON.stringify(extent) === JSON.stringify(infinite_extent)) {
extent = [-13360714.671289, 5314503.622, 8284735.328607, 7099727.320865];
Expand Down
Loading