Skip to content

Commit

Permalink
Fix: draw marker on first load
Browse files Browse the repository at this point in the history
  • Loading branch information
ljowen committed Dec 18, 2023
1 parent 12ccee3 commit bcd825b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Models/LocationMarkerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ export function getMarkerLocation(terria: Terria): LatLonHeight | undefined {
}
return undefined;
}

export function getMarkerCatalogItem(terria: Terria) {
return terria.getModelById(CzmlCatalogItem, MARKER_UNIQUE_ID);
}
15 changes: 15 additions & 0 deletions lib/ReactViewModels/ViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
import DisclaimerHandler from "./DisclaimerHandler";
import SearchState from "./SearchState";
import CatalogSearchProviderMixin from "../ModelMixins/SearchProviders/CatalogSearchProviderMixin";
import { getMarkerCatalogItem } from "../Models/LocationMarkerUtils";
import CzmlCatalogItem from "../Models/Catalog/CatalogItems/CzmlCatalogItem";

export const DATA_CATALOG_NAME = "data-catalog";
export const USER_DATA_NAME = "my-data";
Expand Down Expand Up @@ -368,6 +370,7 @@ export default class ViewState {
private _mobileMenuSubscription: IReactionDisposer;
private _storyPromptSubscription: IReactionDisposer;
private _previewedItemIdSubscription: IReactionDisposer;
private _locationMarkerSubscription: IReactionDisposer;
private _workbenchHasTimeWMSSubscription: IReactionDisposer;
private _storyBeforeUnloadSubscription: IReactionDisposer;
private _disclaimerHandler: DisclaimerHandler;
Expand Down Expand Up @@ -475,6 +478,17 @@ export default class ViewState {
}
);

this._locationMarkerSubscription = reaction(
() => getMarkerCatalogItem(this.terria),
(item: CzmlCatalogItem | undefined) => {
if (item) {
terria.overlays.add(item);
/* dispose subscription after init */
this._locationMarkerSubscription();
}
}
);

this._previewedItemIdSubscription = reaction(
() => this.terria.previewedItemId,
async (previewedItemId: string | undefined) => {
Expand Down Expand Up @@ -525,6 +539,7 @@ export default class ViewState {
this._storyPromptSubscription();
this._previewedItemIdSubscription();
this._workbenchHasTimeWMSSubscription();
this._locationMarkerSubscription();
this._disclaimerHandler.dispose();
this.searchState.dispose();
}
Expand Down

0 comments on commit bcd825b

Please sign in to comment.