* _map3dmoved * Respond to changes in the 3d map, for example if the user interacts with it. * Update zoom and bearing offsets from main map, and recenter the main map if needed.
()
| 358 | * Update zoom and bearing offsets from main map, and recenter the main map if needed. |
| 359 | */ |
| 360 | _map3dmoved() { |
| 361 | const context = this.context; |
| 362 | const maplibre = this.maplibre; |
| 363 | const map = context.systems.map; |
| 364 | const viewport = context.viewport; |
| 365 | const transform = viewport.transform; |
| 366 | |
| 367 | if (!maplibre) return; // called too early? |
| 368 | if (!this._lastv) return; // haven't positioned the map yet (it may be at null island), Rapid#1441 |
| 369 | |
| 370 | const mlCenter = maplibre.getCenter(); |
| 371 | const mlCenterLoc = [mlCenter.lng, mlCenter.lat]; |
| 372 | const mlZoom = maplibre.getZoom(); |
| 373 | const mlBearing = maplibre.getBearing(); |
| 374 | |
| 375 | const mainCenterLoc = viewport.centerLoc(); |
| 376 | const mainZoom = transform.zoom; |
| 377 | // Why a '-' here? Because "bearing" is the angle that the user points, not the angle that north points. |
| 378 | const mainBearing = numWrap(-transform.rotation * RAD2DEG, 0, 360); |
| 379 | |
| 380 | this._zDiff = mainZoom - mlZoom; |
| 381 | this._bDiff = mainBearing - mlBearing; |
| 382 | |
| 383 | // Recenter main map, if 3dmap center moved |
| 384 | if (!vecEqual(mainCenterLoc, mlCenterLoc, 1e-6)) { |
| 385 | map.center(mlCenterLoc); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | |
| 390 | /** |