Multiple Lables

Hello, i try add multiple labels but i can’t, how is it the correct way?
Sorry for my English and thanks.
i try with sfMarcas.Labels.AddLabel(), but mi program it closed.

        Dim utils = New Utils()
        If (sfMarcas.CreateNewWithShapeID("", ShpfileType.SHP_MULTIPOINT) = False) Then
            MessageBox.Show("Fallo al crear sfMarcas: " + sfMarcas.ErrorMsg(sfMarcas.LastErrorCode()))
            Return False
        End If

        Dim options = sfMarcas.DefaultDrawingOptions
        options.PointType = tkPointSymbolType.ptSymbolPicture
        options.Picture = OpenMarker("")
        sfMarcas.CollisionMode = tkCollisionMode.AllowCollisions
        sfMarcas.Labels.Clear()
        _mDrawingHandle = AxMap1.NewDrawing(tkDrawReferenceList.dlScreenReferencedList)
        sfMarcas.Labels = AxMap1.get_DrawingLabels(_mDrawingHandle)
        sfMarcas.Labels.FrameVisible = True
        sfMarcas.Labels.FrameType = tkLabelFrameType.lfRoundedRectangle
        sfMarcas.Labels.FrameBackColor = utils.ColorByName(tkMapColor.AliceBlue)
        sfMarcas.Labels.FrameTransparency = 200

        If (sflineas.CreateNew("", ShpfileType.SHP_POLYLINE) = False) Then
            MessageBox.Show("Fallo al crear sflineas:: " + sflineas.ErrorMsg(sflineas.LastErrorCode()))
            Return False
        End If
        Dim shpMarcas = New Shape()
        shpMarcas.Create(ShpfileType.SHP_MULTIPOINT)
        Dim shpLineas = New Shape()
        shpLineas.Create(ShpfileType.SHP_POLYLINE)
        For x = 0 To 10
            If (ds.Tables("MarcasUbicacion").Rows(x).Item("Latitud").ToString <> "" And Double.TryParse(ds.Tables("MarcasUbicacion").Rows(x).Item("Latitud").ToString, lat) And ds.Tables("MarcasUbicacion").Rows(x).Item("Longitud").ToString <> "" And Double.TryParse((ds.Tables("MarcasUbicacion").Rows(x).Item("Longitud").ToString), lat)) Then
                Dim pnt = New MapWinGIS.Point()
                pnt.y = Val(ds.Tables("MarcasUbicacion").Rows(x).Item("Latitud"))
                pnt.x = Val(ds.Tables("MarcasUbicacion").Rows(x).Item("Longitud"))

                Dim Index = shpMarcas.numPoints
                shpMarcas.InsertPoint(pnt, Index)
                Index = sfMarcas.NumShapes
                Here my problem
                sfMarcas.Labels.AddLabel("prueba", pnt.x, pnt.y, 0.0, -1)


                Index = shpLineas.numPoints
                shpLineas.InsertPoint(pnt, Index)
                Index = sflineas.NumShapes
            End If
        Next
        If (sfMarcas.EditInsertShape(shpMarcas, 0) = False) Then
            MessageBox.Show("Failed to insert shape: " + sfMarcas.ErrorMsg(sfMarcas.LastErrorCode))
            Return False
        End If

        handlayerMarcas = AxMap1.AddLayer(sfMarcas, True)
        If (sflineas.EditInsertShape(shpLineas, 0) = False) Then
            MessageBox.Show("Failed to insert shape: " + sflineas.ErrorMsg(sflineas.LastErrorCode))
            Return False
        End If

        Dim pattern = New LinePattern()
        pattern = New LinePattern()

        pattern.AddLine(utils.ColorByName(tkMapColor.LightBlue), 5.0F, tkDashStyle.dsSolid)
        sflineas.DefaultDrawingOptions.LinePattern = pattern
        sflineas.DefaultDrawingOptions.UseLinePattern = True
        handlayerLineas = AxMap1.AddLayer(sflineas, True)

You’re mixing shapefile labels and drawinglayer labels:
sfMarcas.Labels = AxMap1.get_DrawingLabels(_mDrawingHandle)

You should use sf.Labels.Generate()

More handy links:

1 Like

Thanks @pmeems, i have a cuestion, is it possible add the label (tooltip) at point mark? and not at the shape, or create a shape of labels.
I want to do same in Mapwingis, thanks
This is Gmap control

Dim markador = New GMarkerGoogle(New PointLatLng(LatInicial, LngInicial), My.Resources.LogoEdit3)
markador.ToolTipText = “Prueba”
markador.ToolTipMode = MarkerTooltipMode.OnMouseOver

Have a look at this example: https://www.mapwindow.org/documentation/mapwingis4.9/_tool_tip_8cs-example.html

1 Like