Select to view content in your preferred language

FindNearestXY from GPS or pointer

807
1
04-23-2010 07:07 PM
CharlottePeters
Deactivated User
Hi,
How can I use code to identify whether a point was added using the GPS or the stylus? Right now, when a user creates a new point with the stylus, an attribute value from an underlying shapefile at that location is stored in a variable and then entered in a control on another shapefile. The stylus method works fine, but I need to allow the user to add a new point using the GPS tool. I was thinking of using an If...then statement, but I don't know how to recognize X/Y coordinates collected using a stylus vs. GPS. I use the following code for the stylus:
cRS.BookMark=Application.Map.SelectionBookmark
  Set cShape=cRS.Fields.Shape
...
...
gRec=gRS.FindNearestXY(cShape.x, cShape.y)


To determine if the point was added with a stylus or GPS I tried the following, but the stylus method always returns the value of where the GPS is currently located and not where the stylus was tapped.
If GPS.x>0 then
  dblX=GPS.x
  dblY=GPS.y
 Else
  cRS.BookMark=Application.Map.SelectionBookmark
  Set cShape=cRS.Fields.Shape
 End If 
...
...
If GPS.x>0 then '
  gRec=gRS.FindNearestXY(GPS.x, GPS.y) '
 Else '
  gRec=gRS.FindNearestXY(cShape.x, cShape.y)
 End If '


My intent is to allow the user to collect a point with a stylus even when the GPS receiver is on. IsValidFix and IsOpen automatically generate GPS.x and GPS.y when I want to wait until the user taps the GPS point button before populating GPS.x and GPS.y. I thought about the OnPosition event, but know how to use that in code.
Any guidance would be appreciated.
Thanks,
Charlotte
Tags (3)
0 Kudos
1 Reply
RobChouinard
Frequent Contributor
Is this what you are looking for?

Sub CapturePointerXY()
     'Get X,Y From Pointer
     Dim X, Y
     X = Map.PointerX
     Y = Map.PointerY
     'Do something with this captured location
End Sub


What I did was setup a new toolbutton and called "CapturePointerXY" from the "onpointerup" event. This makes a custom PointerMode the same name of the toolbutton. Search "PointerMode" on the ArcPad Help Index for more info on PointerModes.

Hope this helps.
0 Kudos