Does anyone know how to reference the tracklog layer in a script?

1443
5
06-20-2011 03:46 PM
DouglasBurn
New Contributor
Does anyone know how to toggle the visibility of the tracklog from within a script?  When my application starts, it asks the user if they want to enable the GPS.  If the response is yes, it issues the commands:

[INDENT]application.executecommand("gpsenable")
application.executecommand("gpstracklog")[/INDENT]
By default, when the GPS tracklog is started, it is made visible.  I'd rather have it collected in the background, but cannot figure out how to reference the tracklog layer to set its visibility to false.  I've tried a variety of permutations of the following statement, none of which work:

[INDENT]Set objTrackLogLayer = Map.Layers("Tracklog.shp")
objTrackLogLayer.visible = "False"[/INDENT]
Thanks in advance,

D. Burn
Anchorage, AK
Tags (3)
0 Kudos
5 Replies
EddieViljoen
New Contributor III
Hi
Maybe not the answer you want to hear, but I had a similar problem.  (If the tracklog is visible and it becomes big, it becomes very slow each time the map is redrawn.)

Could not find a way to make the tracklog invisible, so ended up writing a small piece of code that writes a custom tracklog (by appending data to a text file).  If you do not need to display the tracklog to the user, this idea works well and fast, even for very big tracklog files.

On each x number of GPS positions received, I do the following:

L_Line = GPS.X
L_Line = L_Line &  vbtab & GPS.Y
L_Line = L_Line &  vbtab & CStr(Application.GPS.Properties("SOG"))
L_Line = L_Line &  vbtab & GPS.Altitude
L_Line = L_Line &  vbtab & Application.GPS.Properties("UTC")
L_Line = L_Line &  vbtab & Now
L_Line = L_Line &  vbtab & CStr(Application.GPS.Properties("COG"))
L_Line = L_Line &  vbtab & CStr(Application.GPS.Properties("SATS_USED"))
L_Line = L_Line &  vbtab & CStr(Application.GPS.Properties("HPE"))
L_Line = L_Line &  vbtab & CStr(Application.GPS.Properties("VPE"))

Set L_FileToWrite = objFSO.OpenTextFile(Trackdir & "TrackLog.txt", 8, True)   
L_FileToWrite.WriteLine L_Line
L_FileToWrite.Close
0 Kudos
JasonTrook
New Contributor II
Has anyone found a solution to this problem?  I would like to have a turn on and turn off tracklog visibility button so a user doesn't
have to open the TOC to execute the command.
I thought this or a similar variation would have worked but no luck so far:
Application.Map.Layers("GPS Tracklog").visible=false
Thanks,
Jason
0 Kudos
DeniseKing
Esri Regular Contributor
Jason,

Check out couple of ArcPad Team Blog topics, Custom toolbar for working w/ArcPad Tracklogs & How to archive GPS Tracklog using VBScript, JScript or Python using sample found on ArcGIS.com Gallery > ArcPad.

Cheers,
Denise
0 Kudos
JasonTrook
New Contributor II
Denise,
This applet is great and has been very helpful.  However, I would like to expand the capabilities of the applet by adding two new
buttons -> Turn off tracklog visibility and turn on tracklog visibility.  I can turn on/off the tracklog itself but haven't been successful
in programming a command to turn on/off the visibility.

Application.Map.Layers("GPS Tracklog").visible=false

This code works for other layers in my TOC but not the tracklog.
Thanks,
Jason
0 Kudos
GarethWalters
Occasional Contributor III
Hi everyone,

You can access the tracklog by using its index value rather than its name :
Map.Layers(0).Visible=true


FYI, If you use Map.Layers(-1) you can access the Map Grid.

I hope this answers your query.

Cheers,

Gareth
0 Kudos