Skip to content

Commit e202fe7

Browse files
authored
[Maps] remove MapBounds type (#62332)
1 parent 9a6c17d commit e202fe7

7 files changed

Lines changed: 28 additions & 28 deletions

File tree

x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ export class MBMapContainer extends React.Component {
235235
//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)
236236
const lnLatBounds = new mapboxgl.LngLatBounds(
237237
new mapboxgl.LngLat(
238-
clampToLonBounds(goto.bounds.min_lon),
239-
clampToLatBounds(goto.bounds.min_lat)
238+
clampToLonBounds(goto.bounds.minLon),
239+
clampToLatBounds(goto.bounds.minLat)
240240
),
241241
new mapboxgl.LngLat(
242-
clampToLonBounds(goto.bounds.max_lon),
243-
clampToLatBounds(goto.bounds.max_lat)
242+
clampToLonBounds(goto.bounds.maxLon),
243+
clampToLatBounds(goto.bounds.maxLat)
244244
)
245245
);
246246
//maxZoom ensure we're not zooming in too far on single points or small shapes

x-pack/legacy/plugins/maps/public/layers/layer.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
import { LayerDescriptor } from '../../common/descriptor_types';
6+
import { LayerDescriptor, MapExtent, MapFilters } from '../../common/descriptor_types';
77
import { ISource } from './sources/source';
88
import { DataRequest } from './util/data_request';
99
import { SyncContext } from '../actions/map_actions';
1010

1111
export interface ILayer {
12+
getBounds(mapFilters: MapFilters): Promise<MapExtent>;
1213
getDataRequest(id: string): DataRequest | undefined;
1314
getDisplayName(source?: ISource): Promise<string>;
1415
getId(): string;
@@ -25,6 +26,7 @@ export interface ILayerArguments {
2526

2627
export class AbstractLayer implements ILayer {
2728
constructor(layerArguments: ILayerArguments);
29+
getBounds(mapFilters: MapFilters): Promise<MapExtent>;
2830
getDataRequest(id: string): DataRequest | undefined;
2931
getDisplayName(source?: ISource): Promise<string>;
3032
getId(): string;

x-pack/legacy/plugins/maps/public/layers/layer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,12 @@ export class AbstractLayer {
320320
return sourceDataRequest && sourceDataRequest.hasData();
321321
}
322322

323-
async getBounds() {
323+
async getBounds(/* mapFilters: MapFilters */) {
324324
return {
325-
min_lon: -180,
326-
max_lon: 180,
327-
min_lat: -89,
328-
max_lat: 89,
325+
minLon: -180,
326+
maxLon: 180,
327+
minLat: -89,
328+
maxLat: 89,
329329
};
330330
}
331331

x-pack/legacy/plugins/maps/public/layers/sources/es_source.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ export class AbstractESSource extends AbstractVectorSource {
175175
}
176176

177177
return {
178-
min_lon: esBounds.top_left.lon,
179-
max_lon: esBounds.bottom_right.lon,
180-
min_lat: esBounds.bottom_right.lat,
181-
max_lat: esBounds.top_left.lat,
178+
minLon: esBounds.top_left.lon,
179+
maxLon: esBounds.bottom_right.lon,
180+
minLat: esBounds.bottom_right.lat,
181+
maxLat: esBounds.top_left.lat,
182182
};
183183
}
184184

x-pack/legacy/plugins/maps/public/layers/sources/vector_source.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import { FeatureCollection } from 'geojson';
99
import { AbstractSource, ISource } from './source';
1010
import { IField } from '../fields/field';
11-
import { ESSearchSourceResponseMeta } from '../../../common/descriptor_types';
11+
import {
12+
ESSearchSourceResponseMeta,
13+
MapExtent,
14+
VectorSourceRequestMeta,
15+
} from '../../../common/descriptor_types';
1216

1317
export type GeoJsonFetchMeta = ESSearchSourceResponseMeta;
1418

@@ -18,6 +22,7 @@ export type GeoJsonWithMeta = {
1822
};
1923

2024
export interface IVectorSource extends ISource {
25+
getBoundsForFilters(searchFilters: VectorSourceRequestMeta): MapExtent;
2126
getGeoJsonWithMeta(
2227
layerName: 'string',
2328
searchFilters: unknown[],
@@ -29,6 +34,7 @@ export interface IVectorSource extends ISource {
2934
}
3035

3136
export class AbstractVectorSource extends AbstractSource implements IVectorSource {
37+
getBoundsForFilters(searchFilters: VectorSourceRequestMeta): MapExtent;
3238
getGeoJsonWithMeta(
3339
layerName: 'string',
3440
searchFilters: unknown[],

x-pack/legacy/plugins/maps/public/layers/vector_layer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ export class VectorLayer extends AbstractLayer {
167167
features: visibleFeatures,
168168
});
169169
return {
170-
min_lon: bbox[0],
171-
min_lat: bbox[1],
172-
max_lon: bbox[2],
173-
max_lat: bbox[3],
170+
minLon: bbox[0],
171+
minLat: bbox[1],
172+
maxLon: bbox[2],
173+
maxLat: bbox[3],
174174
};
175175
}
176176

x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,8 @@ export type MapCenterAndZoom = MapCenter & {
3333
zoom: number;
3434
};
3535

36-
// TODO replace with map_descriptors.MapExtent. Both define the same thing but with different casing
37-
type MapBounds = {
38-
min_lon: number;
39-
max_lon: number;
40-
min_lat: number;
41-
max_lat: number;
42-
};
43-
4436
export type Goto = {
45-
bounds?: MapBounds;
37+
bounds?: MapExtent;
4638
center?: MapCenterAndZoom;
4739
};
4840

0 commit comments

Comments
 (0)