ArcPad Scripting Object Model
AddLayerFromFile Method
See Also  Example  Send comments on this topic.
FileName
Required. A string that represents the complete file path to the layer.
Map Object : AddLayerFromFile Method

Glossary Item Box

Description

Loads an existing layer into the current map and returns a reference to the layer.

Syntax

Set variable = object.AddLayerFromFile ( FileName )

Parameters

FileName
Required. A string that represents the complete file path to the layer.

Return Type

Remarks

  • FilePath is a string representing the complete file path to the layer. If a map file (.apm) is specified, all layers in the map file will be added to the existing map, but none of the properties defined in the map file will be applied.

 

  • If the specified layer is not successfully added to the map, AddLayerFromFile will return the keyword Nothing. You can check for this return value with the Is operator. For example:

           Dim pLyr
           Set pLyr = Map.AddLayerFromFile("C:\nonexistantlayer.shp")
           If pLyr Is Nothing Then
               'Add layer failed
           Else
               'Add layer succeeded
           End If

 

  • The file path for loading an AXF layer is slightly different.

    For example, to add the Poles layer in the Riverside sample date to a map:

          Map.AddLayerFromFile("C:\Users\Public\Documents\ArcPad\Samples\Riverside\Riverside_mdb.axf|1|Poles")
           

Example

Gets an ArcPad map or layer file (via Open dialog box) and adds it to the current map.
ShowOpen Example (VBScript)Copy Code
Sub AddLayerExample
  Dim strDefExt, strFileFilter, strTitle, lngFlags, varResult
  'Set the arguments of the Open dialog box
  strDefExt = "apl"
  strFileFilter = "ArcPad Maps|*.apm|ArcPad Layers|*.jpg;*.shp;*.sid"
  strTitle = "Select ArcPad Data"
  lngFlags = &H1000   'only allow existing files to be specified
  'Show the Open dialog box and get the result
  varResult = CommonDialog.ShowOpen(strDefExt,strFileFilter,strTitle,lngFlags)
  'If a file is selected, add it to the map and refresh the map  
  If Not IsEmpty (varResult) Then  
    Application.Map.AddLayerFromFile (varResult)  
    Application.Map.Refresh
  End If
End Sub

See Also

© 2013 All Rights Reserved.