Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/geo/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import LngLat from './lng_lat';
import LngLatBounds from './lng_lat_bounds';
import MercatorCoordinate, {mercatorXfromLng, mercatorYfromLat, mercatorZfromAltitude} from './mercator_coordinate';
import Point from '@mapbox/point-geometry';
import {wrap, clamp} from '../util/util';
import {deepEqual, wrap, clamp} from '../util/util';
import {number as interpolate} from '../style-spec/util/interpolate';
import EXTENT from '../data/extent';
import {vec4, mat4, mat2, vec2} from 'gl-matrix';
Expand Down Expand Up @@ -565,16 +565,24 @@ class Transform {
/**
* Sets or clears the map's geographical constraints.
* @param {LngLatBounds} bounds A {@link LngLatBounds} object describing the new geographic boundaries of the map.
* @returns {boolean} true if any changes were made; false otherwise
*/
setMaxBounds(bounds?: LngLatBounds) {
setMaxBounds(bounds?: LngLatBounds): boolean {
const lngRange = bounds ? [bounds.getWest(), bounds.getEast()] : null;
const latRange = bounds ? [bounds.getSouth(), bounds.getNorth()] : [-this.maxValidLatitude, this.maxValidLatitude];

if (deepEqual(this.lngRange, lngRange) && deepEqual(this.latRange, latRange)) {
return false;
}

this.lngRange = lngRange;
this.latRange = latRange;

if (bounds) {
this.lngRange = [bounds.getWest(), bounds.getEast()];
this.latRange = [bounds.getSouth(), bounds.getNorth()];
this._constrain();
} else {
this.lngRange = null;
this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];
}

return true;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,12 @@ class SourceCache extends Evented {

/**
* Resets the value of a particular state key for a feature
* @returns {boolean} true if any changes were made; false otherwise
* @private
*/
removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string) {
removeFeatureState(sourceLayer?: string, featureId?: number | string, key?: string): boolean {
sourceLayer = sourceLayer || '_geojsonTileLayer';
this._state.removeFeatureState(sourceLayer, featureId, key);
return this._state.removeFeatureState(sourceLayer, featureId, key);
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/source/source_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ class SourceFeatureState {
}
}
}

}

removeFeatureState(sourceLayer: string, featureId?: number | string, key?: string) {
/**
* @returns {boolean} true if any changes were made; false otherwise
*/
removeFeatureState(sourceLayer: string, featureId?: number | string, key?: string): boolean {
const sourceLayerDeleted = this.deletedStates[sourceLayer] === null;
if (sourceLayerDeleted) return;
if (sourceLayerDeleted) return false;

const feature = String(featureId);

Expand All @@ -80,6 +84,7 @@ class SourceFeatureState {
this.deletedStates[sourceLayer] = null;
}

return true;
}

getState(sourceLayer: string, featureId: number | string) {
Expand Down
Loading