Skip to content

Instantly share code, notes, and snippets.

@stephenquan
Last active September 6, 2019 05:52
Show Gist options
  • Save stephenquan/d8db9d75de1ea3ca4f1e0c07476f11f1 to your computer and use it in GitHub Desktop.
Save stephenquan/d8db9d75de1ea3ca4f1e0c07476f11f1 to your computer and use it in GitHub Desktop.
MapIdentify Applet for ArcPad

MapIdentify.apa ArcPad Applet

This is an ArcPad Applet customization that shows additional information when the Identify tool is used.

Installation

Deploy MapIdentify.apa and MapIdentify.vbs to C:\Users\Public\Documents\ArcPad\Applets\ folder

<?xml version="1.0" encoding="UTF-8"?>
<ArcPad>
<APPLET>
<SYSTEMOBJECTS>
<MAP onidentify="OnIdentify"/>
</SYSTEMOBJECTS>
</APPLET>
<SCRIPT src="MapIdentify.vbs" language="vbscript"/>
</ArcPad>
Option Explicit
Sub OnIdentify
Dim m, l, b, r, i, n
Set m = ThisEvent.Object
Set l = ThisEvent.Layer
b = ThisEvent.Bookmark
Set r = l.Records
r.Bookmark = b
PrintLayer l
End Sub
Sub PrintLayer(l)
Console.Print l.Name
PrintRecords l.Records
PrintShapeInfo l.Records
Console.Print " "
End Sub
Sub PrintRecords(r)
Dim i
For i = 1 to r.Fields.Count
PrintField r.Fields(i)
Next
End Sub
Sub PrintField(f)
If InStr(f.Name, "AXF_") = 1 Then Exit Sub
If InStr(f.Name, "SHAPE_") = 1 Then Exit Sub
If f.Name = "SHAPE" Then Exit Sub
Console.Print " " & f.Name & ": " & f
End Sub
Function UnitName(CoordSys)
Dim Name
Name = CoordSys.LookupCode(CoordSys.ProjectionUnit)
If Name = "Foot_US" Then Name = "ft"
UnitName = Name
End Function
Sub PrintLength(LengthValue, CoordSys)
Dim UnitConst
UnitConst = CoordSys.LookupConstant(CoordSys.ProjectionUnit)
If UnitConst = 1.0 Then
Console.Print " Length: " & LengthValue & " m"
Else
Console.Print " Length: " & (LengthValue * UnitConst) & " m ( " & LengthValue & " " & UnitName(CoordSys) & " )"
End If
End Sub
Sub PrintArea(AreaValue, CoordSys)
Dim UnitConst
UnitConst = CoordSys.LookupConstant(CoordSys.ProjectionUnit)
If UnitConst = 1.0 Then
Console.Print " Area: " & AreaValue & " m " & Chr(178)
Else
Console.Print " Area: " & (AreaValue * UnitConst * UnitConst) & " m " & Chr(178) & " ( " & AreaValue & " " & UnitName(CoordSys) & " " & Chr(178) & " )"
End If
End Sub
Sub PrintShapeInfo(r)
Select Case r.Fields.ShapeType
Case 1, 11, 21
Console.Print " X: " & r.Fields.Shape.X
Console.Print " Y: " & r.Fields.Shape.Y
Case 3, 13, 23
PrintLength r.Fields.Shape.Length, r.Fields.Shape.CoordinateSystem
Case 5, 15, 23
PrintLength r.Fields.Shape.Perimeter, r.Fields.Shape.CoordinateSystem
PrintArea r.Fields.Shape.Area, r.Fields.Shape.CoordinateSystem
End Select
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment