(VB6) NumLayers and LayerType
(VB6) NumLayers and LayerType
1 de 4
http://www.mapwindow.org/phorum/read.php?11,5104,printview,page=1
Search MapWindow.org
Go
Home
Project Introduction
News
Open Source License
Buy CD & T-shirt
Contact
Products
MapWindow 4 Desktop
MapWindow 6 Alpha
HydroDesktop
MapWinGIS ActiveX
DotSpatial Library
Downloads
MapWindow 4 Desktop
MapWindow 6 Alpha
HydroDesktop
MapWinGIS ActiveX
DotSpatial Library
Documentation
MapWindow 4 Desktop
MapWindow 6 Alpha
HydroDesktop
MapWinGIS ActiveX
DotSpatial Library
Community
Discussion Forums
Mailing Lists
Issue Tracking
Internationalization
People
Service Vendors
Project Management
Source Code
Events
2010 Conference - Orlando
2011 Conference - San Diego
2012 Conference - Europe
This script using the ActiveX and VB6 to loop trough the layers and get some
properties of the layers. Getting the Layertype using eLayerType isn't working, I've filed a bug report:
'Boolean
Dim bStatus As Boolean
'String
Dim sDir As String
Dim sFilename As String
'Long
Dim handle As Long, i As Long
'Object
Dim oMap As MapWinGIS.Map
Dim oSf As New MapWinGIS.Shapefile
Dim oGrid As New MapWinGIS.Grid
Dim oIm As New MapWinGIS.Image
Dim oCs As New MapWinGIS.GridColorScheme
Dim oUtils As New MapWinGIS.utils
'Init:
Set oMap = frmShapefiles.Map1 'Change this to your needs
sDir = "C:\test\NumLayersAndLayerType\" 'Change this to your needs
'For testing purposes first add some files to the map:
'Open shapefiles:
With oSf
sFilename = sDir & "Points.shp"
23/04/2014 10:57
2 de 4
http://www.mapwindow.org/phorum/read.php?11,5104,printview,page=1
bStatus = .open(sFilename)
If Not bStatus Then MsgBox "Cannot open shapefile (" & sFilename & ") " & .ErrorMsg(.LastErrorCode)
End With 'oSf
Call oMap.AddLayer(oSf, True)
oSf.Close
Set oSf = New MapWinGIS.Shapefile
With oSf
sFilename = sDir & "Lines.shp"
bStatus = .open(sFilename)
If Not bStatus Then MsgBox "Cannot open shapefile (" & sFilename & ") " & .ErrorMsg(.LastErrorCode)
End With 'oSf
Call oMap.AddLayer(oSf, True)
oSf.Close
Set oSf = New MapWinGIS.Shapefile
With oSf
sFilename = sDir & "Polygons.shp"
bStatus = .open(sFilename)
If Not bStatus Then MsgBox "Cannot open shapefile (" & sFilename & ") " & .ErrorMsg(.LastErrorCode)
End With 'oSf
Call oMap.AddLayer(oSf, True)
oSf.Close
'Open gridfile
sFilename = sDir & "Grid.asc"
With oGrid
bStatus = .open(sFilename, UnknownDataType, True, Ascii)
If Not bStatus Then MsgBox "Cannot open gridfile (" & sFilename & ") " & .ErrorMsg(.LastErrorCode)
End With 'oGrid
With oCs
.UsePredefined oGrid.Minimum, oGrid.Maximum, Meadow
.NoDataColor = vbWhite
End With 'cs
Set oIm = oUtils.GridToImage(oGrid, oCs)
bStatus = oMap.AddLayer(oIm, True)
oGrid.Close
MsgBox "Number of layers: " & oMap.NumLayers
For i = 0 To oMap.NumLayers - 1
handle = oMap.LayerHandle(i)
'Get layertype:
'LayerType isn't available trough MapWinGis,
'Filed a bugreport: #372
'get layerposition:
MsgBox oMap.LayerPosition(handle)
Next i
'cleanup:
Set oMap = Nothing
Set oSf = Nothing
Set oGrid = Nothing
Set oIm = Nothing
Set oCs = Nothing
Set oUtils = Nothing
End Sub
23/04/2014 10:57
3 de 4
http://www.mapwindow.org/phorum/read.php?11,5104,printview,page=1
Banner Exchange
Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:
23/04/2014 10:57
4 de 4
http://www.mapwindow.org/phorum/read.php?11,5104,printview,page=1
<a
href="http://www.M
apWindow.org
/download.php"><i
Home | Buy | Download | Documentation | Code Repository | Open Source License | Discussion Forum | Contact | Site Statistics
Copyright 1998-2010 - Daniel P. Ames and the MapWindow Open Source Team
last updated: 17 March 2010
23/04/2014 10:57