mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Geomap: Fix Share View (#76787)
* Geomap: Fix Share View * Fix share view for multiple panels and options * clean up --------- Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
This commit is contained in:
parent
bfe7986ab7
commit
7028406b6d
@ -149,8 +149,7 @@ export class GeomapPanel extends Component<Props, State> {
|
||||
optionsChanged(options: Options) {
|
||||
const oldOptions = this.props.options;
|
||||
if (options.view !== oldOptions.view) {
|
||||
const [updatedSharedView, view] = this.initMapView(options.view, sharedView);
|
||||
sharedView = updatedSharedView;
|
||||
const view = this.initMapView(options.view);
|
||||
|
||||
if (this.map && view) {
|
||||
this.map.setView(view);
|
||||
@ -176,7 +175,7 @@ export class GeomapPanel extends Component<Props, State> {
|
||||
// Because data changed, check map view and change if needed (data fit)
|
||||
const v = centerPointRegistry.getIfExists(this.props.options.view.id);
|
||||
if (v && v.id === MapCenterID.Fit) {
|
||||
const [, view] = this.initMapView(this.props.options.view);
|
||||
const view = this.initMapView(this.props.options.view);
|
||||
|
||||
if (this.map && view) {
|
||||
this.map.setView(view);
|
||||
@ -250,7 +249,7 @@ export class GeomapPanel extends Component<Props, State> {
|
||||
pointerMoveListener(evt, this);
|
||||
};
|
||||
|
||||
initMapView = (config: MapViewConfig, sharedView?: View | undefined): Array<View | undefined> => {
|
||||
initMapView = (config: MapViewConfig): View | undefined => {
|
||||
let view = new View({
|
||||
center: [0, 0],
|
||||
zoom: 1,
|
||||
@ -265,9 +264,9 @@ export class GeomapPanel extends Component<Props, State> {
|
||||
view = sharedView;
|
||||
}
|
||||
}
|
||||
this.initViewExtent(view, config);
|
||||
|
||||
return [sharedView, view];
|
||||
this.initViewExtent(view, config);
|
||||
return view;
|
||||
};
|
||||
|
||||
initViewExtent(view: View, config: MapViewConfig) {
|
||||
|
@ -75,7 +75,7 @@ async function initGeojsonFiles() {
|
||||
}
|
||||
|
||||
export const getNewOpenLayersMap = (panel: GeomapPanel, options: Options, div: HTMLDivElement) => {
|
||||
const [view] = panel.initMapView(options.view, undefined);
|
||||
const view = panel.initMapView(options.view);
|
||||
return (panel.map = new OpenLayersMap({
|
||||
view: view,
|
||||
pixelRatio: 1, // or zoom?
|
||||
|
Loading…
Reference in New Issue
Block a user