Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the Map Extent Options to CameraBounds at runtime doesn't work #1904

Open
mmoussa opened this issue Mar 15, 2023 · 1 comment
Open

Comments

@mmoussa
Copy link

mmoussa commented Mar 15, 2023

I'm trying to set the map extent options to Camera Bounds at runtime, and I'm running into the following error:

NullReferenceException: Object reference not set to an instance of an object
Mapbox.Unity.Map.TileProviders.QuadTreeTileProvider.OnInitialized () (at Assets/Mapbox/Unity/Map/TileProviders/QuadTreeTileProvider.cs:50)
Mapbox.Unity.Map.TileProviders.AbstractTileProvider.Initialize (Mapbox.Unity.Map.Interfaces.IMap map) (at Assets/Mapbox/Unity/Map/TileProviders/AbstractTileProvider.cs:34)
Mapbox.Unity.Map.AbstractMap.OnTileProviderChanged () (at Assets/Mapbox/Unity/Map/AbstractMap.cs:1013)
Mapbox.Unity.Map.AbstractMap.SetExtent (Mapbox.Unity.Map.MapExtentType extentType, Mapbox.Unity.Map.ExtentOptions extentOptions) (at Assets/Mapbox/Unity/Map/AbstractMap.cs:1166)

image

Here's the code I'm trying:

CameraBoundsTileProviderOptions options = new CameraBoundsTileProviderOptions();
options.camera = mapCamera;
mapManager.SetExtent(MapExtentType.CameraBounds, options);

It seems like the camera that's passed in is reset to null inside OnTileProviderChanged (or the options are reset to the default).

  • Unity version: 2021.3.19f1
    • Scripting Runtime Version:
    • Scripting Backend: Mono
    • Api Compatibility Level: .NET Standard 2.1
  • Mapbox SDK version: 2.1.1
  • The platform you're building to: Windows/Android/iOS (this issue is on Windows in the editor)
@smahalgavaiya
Copy link

smahalgavaiya commented Jul 9, 2023

Hi if you want to change the camera only in runtime simply use
CameraBoundsTileProviderOptions cameraBoundsOptions =
abstractMap.Options.extentOptions.defaultExtents.cameraBoundsOptions;
cameraBoundsOptions.camera = mapCamera;
image
Also check the CameraBoundsTileProviderOptions script it has public Camera camera;
public int visibleBuffer;
public int disposeBuffer; variables

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

No branches or pull requests

2 participants