Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This is to expand on this question.

How can i programatically obtain the corner coordinates (in page units) or the envelope of the data frame in layout view?

I don't seem to be able to do this with iActiveView:Extent as it is returning the extent of the data view in page units. The below screen capture shows what I would like to get. The coordinates are roughly; upper left 0.9,10 and lower right 8, 0.9. Even in page layout iActive:extent returns: upper left -3.4, 12 and lower right 14,-3 which is the extent of the entire application window not the data frame as it appears in layout.

Here is what i need: enter image description here

share|improve this question
The tool can now be downloaded here: – Jakub Jul 9 '12 at 14:03

2 Answers 2

up vote 3 down vote accepted

Cast the IMxDocument.FocusMap to IActiveView and retrieve current extent from the Extent property.

The map will always automatically modify its extent and other information when you switch from data frame view to the layout view (and back).

share|improve this answer
Perfect! Thanks! – Jakub Jul 6 '12 at 20:41

Hope I got the idea right this time. As I had my Eclipse environment open, I simply put it in a AddIn-Button - so the interesting part of the code is a bit down in the try/catch block.


import javax.swing.JOptionPane;

import com.esri.arcgis.addins.desktop.Button;
import com.esri.arcgis.arcmapui.IMxDocument;
import com.esri.arcgis.framework.IApplication;
import com.esri.arcgis.interop.AutomationException;
import com.esri.arcgis.carto.IMap;

import com.esri.arcgis.carto.IPageLayout;
import com.esri.arcgis.carto.IGraphicsContainer;
import com.esri.arcgis.carto.IElement;

import com.esri.arcgis.carto.IFrameElement;
import com.esri.arcgis.carto.IMapFrame;

import com.esri.arcgis.geometry.IEnvelopeGEN;

import com.esri.arcgis.geometry.IGeometry;

public class mapLayoutPaperExtent extends Button {
    private IApplication app;
    private IMxDocument mxDoc;
    @Override public void init(IApplication app) {
        // TODO Auto-generated method stub = app;
    // Returns whether this button is checked
    public boolean isChecked() {
        return false;

    // Returns whether this button is enabled
    public boolean isEnabled() {
        return true;
    public void onClick() throws IOException, AutomationException {
        // TODO Auto-generated method stub

        try {
            mxDoc = (IMxDocument) app.getDocument();
            IMap map = mxDoc.getFocusMap();

            IPageLayout pageLayout = mxDoc.getPageLayout();

            IGraphicsContainer graphics = (IGraphicsContainer) pageLayout;
            IFrameElement frameElement = graphics.findFrame(map);
            IMapFrame mapFrame = (IMapFrame) frameElement;
            IElement mapElement = (IElement) mapFrame;
            IGeometry geometry = mapElement.getGeometry();

            IEnvelopeGEN envelope = (IEnvelopeGEN) geometry.getEnvelope();

            double xMin = envelope.getXMin();
            double xMax = envelope.getXMax();
            JOptionPane.showMessageDialog(null, String.valueOf(xMin) + " " + String.valueOf(xMax) );

        }catch (Exception e){


share|improve this answer
Hi @doRi. Welcome to GIS SE. Normally an answer should provide a solution, partial solution or a workaround. You can provide comments such as yours under the question by clicking 'Add comment'. I want paper coordinates which i can then transform to whatever screen or map units. The problem is that I am not getting paper coordinates but the application window coordinates with respect to the paper, hence the negative values. I think can can somehow iterate through the graphics container elements and pick out the data frame but it's been years since I've done that.... Any other way will do. – Jakub Jul 6 '12 at 17:17
Just tried @Petr Krebs way, but somehow it doesn't work for me - I added this: IActiveView activeView = (IActiveView) mxDoc.getFocusMap(); IEnvelopeGEN envelopea = (IEnvelopeGEN) activeView.getExtent(); double xMina = envelopea.getXMin(); double xMaxa = envelopea.getXMax(); JOptionPane.showMessageDialog(null, String.valueOf(xMina) + " " + String.valueOf(xMaxa) ); The program gives back the map coordinates when in dataView and in layoutView ?! – doRi Jul 6 '12 at 21:36
@doRi if you are asking a question of your own please post it as a brand new question, not an answer. – blah238 Jul 6 '12 at 21:39
By casting the IMxDocument.FocusMap to IActiveView you will need to transform to page units if that's what you need. Or screen units. The important part is that the coordinates correspond to the layout extent which is what i needed. I used Peter's suggestion to correct my code which now works perfectly. – Jakub Jul 7 '12 at 1:33

Your Answer


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.