Hi there!
I was coding a little bit.
What I want to do is, get some Pois from a db and show them into the map. Pretty similar to the cartracks example. In fact I recode it in VB to understand some issues.
Now, some is wrong with the shapefile categories, because I can’t select them.
In other hand if a poi position or status change (the label text never change) but change in change the label position because is part of the Poi, how I identify every poi? I was using the index for this but the label moves but not the poi image.
What shows at map is this:
What I’m doing wrong?
Best Regards!
Private Sub InitMap()
Map1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR
Map1.TileProvider = tkTileProvider.OpenStreetMap
Map1.KnownExtents = tkKnownExtents.keAustralia
Map1.CursorMode = cmZoomIn
Map1.Latitude = 0
Map1.Longitude = 0
Map1.CurrentZoom = 0
End Sub
Private Sub CreateallPoi()
Dim myPoi(5) As Poi
Dim i As Integer
For i = 0 To 4
myPoi(i).LabelText = "LabelPOI N: " & i
myPoi(i).Lon = 0
myPoi(i).Lat = i * -10
myPoi(i).Catergory = i
myPoi(i).Status = i
myPoi(i).Visible = True
Next
Dim objPoi As Shapefile
For i = 0 To 3
Set objPoi = CreatePiontSF(myPoi(i))
Map1.AddLayer objPoi, True
Next
Map1.Redraw
Map1.CurrentZoom = 3
End Sub
Private Function CreatePiontSF(mapPoi As Poi) As Shapefile
Dim sf As New Shapefile
Dim ct As ShapefileCategory
Dim opt As ShapeDrawingOptions
Dim pic As New MapWinGIS.Image
Dim utils As New utils
Dim lb As LabelCategory
Dim i As Integer
Dim X1 As Double, Y1 As Double
Map1.DegreesToProj mapPoi.Lon, mapPoi.Lat, X1, Y1
sf.CreateNew "", SHP_POINT
sf.DefaultDrawingOptions.AlignPictureByBottom = False
Set ct = sf.Categories.Add("Apagado")
Set opt = ct.DrawingOptions
opt.PointType = ptSymbolPicture
pic.Open App.Path & "\icon_gray.png", PNG_FILE
opt.Picture = pic
opt.Visible = True
Set ct = sf.Categories.Add("Encendido")
Set opt = ct.DrawingOptions
opt.PointType = ptSymbolPicture
pic.Open App.Path & "\icon_blue.png", PNG_FILE
opt.Picture = pic
opt.Visible = True
Set ct = sf.Categories.Add("GpsEnLinea")
Set opt = ct.DrawingOptions
opt.PointType = ptSymbolPicture
pic.Open App.Path & "\icon_orange.png", PNG_FILE
opt.Picture = pic
opt.Visible = True
sf.Labels.FrameVisible = True
sf.Labels.TextRenderingHint = tkTextRenderingHint.ClearTypeGridFit
Set lb = sf.Labels.AddCategory("Busy")
lb.FrameBackColor = utils.ColorByName(tkMapColor.OrangeRed)
Set lb = sf.Labels.AddCategory("Available")
lb.FrameBackColor = utils.ColorByName(tkMapColor.Green)
Set lb = sf.Labels.AddCategory("OutOfService")
lb.FrameBackColor = utils.ColorByName(tkMapColor.Gray)
'Some problem is here, sf.Category don't change the shape image, remains in the last loaded
'For i = 0 To 5
i = 0
Dim shp As New MapWinGIS.Shape
shp.Create (ShpfileType.SHP_POINT)
shp.AddPoint X1, Y1
sf.EditAddShape shp
sf.ShapeCategory(i) = i
sf.Labels.AddLabel mapPoi.LabelText, X1, Y1
sf.Labels.Label(i, 0).Category = i
'Next
Debug.Print "Pio categories: " & sf.Categories.Count 'this show 3
Debug.Print "LBL categories: " & sf.Labels.NumCategories 'this show 3
Set CreatePiontSF = sf
'here must destroy all the objects
End Function