Geomap: fix esri server config (#37283)

This commit is contained in:
Ryan McKinley 2021-07-27 22:26:42 -07:00 committed by GitHub
parent ee51df3715
commit 5f41c2f334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -102,5 +102,5 @@ export interface MapLayerRegistryItem<TConfig = MapLayerOptions> extends Registr
/**
* Show custom elements in the panel edit UI
*/
registerOptionsUI?: (builder: PanelOptionsEditorBuilder<TConfig>) => void;
registerOptionsUI?: (builder: PanelOptionsEditorBuilder<MapLayerOptions<TConfig>>) => void;
}

View File

@ -41,7 +41,7 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
return null;
}
const builder = new PanelOptionsEditorBuilder();
const builder = new PanelOptionsEditorBuilder<MapLayerOptions>();
if (layer.showLocation) {
builder
.addRadio({
@ -65,7 +65,7 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
filter: (f: Field) => f.type === FieldType.number,
noFieldsMessage: 'No numeric fields found',
},
showIf: (opts: MapLayerOptions) => opts.location?.mode === FrameGeometrySourceMode.Coords,
showIf: (opts) => opts.location?.mode === FrameGeometrySourceMode.Coords,
})
.addFieldNamePicker({
path: 'location.longitude',
@ -74,7 +74,7 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
filter: (f: Field) => f.type === FieldType.number,
noFieldsMessage: 'No numeric fields found',
},
showIf: (opts: MapLayerOptions) => opts.location?.mode === FrameGeometrySourceMode.Coords,
showIf: (opts) => opts.location?.mode === FrameGeometrySourceMode.Coords,
})
.addFieldNamePicker({
path: 'location.geohash',
@ -83,7 +83,7 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
filter: (f: Field) => f.type === FieldType.string,
noFieldsMessage: 'No strings fields found',
},
showIf: (opts: MapLayerOptions) => opts.location?.mode === FrameGeometrySourceMode.Geohash,
showIf: (opts) => opts.location?.mode === FrameGeometrySourceMode.Geohash,
// eslint-disable-next-line react/display-name
// info: (props) => <div>HELLO</div>,
})
@ -94,14 +94,14 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
filter: (f: Field) => f.type === FieldType.string,
noFieldsMessage: 'No strings fields found',
},
showIf: (opts: MapLayerOptions) => opts.location?.mode === FrameGeometrySourceMode.Lookup,
showIf: (opts) => opts.location?.mode === FrameGeometrySourceMode.Lookup,
})
.addCustomEditor({
id: 'gazetteer',
path: 'location.gazetteer',
name: 'Gazetteer',
editor: GazetteerPathEditor,
showIf: (opts: MapLayerOptions) => opts.location?.mode === FrameGeometrySourceMode.Lookup,
showIf: (opts) => opts.location?.mode === FrameGeometrySourceMode.Lookup,
});
}
if (layer.registerOptionsUI) {

View File

@ -49,9 +49,7 @@ export const publicServiceRegistry = new Registry<PublicServiceItem>(() => [
]);
export interface ESRIXYZConfig extends XYZConfig {
config: {
server: string;
};
server: string;
}
export const esriXYZTiles: MapLayerRegistryItem<ESRIXYZConfig> = {
@ -61,7 +59,7 @@ export const esriXYZTiles: MapLayerRegistryItem<ESRIXYZConfig> = {
create: async (map: Map, options: MapLayerOptions<ESRIXYZConfig>, theme: GrafanaTheme2) => {
const cfg = { ...options.config };
const svc = publicServiceRegistry.getIfExists(cfg.config?.server ?? DEFAULT_SERVICE)!;
const svc = publicServiceRegistry.getIfExists(cfg.server ?? DEFAULT_SERVICE)!;
if (svc.id !== CUSTOM_SERVICE) {
const base = 'https://services.arcgisonline.com/ArcGIS/rest/services/';
cfg.url = `${base}${svc.slug}/MapServer/tile/{z}/{y}/{x}`;