From c78286eba407b955a49ae98e6864fdae50059c29 Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 2 Apr 2020 11:04:06 -0600 Subject: [PATCH] [Maps] remove MapBounds type (#62332) --- .../maps/public/connected_components/map/mb/view.js | 8 ++++---- x-pack/legacy/plugins/maps/public/layers/layer.d.ts | 4 +++- x-pack/legacy/plugins/maps/public/layers/layer.js | 10 +++++----- .../plugins/maps/public/layers/sources/es_source.js | 8 ++++---- .../maps/public/layers/sources/vector_source.d.ts | 8 +++++++- .../legacy/plugins/maps/public/layers/vector_layer.js | 8 ++++---- .../maps/common/descriptor_types/map_descriptor.ts | 10 +--------- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js b/x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js index fdc8ad2176d08..2995ea039e7a8 100644 --- a/x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js +++ b/x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js @@ -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 diff --git a/x-pack/legacy/plugins/maps/public/layers/layer.d.ts b/x-pack/legacy/plugins/maps/public/layers/layer.d.ts index 777566298e607..de59642ede8ab 100644 --- a/x-pack/legacy/plugins/maps/public/layers/layer.d.ts +++ b/x-pack/legacy/plugins/maps/public/layers/layer.d.ts @@ -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; getDataRequest(id: string): DataRequest | undefined; getDisplayName(source?: ISource): Promise; getId(): string; @@ -25,6 +26,7 @@ export interface ILayerArguments { export class AbstractLayer implements ILayer { constructor(layerArguments: ILayerArguments); + getBounds(mapFilters: MapFilters): Promise; getDataRequest(id: string): DataRequest | undefined; getDisplayName(source?: ISource): Promise; getId(): string; diff --git a/x-pack/legacy/plugins/maps/public/layers/layer.js b/x-pack/legacy/plugins/maps/public/layers/layer.js index d162e342dfd1a..e9616be89b601 100644 --- a/x-pack/legacy/plugins/maps/public/layers/layer.js +++ b/x-pack/legacy/plugins/maps/public/layers/layer.js @@ -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, }; } diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js index bf04a73cfba77..441d52d23398a 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_source.js @@ -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, }; } diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts b/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts index 7a747da244233..1400654297e01 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts +++ b/x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts @@ -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[], diff --git a/x-pack/legacy/plugins/maps/public/layers/vector_layer.js b/x-pack/legacy/plugins/maps/public/layers/vector_layer.js index 6b89554546330..d606420909281 100644 --- a/x-pack/legacy/plugins/maps/public/layers/vector_layer.js +++ b/x-pack/legacy/plugins/maps/public/layers/vector_layer.js @@ -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], }; } diff --git a/x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts b/x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts index b2a4c6b85a856..798b5f335dda2 100644 --- a/x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts +++ b/x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts @@ -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; };