Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.)

share|improve this question
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 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 at 15:00
    
@GISKid -- Interesting idea, can you elaborate on how to do that (presumably as an Answer)? –  Erica Jul 25 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 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 at 17:59

2 Answers 2

up vote 6 down vote accepted

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):        
        try:    
            lyr = pythonaddins.GetSelectedTOCLayerOrDataFrame()
            mxd = arcpy.mapping.MapDocument("current")
            df = arcpy.mapping.ListDataFrames(mxd)[0]
            df.panToExtent(lyr.getExtent())            
            arcpy.RefreshActiveView()

            del lyr, mxd, df
        except:
            pass

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.

share|improve this answer
    
I was hoping you (or somebody) could put together a code snippet for this! Thanks :-) –  Erica Jul 25 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.

share|improve this answer
    
Aha! This works in 10.1 as well. –  Erica Jul 25 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 at 15:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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