VBA

May 11, 2012 at 3:19 PM

Hello All,

I'm very new to MapWinGIS (just started looking at it this week) but have had some success in getting it up and running.  I have a MsAccess database and am using VBA to manipulate the map.  I've got my GIS layer data loaded, and I've set the basic layer viewing properties.  What I'm struggling with is setting visualization properties for individual shapes (polygons, polylines etc) within a layer.  I am able to iterate through the shapes, and evaluate the term that I want to differentiate on, but I'm not able to change the shape properties (line width, line color, polygon fill).  So my first question:  does anybody have some VBA (or VB.net) code that demonstrates how to do this?

Second question: although I've loaded basemaps (GIS layers) into the map, my ultimate goal is to take spatial data from the database and display it (with various user definable filters) on the map.  I know how to write the filters, but its not clear how to connect an access table (or query) to the map. 

Thanks in advance and sorry for the noob questions

Doug

May 11, 2012 at 3:52 PM

If you are using MW4.8 then what was recommended was to create a category for the shapfeile and then assign that category to the individual shape. Doing a search in the documentation http://mapwingis.codeplex.com/documentation and you will see samples on creating categories. The first link and the Sample Code goes a long way.

May 11, 2012 at 4:23 PM
Edited May 11, 2012 at 4:24 PM

I’ve been trying to do that, although unsuccessfully. I’m sure I have the syntax (or concept) wrong which is why I was looking for some VBA code examples. Below is my attempt at setting up the category, followed by a snippet from a separate section of code where I try and apply the category to a selected polygon:

 

' Load Parcel Layer

shpFilePathAndName = "C:\Users\d.kelly\Downloads\MapWinGIS\MapLayers\Export_Output_2.shp"

ParcelLayer.Open (shpFilePathAndName)

hndParcels = mapCtl.AddLayer(ParcelLayer, True)

mapObj.ShapeLayerFillColor(hndParcels) = RGB(100, 200, 100)

mapObj.ShapeLayerLineColor(hndParcels) = RGB(75, 0, 0)

 

‘setup category

Set LayerShapeOptions = ParcelLayer.DefaultDrawingOptions

LayerShapeOptions.FillColor = vbBlue

Set LayerCat = ParcelLayer.Categories.Add("LayerCat1")

LayerCat.DrawingOptions = LayerShapeOptions

LayerCatIndex = ParcelLayer.Categories.Count

*****************************************

 

 

 

 

targetShapeIndex = selectedLayerShapefile.PointInShapefile(projX, projY) 'returns a shape index

ParcelLayer.ShapeCategory(targetShapeIndex) = ShapeCat1Index 'color it

 

 

Douglas J. Kelly L.G., L.HG. 

Hydrogeologist

Island County Environmental Health

(360) 678-7885

D.Kelly@co.island.wa.us

 

From: sindizzy [email removed]
Sent: Friday, May 11, 2012 8:53 AM
To: Doug Kelly
Subject: Re: VBA [mapwingis:355467]

 

From: sindizzy

If you are using MW4.8 then what was recommended was to create a category for the shapfeile and then assign that category to the individual shape. Doing a search in the documentation http://mapwingis.codeplex.com/documentation and you will see samples on creating categories. The first link and the Sample Code goes a long way.

May 11, 2012 at 4:52 PM
Your index is probably wrong. Indexes are zero-based I believe.

Abel



Sent from my Palm Pre on the Now Network from Sprint


On May 11, 2012 11:24 AM, IslandHydro <notifications@codeplex.com> wrote:

From: IslandHydro

I’ve been trying to do that, although unsuccessfully. I’m sure I have the syntax (or concept) wrong which is why I was looking for some VBA code examples. Below is my attempt at setting up the category, followed by a snippet from a separate section of code where I try and apply the category to a selected polygon:

' Load Parcel Layer

shpFilePathAndName = "C:\Users\d.kelly\Downloads\MapWinGIS\MapLayers\Export_Output_2.shp"

ParcelLayer.Open (shpFilePathAndName)

hndParcels = mapCtl.AddLayer(ParcelLayer, True)

mapObj.ShapeLayerFillColor(hndParcels) = RGB(100, 200, 100)

mapObj.ShapeLayerLineColor(hndParcels) = RGB(75, 0, 0)

‘setup category

Set LayerShapeOptions = ParcelLayer.DefaultDrawingOptions

LayerShapeOptions.FillColor = vbBlue

Set LayerCat = ParcelLayer.Categories.Add("LayerCat1")

LayerCat.DrawingOptions = LayerShapeOptions

LayerCatIndex = ParcelLayer.Categories.Count

targetShapeIndex = selectedLayerShapefile.PointInShapefile(projX, projY) 'returns a shape index

ParcelLayer.ShapeCategory(targetShapeIndex) = ShapeCat1Index 'color it

Douglas J. Kelly L.G., L.HG.

Hydrogeologist

Island County Environmental Health

(360) 678-7885

D.Kelly@co.island.wa.us

From: sindizzy [email removed]
Sent: Friday, May 11, 2012 8:53 AM
To: Doug Kelly
Subject: Re: VBA [mapwingis:355467]

From: sindizzy

If you are using MW4.8 then what was recommended was to create a category for the shapfeile and then assign that category to the individual shape. Doing a search in the documentation http://mapwingis.codeplex.com/documentation and you will see samples on creating categories. The first link and the Sample Code goes a long way.