diff --git a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py
index 2b85e8653a..2f88d06b7b 100644
--- a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py
+++ b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.py
@@ -47,6 +47,7 @@ class VoPlugin(PluginTemplateMixin, AddResultsMixin, TableMixin):
resources_loading = Bool(False).tag(sync=True)
source = Unicode("").tag(sync=True)
+ coord_follow_viewer_pan = Bool(False).tag(sync=True)
coordframes = List([]).tag(sync=True)
coordframe_selected = Unicode("icrs").tag(sync=True)
radius_val = Float(1).tag(sync=True)
@@ -89,7 +90,24 @@ def __init__(self, *args, **kwargs):
self.hub.subscribe(self, RemoveDataMessage, handler=self.vue_center_on_data)
self.hub.subscribe(self, LinkUpdatedMessage, handler=self.vue_center_on_data)
- @observe("viewer_selected", type="change")
+ @observe("viewer_selected", "coord_follow_viewer_pan", type="change")
+ def vue_viewer_changed(self, _=None):
+ if not hasattr(self, "viewer"):
+ # mixin object not yet initialized
+ return
+
+ # Clear all existing subscriptions
+ for viewer in self.viewer.viewers:
+ viewer.state.remove_callback('zoom_center_x', self.vue_center_on_data)
+ viewer.state.remove_callback('zoom_center_y', self.vue_center_on_data)
+
+ # Subscribe to selected viewer
+ if self.coord_follow_viewer_pan:
+ self.viewer.selected_obj.state.add_callback('zoom_center_x', self.vue_center_on_data)
+ self.viewer.selected_obj.state.add_callback('zoom_center_y', self.vue_center_on_data)
+
+ self.vue_center_on_data()
+
def vue_center_on_data(self, _=None):
"""
If data is present in the default viewer, center the plugin's coordinates on
diff --git a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue
index a1a81af2db..3fb456a493 100644
--- a/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue
+++ b/jdaviz/configs/default/plugins/virtual_observatory/vo_plugin.vue
@@ -12,11 +12,20 @@
:selected.sync="viewer_selected"
label="Viewer"
:show_if_single_entry="true"
- hint="Select a viewer to autofill center coordinates, or Manual for manual coordinate entry."
+ hint="Select a viewer to retrieve center coordinates, or Manual for manual coordinate entry."
/>
+
+
+
+
-