Setting transparency color attribute for raster files in ArcPad

763
0
09-06-2012 12:18 PM
ChrisSeabrooke
New Contributor III
I have an application written in VB Script that loads raster files to the map. The problem is the background displays as black or white strips. I want to re-set the display background to no color -- in code after the raster is loaded. I've seen an attribute 'transparencycolor', but I can't find anything on how to set this using VBScript.

In ArcMap, I can set the Display Background value to match the raster and then select As 'No Color'. But this won't work for our customers. Is there a way to do something similar in code?

Following is the subroutine that loads the layers. After this method is done, I want to check for raster-type layers and set the transparency. Any help is appreciated.

Chris S.

Sub LoadMapLayers()
    'Get the path to the current map document and load all the shapefiles
    Dim mapPath
    Dim layerFile, arrLayerFiles, newLayer
    Dim layerTypeList, curLayerType, curLayerFile
      
    'Get the data path from the map
    mapPath = GetFilePath(Application.Map.FilePath)

    'Iterate through the file type list to check for map layers to add
    layerTypeList = Application.UserProperties("RasterFileTypeList")
   
    If Len(Trim(layerTypeList)) > 0 Then
     'Create a new file to check for map layers to add
     Set layerFile = Application.CreateAppObject("File")
    End If
   
    'Loop through each item
    While Len(Trim(layerTypeList)) > 0
        'Get the next item
        curLayerType = TokenString(layerTypeList, ",")

        'Check the map path for matching file types
        arrLayerFiles = layerFile.FindFiles(WithTrailingBackslash(mapPath) & "*" & curLayerType)
       
        'Iterate the array of files and add each one to the map
        If VarType(arrLayerFiles) <> 0 Then
            For Each curLayerFile In arrLayerFiles
                'Add the layer to the map
  Set newLayer = Application.Map.AddLayerFromFile(WithTrailingBackslash(mapPath) & curLayerFile)     

                If Not newLayer Is Nothing Then
                    'Check the layer type to see if it's a raster and needs to be moved to the bottom
                    If LayerIsRaster(newLayer) Then MoveLayerToBottom(newLayer.Name)    
                End If
            Next
        End If
    Wend

     On Error Resume Next
     Set layerFile = Nothing

    'Done, refresh the map
    RefreshMap(False)
   
End Sub
Tags (3)
0 Kudos
0 Replies