VDS Technologies

 

How to Add Marker from Spatial MSSQL?

8/26/2012 2:24:15 PM
Total Posts 50

How to Add Marker from Spatial MSSQL?

I Have problem with Mark layer from Spatial MSSQL Server. Can you check with this code, which wrong ?

Markers not occurs, only spatial data occurs.

 

Protected Sub AddMarkLay(ByVal map As AspMap.Web.Map)
map.Callouts.Clear()

Dim sqlSelect As String = "SELECT *, SP_geometry.STAsBinary() AS WkbGeometry FROM WTP"
Dim connectionString As String = "Data Source=GIS-LAPTOP\ATBGISMAPDB;Initial Catalog=ATBGISMAPDB;Integrated Security=SSPI;Trusted_Connection=Yes"

Dim adapter As SqlDataAdapter = New SqlDataAdapter(sqlSelect, connectionString)
Dim dataTable As DataTable = New DataTable()

adapter.Fill(dataTable)
adapter.Dispose()

Dim Points As AspMap.Layer = map.AddSpatialDataLayer(dataTable, "WkbGeometry")
Points.CoordinateSystem = CoordSystem.WGS1984
Dim rs As AspMap.Recordset = Points.SearchExpression("category=""WTP""")

If rs.EOF Then
Return
End If
' add markers

Dim maxRecords As Integer = rs.RecordCount

For record As Integer = 0 To maxRecords - 1
If rs.EOF Then ' no more records
Exit For
End If

'Dim position As AspMap.Point = rs.Shape.GetPoint(0)
Dim Position As AspMap.Point = rs.Shape.WkbData

Dim image As MarkerSymbol = New MarkerSymbol("symbol/Dam.png", 19, 31)

'Dim tooltip As String = "<b>WTPID:</b> " & rs("MI_Prinx") & "<br><b>Name WTP:</b> " & rs("Name") & "<br><b>Capacity:</b> " & rs("Capacity") & "<b>LPS</b>" & "<br/><img src=""Data/Photo/WTP/" & rs("Imagelink1") & """ width=""100"" heigth=""150""> " & "<img src=""Data/Photo/WTP/" & rs("Imagelink2") & """ width=""100"" heigth=""150""> "

map.TooltipStyle.BackColor = Color.Red
map.TooltipStyle.Width = Unit.Pixel(250)
map.TooltipStyle.Height = Unit.Pixel(200)
map.TooltipStyle.BackColor = Color.Beige
map.TooltipStyle.Font.Size = 12

Dim tooltip As String = "<b>Name WTP:</b> " & rs("Name") & "<br>Capacity:</b> " & rs("Capacity") & "<b>LPS</b>" & "<br/><img src=""Data/Photo/WTP/" & rs("Imagelink1") & """ width=""100"" heigth=""150""> " & "<img src=""Data/Photo/WTP/" & rs("Imagelink2") & """ width=""100"" heigth=""150""> "
'Dim tooltip As String = rs("NAME").ToString()

'Dim html As String = "<b>" & rs("NAME").ToString() & "</b><br/>" & "TES" & "<br/><img src=""SYMBOLS/building.gif"">"
Dim html As String = "<DIV id='infoWindow'>" & "<b>WTPID:</b> " & rs("MI_Prinx") & "<br><b>Name WTP:</b> " & rs("Name") & "<br>Capacity:</b> " & rs("Capacity") & "<b>LPS</b>" & "<br/><img src=""Data/Photo/WTP/" & rs("Imagelink1") & """ width=""100"" heigth=""150""> " & "<img src=""Data/Photo/WTP/" & rs("Imagelink2") & """ width=""100"" heigth=""150""> " & "</Div>"

Dim marker As AspMap.Web.Marker = New AspMap.Web.Marker(map.CoordinateSystem.FromWgs84(position), image, tooltip, html)

map.Markers.Add(marker)

rs.MoveNext()

Next record

End Sub

8/28/2012 12:05:21 PM
MVP
Total Posts 323

Re: How to Add Marker from Spatial MSSQL?

The code looks correct. But, to answer your question, we have to debug it.

Please submit a support ticket from your Customer Area and include the project with data.