Skip to content

Commit

Permalink
fix: fixed issue with easeTo input
Browse files Browse the repository at this point in the history
- fixed issue where null/undefined was being passed for zoom values to the final easeTo() function and causing errors
  • Loading branch information
dereekb committed Sep 8, 2022
1 parent a49e72c commit eb03604
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/dbx-web/mapbox/src/lib/mapbox.store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cleanup, filterMaybe, onTrueToFalse } from '@dereekb/rxjs';
import { Inject, Injectable, OnDestroy } from '@angular/core';
import { isSameLatLngBound, isSameLatLngPoint, IsWithinLatLngBoundFunction, isWithinLatLngBoundFunction, LatLngBound, latLngBoundFunction, LatLngPointInput, LatLngPoint, latLngPointFunction, Maybe, OverlapsLatLngBoundFunction, overlapsLatLngBoundFunction, diffLatLngBoundPoints, latLngBoundCenterPoint, addLatLngPoints, isDefaultLatLngPoint, swMostLatLngPoint, neMostLatLngPoint, latLngBoundWrapsMap, Vector, vectorsAreEqual } from '@dereekb/util';
import { isSameLatLngBound, isSameLatLngPoint, IsWithinLatLngBoundFunction, isWithinLatLngBoundFunction, LatLngBound, latLngBoundFunction, LatLngPointInput, LatLngPoint, latLngPointFunction, Maybe, OverlapsLatLngBoundFunction, overlapsLatLngBoundFunction, diffLatLngBoundPoints, latLngBoundCenterPoint, addLatLngPoints, isDefaultLatLngPoint, swMostLatLngPoint, neMostLatLngPoint, latLngBoundWrapsMap, Vector, vectorsAreEqual, filterUndefinedValues } from '@dereekb/util';
import { ComponentStore } from '@ngrx/component-store';
import { MapService } from 'ngx-mapbox-gl';
import { defaultIfEmpty, distinctUntilChanged, filter, map, shareReplay, switchMap, tap, NEVER, Observable, of, Subscription, startWith, interval, first, combineLatest } from 'rxjs';
Expand Down Expand Up @@ -81,7 +81,7 @@ export interface DbxMapboxStoreState {
*/
@Injectable()
export class DbxMapboxMapStore extends ComponentStore<DbxMapboxStoreState> implements OnDestroy {
private safeLatLngPoint = latLngPointFunction();
private safeLatLngPoint = latLngPointFunction({ wrap: true });
private latLngPoint = latLngPointFunction({ wrap: false, validate: false });
private latLngBound = latLngBoundFunction({ pointFunction: this.latLngPoint });

Expand Down Expand Up @@ -211,8 +211,8 @@ export class DbxMapboxMapStore extends ComponentStore<DbxMapboxStoreState> imple
switchMap((zoomRange: Partial<MapboxZoomLevelRange>) => {
return this.mapInstance$.pipe(
tap((map) => {
map.setMinZoom(zoomRange.min);
map.setMaxZoom(zoomRange.max);
map.setMinZoom(zoomRange.min || null);
map.setMaxZoom(zoomRange.max || null);
})
);
})
Expand Down Expand Up @@ -380,7 +380,7 @@ export class DbxMapboxMapStore extends ComponentStore<DbxMapboxStoreState> imple
switchMap((x) => {
const inputCenter = x.center ?? x.to?.center;
const center = inputCenter ? this.safeLatLngPoint(inputCenter) : undefined;
return this.mapInstance$.pipe(tap((map) => map.jumpTo({ ...x.to, center }, x.eventData)));
return this.mapInstance$.pipe(tap((map) => map.jumpTo(filterUndefinedValues({ ...x.to, center }), x.eventData)));
})
);
});
Expand All @@ -390,7 +390,7 @@ export class DbxMapboxMapStore extends ComponentStore<DbxMapboxStoreState> imple
switchMap((x) => {
const inputCenter = x.center ?? x.to?.center;
const center = inputCenter ? this.safeLatLngPoint(inputCenter) : undefined;
return this.mapInstance$.pipe(tap((map) => map.easeTo({ ...x.to, center }, x.eventData)));
return this.mapInstance$.pipe(tap((map) => map.easeTo(filterUndefinedValues({ ...x.to, center }), x.eventData)));
})
);
});
Expand All @@ -400,7 +400,7 @@ export class DbxMapboxMapStore extends ComponentStore<DbxMapboxStoreState> imple
switchMap((x) => {
const inputCenter = x.center ?? x.to?.center;
const center = inputCenter ? this.safeLatLngPoint(inputCenter) : undefined;
return this.mapInstance$.pipe(tap((map) => map.flyTo({ ...x.to, center }, x.eventData)));
return this.mapInstance$.pipe(tap((map) => map.flyTo(filterUndefinedValues({ ...x.to, center }), x.eventData)));
})
);
});
Expand Down

0 comments on commit eb03604

Please sign in to comment.