mapbox / mapbox/mapbox-unity-sdk
branch SDK3 V3.06 When using TransformBasedTileProvider setting position via MapInformation.SetInformation does not always update VectorLayerModule correctly
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 784
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Description
If you are using TransformBasedTileProvider(didn't test with other stuff) and set a new coordinate via MapInformation.SetInformation VectorLayerModule doesn't update the position of tiles.
For StaticApiLayerModule, if you move the MapInformation latitude and longitude a bit, the tile will update its position. If you move far, the tiles respawn. This is ok!
For VectorLayerModule, if you move the MapInformation latitude and longitude a bit, the tile will not update its position. If you move far, the tiles respawn. This is not ok!
I "think" StaticApiLayerModule works fine cause of MapboxMapVisualizer ->Load -> ShowTile calls for IMapInformation.PositionObjectFor, Load is called every frame and that updates the tile position. VectorLayerModule doesn't have that sort of update. The crude way to fix this is to add the same IMapInformation.PositionObjectFor inside VectorLayerVisualizer -> SetActive
public void SetActive(CanonicalTileId canonicalTileId, bool isActive, IMapInformation mapInformation)
{
if (isActive)
{
if (_results.TryGetValue(canonicalTileId, out var visuals))
{
foreach (var entity in visuals)
{
if (_stackList.TryGetValue(entity.StackId, out var stack))
{
var isVisible = stack.IsZinSupportedRange(_mapInformation.AbsoluteZoom);
entity.GameObject.SetActive(isVisible);
_mapInformation.PositionObjectFor(entity.GameObject, canonicalTileId);
}
}
}
}
else
{
UnregisterTile(canonicalTileId);
}
}
But it would update every frame, which could impact performance. I think a better approach would be to tie most of the calls to IMapInformation.PositionObjectFor via IMapInformation.LatitudeLongitudeChanged and IMapInformation.WorldScaleChanged, so they don't happen every single frame. (Sorry, don't have time to write a full PR with this idea)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with VectorLayerVisualizer.SetActive and MapInformation.SetInformation, then compare the StaticApiLayerModule path through MapboxMapVisualizer.Load and ShowTile. Reproduce small and large latitude/longitude changes with TransformBasedTileProvider and verify that vector tiles update on small moves without requiring per-frame positioning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100