Skip to content

Commit

Permalink
[Maps] remove MapBounds type (#62332)
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese authored Apr 2, 2020
1 parent 9a6c17d commit e202fe7
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion x-pack/legacy/plugins/maps/public/layers/layer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions x-pack/legacy/plugins/maps/public/layers/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
8 changes: 4 additions & 4 deletions x-pack/legacy/plugins/maps/public/layers/sources/es_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -18,6 +22,7 @@ export type GeoJsonWithMeta = {
};

export interface IVectorSource extends ISource {
getBoundsForFilters(searchFilters: VectorSourceRequestMeta): MapExtent;
getGeoJsonWithMeta(
layerName: 'string',
searchFilters: unknown[],
Expand All @@ -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[],
Expand Down
8 changes: 4 additions & 4 deletions x-pack/legacy/plugins/maps/public/layers/vector_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
};
}

Expand Down
10 changes: 1 addition & 9 deletions x-pack/plugins/maps/common/descriptor_types/map_descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit e202fe7

Please sign in to comment.