Skip to content

Commit

Permalink
Fix zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney committed Aug 29, 2024
1 parent 34fd1fe commit 90751d1
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions packages/base/src/mainview/mainViewOl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ export class OlMainView extends React.Component<IProps, IStates> {
this._onSharedOptionsChanged,
this
);
// this._model.clientStateChanged.connect(
// this._onClientSharedStateChanged,
// this
// );
this._model.clientStateChanged.connect(
this._onClientSharedStateChanged,
this
);

this._model.sharedLayersChanged.connect(this._onLayersChanged, this);
this._model.sharedLayerTreeChanged.connect(this._onLayerTreeChange, this);
Expand Down Expand Up @@ -109,10 +109,10 @@ export class OlMainView extends React.Component<IProps, IStates> {
this
);

// this._model.clientStateChanged.disconnect(
// this._onClientSharedStateChanged,
// this
// );
this._model.clientStateChanged.disconnect(
this._onClientSharedStateChanged,
this
);

this._mainViewModel.dispose();
}
Expand All @@ -137,17 +137,21 @@ export class OlMainView extends React.Component<IProps, IStates> {

const view = this._Map.getView();
const center = view.getCenter();
if (!center) {
const zoom = view.getZoom();
if (!center || !zoom) {
return;
}
const latLng = toLonLat(center, view.getProjection());
const projection = view.getProjection();
const latLng = toLonLat(center, projection);
const bearing = view.getRotation();
// const pitch = this._Map.getPitch();
this._model.setOptions({
...this._model.getOptions(),
latitude: latLng[1],
longitude: latLng[0],
bearing
bearing,
projection: projection.getCode(),
zoom
});
});

Expand Down Expand Up @@ -831,7 +835,9 @@ export class OlMainView extends React.Component<IProps, IStates> {
change?: MapChange
): void {
if (!this._initializedPosition) {
console.log('on change options');
const options = this._model.getOptions();
console.log('options', options);

this.updateOptions(options);

Expand All @@ -842,7 +848,7 @@ export class OlMainView extends React.Component<IProps, IStates> {
private updateOptions(options: IJGISOptions) {
const centerCoord = fromLonLat(
[options.longitude, options.latitude],
this._Map.getView().getProjection()
options.projection
);

console.log('centerCoord', centerCoord);
Expand Down

0 comments on commit 90751d1

Please sign in to comment.