diff --git a/public/app/features/geo/editor/locationEditor.ts b/public/app/features/geo/editor/locationEditor.ts index d8b6e7e1e02..d8a5cc8fcab 100644 --- a/public/app/features/geo/editor/locationEditor.ts +++ b/public/app/features/geo/editor/locationEditor.ts @@ -51,7 +51,7 @@ export function addLocationFields( case FrameGeometrySourceMode.Geohash: builder.addFieldNamePicker({ - path: `${prefix}.geohash`, + path: `${prefix}geohash`, name: 'Geohash field', settings: { filter: (f: Field) => f.type === FieldType.string, diff --git a/public/app/features/geo/utils/location.test.ts b/public/app/features/geo/utils/location.test.ts index d816361d477..b6f47000035 100644 --- a/public/app/features/geo/utils/location.test.ts +++ b/public/app/features/geo/utils/location.test.ts @@ -67,4 +67,31 @@ describe('handle location parsing', () => { ] `); }); + + it('auto support geohash fields', async () => { + const frame = toDataFrame({ + name: 'simple', + fields: [ + { name: 'name', type: FieldType.string, values: names }, + { name: 'geohash', type: FieldType.string, values: ['9q94r', 'dr5rs'] }, + ], + }); + + const matchers = await getLocationMatchers({ + mode: FrameGeometrySourceMode.Geohash, + }); + const geo = getGeometryField(frame, matchers).field!; + expect(geo.values.toArray().map((p) => toLonLat((p as Point).getCoordinates()))).toMatchInlineSnapshot(` + Array [ + Array [ + -122.01416015625001, + 36.979980468750014, + ], + Array [ + -73.98193359375, + 40.71533203125, + ], + ] + `); + }); });