mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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) {
|
optionsChanged(options: Options) {
|
||||||
const oldOptions = this.props.options;
|
const oldOptions = this.props.options;
|
||||||
if (options.view !== oldOptions.view) {
|
if (options.view !== oldOptions.view) {
|
||||||
const [updatedSharedView, view] = this.initMapView(options.view, sharedView);
|
const view = this.initMapView(options.view);
|
||||||
sharedView = updatedSharedView;
|
|
||||||
|
|
||||||
if (this.map && view) {
|
if (this.map && view) {
|
||||||
this.map.setView(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)
|
// Because data changed, check map view and change if needed (data fit)
|
||||||
const v = centerPointRegistry.getIfExists(this.props.options.view.id);
|
const v = centerPointRegistry.getIfExists(this.props.options.view.id);
|
||||||
if (v && v.id === MapCenterID.Fit) {
|
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) {
|
if (this.map && view) {
|
||||||
this.map.setView(view);
|
this.map.setView(view);
|
||||||
@ -250,7 +249,7 @@ export class GeomapPanel extends Component<Props, State> {
|
|||||||
pointerMoveListener(evt, this);
|
pointerMoveListener(evt, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
initMapView = (config: MapViewConfig, sharedView?: View | undefined): Array<View | undefined> => {
|
initMapView = (config: MapViewConfig): View | undefined => {
|
||||||
let view = new View({
|
let view = new View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
zoom: 1,
|
zoom: 1,
|
||||||
@ -265,9 +264,9 @@ export class GeomapPanel extends Component<Props, State> {
|
|||||||
view = sharedView;
|
view = sharedView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.initViewExtent(view, config);
|
|
||||||
|
|
||||||
return [sharedView, view];
|
this.initViewExtent(view, config);
|
||||||
|
return view;
|
||||||
};
|
};
|
||||||
|
|
||||||
initViewExtent(view: View, config: MapViewConfig) {
|
initViewExtent(view: View, config: MapViewConfig) {
|
||||||
|
@ -75,7 +75,7 @@ async function initGeojsonFiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getNewOpenLayersMap = (panel: GeomapPanel, options: Options, div: HTMLDivElement) => {
|
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({
|
return (panel.map = new OpenLayersMap({
|
||||||
view: view,
|
view: view,
|
||||||
pixelRatio: 1, // or zoom?
|
pixelRatio: 1, // or zoom?
|
||||||
|
Loading…
Reference in New Issue
Block a user