Cant get Point Image to display in MWG ver 4.8

Jan 20, 2012 at 6:54 AM

Hi folks,

I've spent far too long on this and can only think there is a bug in vers 4.8 to display images at shapefile points.

Can someone please check my code below which I have re-written in many ways but all that displays is a single pixel!

Private Sub AddShapefile(Filename As String, Shapename As String)
    Dim FileSys As New Scripting.FileSystemObject
    Dim handle As Long
    Dim ErrMsg As String
    Dim z As Long
    Dim bridge_image As New MapWinGIS.image

    Set sf = CreateObject("MapWinGIS.Shapefile")

    If LCase(Right(Filename, 3)) = "shp" Then
 
        If sf.Open(Filename, Nothing) = False Then
            ErrMsg = sf.ErrorMsg(sf.LastErrorCode)
            MsgBox "The file, " & Filename & " failed to open for the following reason:" & vbCrLf & ErrMsg, vbCritical
            Exit Sub
        Else
            handle = Map1.AddLayer(sf, True)
            
            Map1.layername(handle) = FileSys.GetFileName(sf.Filename)
            Map1.ZoomPercent = ZoomLevel
            If handle < 0 Then Exit Sub
            Select Case Shapename
            Case "Bridge"
                bridge_handle = handle
                Set bridge_image.Picture = LoadPicture(LayerPath & "bridge.bmp")
                bridge_image.UseTransparencyColor = True
                bridge_image.TransparencyColor = RGB(255, 255, 255)
                Set Map1.UDPointType(bridge_handle) = bridge_image
                Map1.ShapeLayerPointSize(bridge_handle) = 1
                Map1.ShapeLayerPointType(bridge_handle) = ptUserDefined
                For shapenum = 0 To sf.numshapes - 1
                    LabelText = "List no. " & Trim(sf.CellValue(0, shapenum))
                    x = sf.Shape(shapenum).Point(0).x
                    y = sf.Shape(shapenum).Point(0).y
                    Map1.AddLabel bridge_handle, LabelText, RGB(0, 0, 0), x, y, hjCenter
                Next
Jan 30, 2012 at 8:16 AM
Edited Jan 30, 2012 at 8:17 AM

Change the following lines:

Set bridge_image.Picture = LoadPicture(LayerPath & "bridge.bmp")
..

Set Map1.UDPointType(bridge_handle) = bridge_image
Map1.ShapeLayerPointSize(bridge_handle) = 1
Map1.ShapeLayerPointType(bridge_handle) = ptUserDefined

 

to:

 

bridge_image.open(LayerPath & "bridge.bmp", MapWinGIS.ImageType.USE_FILE_EXTENSION, True)

..

sf.DefaultDrawingOptions.PointType = MapWinGIS.tkPointSymbolType.ptSymbolPicture sf.DefaultDrawingOptions.Picture = bridge_image
Feb 17, 2012 at 10:31 PM

spiral_, sorry for the delay in getting back. I've just implimented your code and SUCCESS!!!

Thank you so much for your help

 

Cheers'

Brian