Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
plugins
/
panel
/
geomap
/
layers
/
basemaps
/
File Content:
generic.ts
import Map from 'ol/Map'; import TileLayer from 'ol/layer/Tile'; import XYZ from 'ol/source/XYZ'; import { MapLayerRegistryItem, MapLayerOptions, GrafanaTheme2, EventBus } from '@grafana/data'; export interface XYZConfig { url: string; attribution: string; minZoom?: number; maxZoom?: number; } const sampleURL = 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer'; export const defaultXYZConfig: XYZConfig = { url: sampleURL + '/tile/{z}/{y}/{x}', attribution: `Tiles © <a href="${sampleURL}">ArcGIS</a>`, }; export const xyzTiles: MapLayerRegistryItem<XYZConfig> = { id: 'xyz', name: 'XYZ Tile layer', description: 'Add map from a generic tile layer', isBaseMap: true, create: async (map: Map, options: MapLayerOptions<XYZConfig>, eventBus: EventBus, theme: GrafanaTheme2) => ({ init: () => { const cfg = { ...options.config }; if (!cfg.url) { cfg.url = defaultXYZConfig.url; cfg.attribution = cfg.attribution ?? defaultXYZConfig.attribution; } return new TileLayer({ source: new XYZ({ url: cfg.url, attributions: cfg.attribution, // singular? }), minZoom: cfg.minZoom, maxZoom: cfg.maxZoom, }); }, registerOptionsUI: (builder) => { builder .addTextInput({ path: 'config.url', name: 'URL template', description: 'Must include {x}, {y} or {-y}, and {z} placeholders', settings: { placeholder: defaultXYZConfig.url, }, }) .addTextInput({ path: 'config.attribution', name: 'Attribution', settings: { placeholder: defaultXYZConfig.attribution, }, }); }, }), }; export const genericLayers = [xyzTiles];
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
carto.ts
2238 bytes
0644
esri.ts
3046 bytes
0644
generic.ts
1827 bytes
0644
index.ts
318 bytes
0644
osm.ts
696 bytes
0644
N4ST4R_ID | Naxtarrr