mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Geomap: Fix duplicate layer bug (#54660)
* Geomap: Fix duplicate layer bug * Remove dependency on name parameter
This commit is contained in:
@@ -35,6 +35,7 @@ import { GeomapOverlay, OverlayProps } from './GeomapOverlay';
|
|||||||
import { GeomapTooltip } from './GeomapTooltip';
|
import { GeomapTooltip } from './GeomapTooltip';
|
||||||
import { DebugOverlay } from './components/DebugOverlay';
|
import { DebugOverlay } from './components/DebugOverlay';
|
||||||
import { MeasureOverlay } from './components/MeasureOverlay';
|
import { MeasureOverlay } from './components/MeasureOverlay';
|
||||||
|
import { MeasureVectorLayer } from './components/MeasureVectorLayer';
|
||||||
import { GeomapHoverPayload, GeomapLayerHover } from './event';
|
import { GeomapHoverPayload, GeomapLayerHover } from './event';
|
||||||
import { getGlobalStyles } from './globalStyles';
|
import { getGlobalStyles } from './globalStyles';
|
||||||
import { defaultMarkersConfig, MARKERS_LAYER_ID } from './layers/data/markersLayer';
|
import { defaultMarkersConfig, MARKERS_LAYER_ID } from './layers/data/markersLayer';
|
||||||
@@ -146,6 +147,12 @@ export class GeomapPanel extends Component<Props, State> {
|
|||||||
private doOptionsUpdate(selected: number) {
|
private doOptionsUpdate(selected: number) {
|
||||||
const { options, onOptionsChange } = this.props;
|
const { options, onOptionsChange } = this.props;
|
||||||
const layers = this.layers;
|
const layers = this.layers;
|
||||||
|
this.map?.getLayers().forEach((l) => {
|
||||||
|
if (l instanceof MeasureVectorLayer) {
|
||||||
|
this.map?.removeLayer(l);
|
||||||
|
this.map?.addLayer(l);
|
||||||
|
}
|
||||||
|
});
|
||||||
onOptionsChange({
|
onOptionsChange({
|
||||||
...options,
|
...options,
|
||||||
basemap: layers[0].options,
|
basemap: layers[0].options,
|
||||||
@@ -227,6 +234,7 @@ export class GeomapPanel extends Component<Props, State> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
reorder: (startIndex: number, endIndex: number) => {
|
reorder: (startIndex: number, endIndex: number) => {
|
||||||
|
// TODO look into reorder with respect to measure layer
|
||||||
const result = Array.from(this.layers);
|
const result = Array.from(this.layers);
|
||||||
const [removed] = result.splice(startIndex, 1);
|
const [removed] = result.splice(startIndex, 1);
|
||||||
result.splice(endIndex, 0, removed);
|
result.splice(endIndex, 0, removed);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ export const MeasureOverlay = ({ map, menuActiveState }: Props) => {
|
|||||||
if (firstLoad) {
|
if (firstLoad) {
|
||||||
// Initialize on first load
|
// Initialize on first load
|
||||||
setFirstLoad(false);
|
setFirstLoad(false);
|
||||||
|
vector.current.setZIndex(1);
|
||||||
map.addLayer(vector.current);
|
map.addLayer(vector.current);
|
||||||
map.addInteraction(vector.current.modify);
|
map.addInteraction(vector.current.modify);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user