mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Fix custom raster developer example (#142664)
This commit is contained in:
parent
7f3541c8ba
commit
fc8407d222
4 changed files with 32 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { ReactElement } from 'react';
|
||||
import { calculateBounds } from '@kbn/data-plugin/common';
|
||||
import { FieldFormatter, MIN_ZOOM, MAX_ZOOM } from '@kbn/maps-plugin/common';
|
||||
|
@ -16,15 +17,18 @@ import type {
|
|||
Timeslice,
|
||||
} from '@kbn/maps-plugin/common/descriptor_types';
|
||||
import type {
|
||||
DataRequest,
|
||||
IField,
|
||||
ImmutableSourceProperty,
|
||||
ITMSSource,
|
||||
IRasterSource,
|
||||
SourceEditorArgs,
|
||||
} from '@kbn/maps-plugin/public';
|
||||
import { RasterTileSourceData } from '@kbn/maps-plugin/public/classes/sources/raster_source';
|
||||
import { RasterTileSource } from 'maplibre-gl';
|
||||
|
||||
type CustomRasterSourceDescriptor = AbstractSourceDescriptor;
|
||||
|
||||
export class CustomRasterSource implements ITMSSource {
|
||||
export class CustomRasterSource implements IRasterSource {
|
||||
static type = 'CUSTOM_RASTER';
|
||||
|
||||
readonly _descriptor: CustomRasterSourceDescriptor;
|
||||
|
@ -39,6 +43,25 @@ export class CustomRasterSource implements ITMSSource {
|
|||
this._descriptor = sourceDescriptor;
|
||||
}
|
||||
|
||||
async canSkipSourceUpdate(
|
||||
dataRequest: DataRequest,
|
||||
nextRequestMeta: DataRequestMeta
|
||||
): Promise<boolean> {
|
||||
const prevMeta = dataRequest.getMeta();
|
||||
if (!prevMeta) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
return Promise.resolve(_.isEqual(prevMeta.timeslice, nextRequestMeta.timeslice));
|
||||
}
|
||||
|
||||
isSourceStale(mbSource: RasterTileSource, sourceData: RasterTileSourceData): boolean {
|
||||
if (!sourceData.url) {
|
||||
return false;
|
||||
}
|
||||
return mbSource.tiles?.[0] !== sourceData.url;
|
||||
}
|
||||
|
||||
cloneDescriptor(): CustomRasterSourceDescriptor {
|
||||
return {
|
||||
type: this._descriptor.type,
|
||||
|
|
|
@ -41,15 +41,18 @@ export class KibanaTilemapSource extends AbstractSource {
|
|||
},
|
||||
];
|
||||
}
|
||||
|
||||
isSourceStale(mbSource, sourceData) {
|
||||
if (!sourceData.url) {
|
||||
return false;
|
||||
}
|
||||
return mbSource.tiles?.[0] !== sourceData.url;
|
||||
}
|
||||
|
||||
async canSkipSourceUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
async getUrlTemplate() {
|
||||
const tilemap = getKibanaTileMap();
|
||||
if (!tilemap.url) {
|
||||
|
|
|
@ -27,15 +27,18 @@ export class WMSSource extends AbstractSource {
|
|||
styles,
|
||||
};
|
||||
}
|
||||
|
||||
isSourceStale(mbSource, sourceData) {
|
||||
if (!sourceData.url) {
|
||||
return false;
|
||||
}
|
||||
return mbSource.tiles?.[0] !== sourceData.url;
|
||||
}
|
||||
|
||||
async canSkipSourceUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
async getImmutableProperties() {
|
||||
return [
|
||||
{ label: getDataSourceLabel(), value: sourceTitle },
|
||||
|
|
|
@ -35,6 +35,7 @@ export type { MapEmbeddable, MapEmbeddableInput, MapEmbeddableOutput } from './e
|
|||
export type { EMSTermJoinConfig, SampleValuesConfig } from './ems_autosuggest';
|
||||
|
||||
export type { ITMSSource } from './classes/sources/tms_source';
|
||||
export type { IRasterSource } from './classes/sources/raster_source';
|
||||
|
||||
export type {
|
||||
GetFeatureActionsArgs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue