Geomap: include sample geojson files (#39057)

This commit is contained in:
Ryan McKinley
2021-09-10 09:05:03 -07:00
committed by GitHub
parent 0bb7d50ad6
commit ddd110d0b2
10 changed files with 376 additions and 24 deletions

View File

@@ -16,7 +16,7 @@ export interface GeoJSONMapperConfig {
}
const defaultOptions: GeoJSONMapperConfig = {
src: 'https://openlayers.org/en/latest/examples/data/geojson/countries.geojson',
src: 'public/maps/countries.geojson',
};
export const geojsonMapper: MapLayerRegistryItem<GeoJSONMapperConfig> = {
@@ -55,6 +55,22 @@ export const geojsonMapper: MapLayerRegistryItem<GeoJSONMapperConfig> = {
};
},
// Geojson source url
registerOptionsUI: (builder) => {
builder.addSelect({
path: 'config.src',
name: 'GeoJSON URL',
settings: {
options: [
{ label: 'public/maps/countries.geojson', value: 'public/maps/countries.geojson' },
{ label: 'public/maps/usa-states.geojson', value: 'public/maps/usa-states.geojson' },
],
allowCustomValue: true,
},
defaultValue: defaultOptions.src,
});
},
// fill in the default values
defaultOptions,
};

View File

@@ -8,6 +8,7 @@ import {
} from '@grafana/data';
import Map from 'ol/Map';
import Feature from 'ol/Feature';
import { Point } from 'ol/geom';
import * as layer from 'ol/layer';
import * as source from 'ol/source';
@@ -97,7 +98,7 @@ export const markersLayer: MapLayerRegistryItem<MarkersConfig> = {
return; // ignore empty
}
const features: Feature[] = [];
const features: Feature<Point>[] = [];
for (const frame of data.series) {
const info = dataFrameToPoints(frame, matchers);