CoordinateSystem Example


Prompts the user for a PRJ file and sets the map's coordinate system based on the selected PRJ file.

VBScript Code

Copy Code
Sub SetMapProjection
      'Prompt the user to select a PRJ file
      Dim txtPRJFile
      txtPRJFile = CommonDialog.ShowOpen("prj", "Projection files|*.prj", "Select new map projection")
      'If Cancel button is pressed, exit
      If IsEmpty(txtPRJFile) Then
            Exit Sub
      End If
      'Create a CoordSys object and import the selected PRJ file
      Dim pCS
      Set pCS = Application.CreateAppObject("CoordSys")
      pCS.Import txtPRJFile
      'Set the map's coordsys to the selected PRJ file's coordsys
      Set Map.CoordinateSystem = pCS
      'Display the new map projection
      MsgBox "The map projection is now: " & vbCrlf & Map.CoordinateSystem.String, vbInformation, "Current map projection"
      'Clean up
      Set pCS = Nothing
End Sub