English

How To: Display longitude and latitude coordinate for a projected view

Summary

You can use Avenue to display information on the ArcView status bar. This document uses an example to display decimal degree coordinates of a location on a projected view.

Procedure

This procedure requires the view to have a projection properties setting.

  1. Copy, paste, and compile the following code into a <new> script window:

    Code:
    if(av.GetActiveDoc.AsString = "View1") then
    av.DelayedRun("Script2", nil, 0.5)
    end

  2. Rename the new script document Script1.

    A. Select Properties from the Script menu.
    B. Type in a new name in the Name field.
    C. Click OK.

  3. Copy, paste, and compile the following code into another new script window:

    Code:
    theView = av.GetProject.FindDoc("View1")
    viewprojection = theview.getprojection
    p = theView.GetDisplay.ReturnUserPoint.ReturnUnprojected(viewProjection)
    x = p.GetX
    y = p.GetY
    lon = x.SetFormat("ddd.ddddd")
    lat = y.SetFormat("dd.ddddd")
    msg = ("Position = "+lon.AsString+", "+lat.AsString)
    av.ShowMsg(msg)
    System.RefreshWindows

  4. Rename the second new script document Script2.

    A. Select Properties from the Script menu.
    B. Type in a new name in the Name field.
    C. Click OK.


  5. Double-click the tool bar to open the Customization Dialog box.
  6. Set type to View and category to Tool, then move the cursor to the end of the tool button display (the cursor will look like a box).
  7. Click Separator twice and click Tool once.
  8. Double-click the Apply field and select Script1 in the Script Manager. Double-click the Click field and select Script2.

    Note:
    If you want to assign the tool and icon, double-click the Icon field and select the desired representation.

  9. Close the dialog and select the new tool.
  10. Click anywhere inside of a projected view and look at the status bar.

    Note:
    This example is hard coded to work with a view named View1, and scripts named Script1 and Script2. You will need to edit the scripts if you wish to use documents with different names.