Skip to content
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
25 changes: 18 additions & 7 deletions packages/base/src/mainview/mainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ export class MainView extends React.Component<IProps, IStates> {
const center = view.getCenter() || [0, 0];
const zoom = view.getZoom() || 0;

const projection = view.getProjection();
const projection =
getProjection(currentOptions.projection) ?? view.getProjection();
const latLng = toLonLat(center, projection);
const bearing = view.getRotation();
const resolution = view.getResolution();
Expand Down Expand Up @@ -413,12 +414,16 @@ export class MainView extends React.Component<IProps, IStates> {
this._contextMenu.open(event);
});

const projection =
getProjection(this._model.getOptions().projection) ??
view.getProjection();

this.setState(old => ({
...old,
loading: false,
viewProjection: {
code: view.getProjection().getCode(),
units: view.getProjection().getUnits(),
code: projection.getCode(),
units: projection.getUnits(),
},
}));
}
Expand Down Expand Up @@ -1711,13 +1716,23 @@ export class MainView extends React.Component<IProps, IStates> {
if (projection !== undefined && currentProjection !== projection) {
const newProjection = getProjection(projection);
if (newProjection) {
this.setState(old => ({
viewProjection: {
...old.viewProjection,
code: newProjection.getCode(),
units: newProjection.getUnits(),
},
}));
view = new View({ projection: newProjection });
} else {
console.warn(`Invalid projection: ${projection}`);
return;
}
}

view.setRotation(bearing || 0);
this._Map.setView(view);

// Use the extent only if explicitly requested (QGIS files).
if (useExtent && extent) {
view.fit(extent);
Expand All @@ -1735,10 +1750,6 @@ export class MainView extends React.Component<IProps, IStates> {
this._model.setOptions(options);
}
}

view.setRotation(bearing || 0);

this._Map.setView(view);
}

private _onViewChanged(
Expand Down
Loading