maplibre / maplibre-rs

Experimental Maps for Web, Mobile and Desktop
Apache License 2.0
1.36k stars 79 forks source link

Limit the maximum and minimum zoom level #161

Open hanchao opened 2 years ago

hanchao commented 2 years ago

Keep zooming in or zooming out, demo will crash.

🤔 Expected Behavior

Need to limit maximum and minimum zoom level

😯 Current Behavior

Keep zooming in until crashed

[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 30.42
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 30.52
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 30.71
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 30.96
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 31.21
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 31.36
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 31.53
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 31.85
[2022-07-18T12:36:49Z INFO  maplibre::context] zoom: 32.16
thread 'main' panicked at 'attempt to add with overflow', maplibre/src/coords.rs:584:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2022-07-18T12:36:49Z INFO  wgpu_core::hub] Dropping Global
[2022-07-18T12:36:49Z INFO  wgpu_core::device] Destroying 12 command encoders

Keep zooming out until crashed

[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -30.15
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -30.41
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -30.66
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -30.9
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -31.13
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -31.35
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -31.56
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -31.76
[2022-07-18T12:35:05Z INFO  maplibre::context] zoom: -31.95
thread 'main' panicked at 'attempt to add with overflow', maplibre/src/coords.rs:584:42
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2022-07-18T12:35:05Z INFO  wgpu_core::hub] Dropping Global
[2022-07-18T12:35:05Z INFO  wgpu_core::device] Destroying 5 command encoders

🌍 Your Environment

DerKarlos commented 2 years ago

Oops, I started with this and commented in the wrong Issue #73

maxammann commented 2 years ago

Alright no worries!

maxammann commented 1 year ago

We should also directly address the overflows. E.g. returning errors/options when we would hit the overflows.