Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Maps] remove MapBounds type (#62332) #62349

Merged
merged 1 commit into from
Apr 2, 2020
Merged
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
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