mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Geomap: Route/path visualization (#43554)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Feature } from 'ol';
|
||||
import { Geometry } from 'ol/geom';
|
||||
import { Geometry, LineString, Point } from 'ol/geom';
|
||||
import VectorSource from 'ol/source/Vector';
|
||||
|
||||
import { DataFrame } from '@grafana/data';
|
||||
import { DataFrame, Field } from '@grafana/data';
|
||||
|
||||
import { getGeometryField, LocationFieldMatchers } from './location';
|
||||
|
||||
@@ -34,4 +34,26 @@ export class FrameVectorSource<T extends Geometry = Geometry> extends VectorSour
|
||||
// only call this at the end
|
||||
this.changed();
|
||||
}
|
||||
|
||||
updateLineString(frame: DataFrame) {
|
||||
this.clear(true);
|
||||
const info = getGeometryField(frame, this.location);
|
||||
if (!info.field) {
|
||||
this.changed();
|
||||
return;
|
||||
}
|
||||
|
||||
const field = info.field as Field<Point>;
|
||||
const geometry = new LineString(field.values.toArray().map((p) => p.getCoordinates())) as Geometry;
|
||||
this.addFeatureInternal(
|
||||
new Feature({
|
||||
frame,
|
||||
rowIndex: 0,
|
||||
geometry: geometry as T,
|
||||
})
|
||||
);
|
||||
|
||||
// only call this at the end
|
||||
this.changed();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user