Skip to content

Fix disappearing of MyLocation point#7731

Merged
na9da merged 4 commits intoTerriaJS:mainfrom
bioretics:fix-mylocation-visibility
Jan 22, 2026
Merged

Fix disappearing of MyLocation point#7731
na9da merged 4 commits intoTerriaJS:mainfrom
bioretics:fix-mylocation-visibility

Conversation

@glughi
Copy link
Copy Markdown
Contributor

@glughi glughi commented Nov 17, 2025

What this PR does

Fixes #7725

Checklist

  • There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
  • I've updated relevant documentation in doc/.
  • I've updated CHANGES.md with what I changed.
  • I've provided instructions in the PR description on how to test this PR.

@glughi
Copy link
Copy Markdown
Contributor Author

glughi commented Jan 9, 2026

Hello, any news about this PR?

@niktayv
Copy link
Copy Markdown
Collaborator

niktayv commented Jan 12, 2026

Hi Giovanni. Thanks for the fix and for your interest in improving TerriaJS.
I tested your solution locally, and it does resolve the issue.

Can I suggest you tweak the implementation to be a bit more robust and generic?

As far as I understand your idea, we want the app-generated "My Location" item to remain visible, even when the "Terrain hides underground features" checkbox is enabled. Your solution works, but it creates a coupling to i18n and to a very concrete instance of the item, which may be a leaky abstraction.

Add a generic trait isAlwaysVisible?: boolean = false to lib/Traits/TraitsClasses/GeoJsonTraits.ts with a description for disabling depth testing.

@primitiveTrait({
  type: "boolean",
  name: "Is Always Visible",
  description:
    "If true, points will render without depth testing so they remain visible through terrain and tiles."
})
isAlwaysVisible?: boolean = false;

Set this trait on the app-created My Location marker in lib/ReactViews/Map/MapNavigation/Items/MyLocation.ts:

this._marker.setTrait(CommonStrata.user, "isAlwaysVisible", true);

In lib/ModelMixins/GeojsonMixin.ts, switch the depth-test override to:

disableDepthTestDistance: this.isAlwaysVisible
  ? new ConstantProperty(Number.POSITIVE_INFINITY)
  : undefined

Hopefully, this will be closer to TerriaJS’s architecture (avoiding name/i18n coupling and making the behaviour reusable).

@na9da
Copy link
Copy Markdown
Collaborator

na9da commented Jan 14, 2026

I agree with @niktayv's comment on moving the setting to somewhere that is more specific.

This could be done in MyLocation.ts where the marker is created, by adding something like below:

// Set depth test distance to a large value to disable it so that the marker is visible even when dept testing is enabled
this._marker.defaultStyle.point.null.setTrait(CommonStrata.user, "disableDepthTestDistance", 9999999);

This is using the existing disableDepthTestDistance trait (which is honestly a bit hard to find)

@glughi
Copy link
Copy Markdown
Contributor Author

glughi commented Jan 14, 2026

Hi @na9da, I tried the suggestion (and some variations), but it doesn't seem to work to fix the issue.

@na9da
Copy link
Copy Markdown
Collaborator

na9da commented Jan 16, 2026

Ah sorry! That's because when using simple-style for GeoJSON these other styling traits (like disableDepthTestDistance) are ignored.

In that case I would use what @niktayv has suggested - to add a new trait and set that from MyLocation.ts - but maybe name the new boolean trait disableDepthTest instead of isAlwaysVisible to make it a bit more obvious.

Copy link
Copy Markdown
Collaborator

@niktayv niktayv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@na9da
Copy link
Copy Markdown
Collaborator

na9da commented Jan 22, 2026

LGTM. Thanks @glughi @niktayv

@na9da na9da merged commit 6bdbd08 into TerriaJS:main Jan 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

My Location point disappears

3 participants