[Maps] remove MapBounds type (#62332)

This commit is contained in:
Nathan Reese 2020-04-02 11:04:06 -06:00 committed by GitHub
parent 9a6c17d3da
commit e202fe7aa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 28 deletions

View file

@ -235,12 +235,12 @@ export class MBMapContainer extends React.Component {
//clamping ot -89/89 latitudes since Mapboxgl does not seem to handle bounds that contain the poles (logs errors to the console when using -90/90)
const lnLatBounds = new mapboxgl.LngLatBounds(
new mapboxgl.LngLat(
clampToLonBounds(goto.bounds.min_lon),
clampToLatBounds(goto.bounds.min_lat)
clampToLonBounds(goto.bounds.minLon),
clampToLatBounds(goto.bounds.minLat)
),
new mapboxgl.LngLat(
clampToLonBounds(goto.bounds.max_lon),
clampToLatBounds(goto.bounds.max_lat)
clampToLonBounds(goto.bounds.maxLon),
clampToLatBounds(goto.bounds.maxLat)
)
);
//maxZoom ensure we're not zooming in too far on single points or small shapes

View file

@ -3,12 +3,13 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { LayerDescriptor } from '../../common/descriptor_types';
import { LayerDescriptor, MapExtent, MapFilters } from '../../common/descriptor_types';
import { ISource } from './sources/source';
import { DataRequest } from './util/data_request';
import { SyncContext } from '../actions/map_actions';
export interface ILayer {
getBounds(mapFilters: MapFilters): Promise<MapExtent>;
getDataRequest(id: string): DataRequest | undefined;
getDisplayName(source?: ISource): Promise<string>;
getId(): string;
@ -25,6 +26,7 @@ export interface ILayerArguments {
export class AbstractLayer implements ILayer {
constructor(layerArguments: ILayerArguments);
getBounds(mapFilters: MapFilters): Promise<MapExtent>;
getDataRequest(id: string): DataRequest | undefined;
getDisplayName(source?: ISource): Promise<string>;
getId(): string;

View file

@ -320,12 +320,12 @@ export class AbstractLayer {
return sourceDataRequest && sourceDataRequest.hasData();
}
async getBounds() {
async getBounds(/* mapFilters: MapFilters */) {
return {
min_lon: -180,
max_lon: 180,
min_lat: -89,
max_lat: 89,
minLon: -180,
maxLon: 180,
minLat: -89,
maxLat: 89,
};
}

View file

@ -175,10 +175,10 @@ export class AbstractESSource extends AbstractVectorSource {
}
return {
min_lon: esBounds.top_left.lon,
max_lon: esBounds.bottom_right.lon,
min_lat: esBounds.bottom_right.lat,
max_lat: esBounds.top_left.lat,
minLon: esBounds.top_left.lon,
maxLon: esBounds.bottom_right.lon,
minLat: esBounds.bottom_right.lat,
maxLat: esBounds.top_left.lat,
};
}

View file

@ -8,7 +8,11 @@
import { FeatureCollection } from 'geojson';
import { AbstractSource, ISource } from './source';
import { IField } from '../fields/field';
import { ESSearchSourceResponseMeta } from '../../../common/descriptor_types';
import {
ESSearchSourceResponseMeta,
MapExtent,
VectorSourceRequestMeta,
} from '../../../common/descriptor_types';
export type GeoJsonFetchMeta = ESSearchSourceResponseMeta;
@ -18,6 +22,7 @@ export type GeoJsonWithMeta = {
};
export interface IVectorSource extends ISource {
getBoundsForFilters(searchFilters: VectorSourceRequestMeta): MapExtent;
getGeoJsonWithMeta(
layerName: 'string',
searchFilters: unknown[],
@ -29,6 +34,7 @@ export interface IVectorSource extends ISource {
}
export class AbstractVectorSource extends AbstractSource implements IVectorSource {
getBoundsForFilters(searchFilters: VectorSourceRequestMeta): MapExtent;
getGeoJsonWithMeta(
layerName: 'string',
searchFilters: unknown[],

View file

@ -167,10 +167,10 @@ export class VectorLayer extends AbstractLayer {
features: visibleFeatures,
});
return {
min_lon: bbox[0],
min_lat: bbox[1],
max_lon: bbox[2],
max_lat: bbox[3],
minLon: bbox[0],
minLat: bbox[1],
maxLon: bbox[2],
maxLat: bbox[3],
};
}

View file

@ -33,16 +33,8 @@ export type MapCenterAndZoom = MapCenter & {
zoom: number;
};
// TODO replace with map_descriptors.MapExtent. Both define the same thing but with different casing
type MapBounds = {
min_lon: number;
max_lon: number;
min_lat: number;
max_lat: number;
};
export type Goto = {
bounds?: MapBounds;
bounds?: MapExtent;
center?: MapCenterAndZoom;
};