In an Attribute Table, I am able to choose Pan to Feature (rather than Zoom to Feature) to refocus the map without changing the zoom level. Is there a similar Pan to Layer option (and/or shortcut key) when in the Table of Contents, to match the Zoom to Layer?

(The workaround is, obviously, Zoom to Layer and then reset the scale -- I'm just looking for a simpler way.)

  • 1
    There doesn't appear to be a button to do this in customize mode, but you could create a Python addin that pans to the centroid of the layer, for instance. – Paul Jul 25 '14 at 14:57
  • Another work around is to change your scale settings to only one scale, that way "zoom to layer" would default to your set scale. – GISKid Jul 25 '14 at 15:00
  • @GISKid -- Interesting idea, can you elaborate on how to do that (presumably as an Answer)? – Erica Jul 25 '14 at 15:01
  • @GISKid, while that's a great idea, it doesn't work. Zoom to layer is disabled when fixed scale is set for the data frame. – Paul Jul 25 '14 at 15:03
  • 1
    Not quite what you asked but if you hold down the Alt key when you click on a layer in the Top it will zoom to full extent. – Hornbydd Jul 25 '14 at 17:59

The python addin button is actually simpler than I first thought. Just highlight a layer in the TOC and the button will pan to it.

import arcpy, pythonaddins

class ButtonClass1(object):
    """Implementation for pantolayer_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):        
            lyr = pythonaddins.GetSelectedTOCLayerOrDataFrame()
            mxd = arcpy.mapping.MapDocument("current")
            df = arcpy.mapping.ListDataFrames(mxd)[0]

            del lyr, mxd, df

If you wanted, you could introduce code to ensure that disables the button when no layer in TOC is selected or does nothing when a data frame is selected.

  • I was hoping you (or somebody) could put together a code snippet for this! Thanks :-) – Erica Jul 25 '14 at 15:59

Another potential workaround (at least in 10.2) that doesn't make you mess with scale would be to right click the layer -> selection -> Select All, then right click the layer -> selection -> Pan to Selected Features, and then clear the selection.

  • Aha! This works in 10.1 as well. – Erica Jul 25 '14 at 15:13
  • Zooming to layer and then changing the scale back seems like a lot less clicks. +1 as this is a pretty neat idea. – Paul Jul 25 '14 at 15:17
  • Unfortunately this does not work for layers that are not selectable, i.e Rasters – Barbarossa Mar 20 '15 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.