Dysfunction on DataTablePoint provider

Topics: SharpMap v0.9 / v1.x
Jan 17, 2012 at 3:47 PM

Hello to All,

My map does not show any point on the mapimage, it is absolutely empty. It shows only the background according to preset color.(No error nor message.)

I use a datatable object as datasource, with filled up more than eight thousand point records. It has double type coordinate fields and integer type PId field as required by the DataTablePoint provider. I created a vectorlayer object and set its datasource to the datatable by the DataTablePoint provider, than I added it to the map.layers collection. I set  the layer.style.symbol property to a jpg picture file wich was picked up in my project resources.

The result still is an empty map image!

(for some more info, please refer my first discussion 'Version Conflict?')

My vb. code snippet:

Imports System
Imports System.Windows
Imports System.Windows.Forms
Imports System.Drawing
Imports SharpMap
Imports SharpMap.Layers.VectorLayer

Public Class Form1_Map

    Private myMap As New SharpMap.Map(New Size(400, 300))
    Private myLayer As New SharpMap.Layers.VectorLayer("Mylayer")
    Private MImage1 As New SharpMap.Forms.MapImage   'Picturebox control
    Private MBox1 As New SharpMap.Forms.MapBox       'MapBox control 

    Public Sub New(ByVal tblSou As System.Data.DataTable, ByVal oid As String, ByVal xColumn As String, ByVal yColumn As String)

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        myLayer.DataSource = New SharpMap.Data.Providers.DataTablePoint(tblSou, oid, xColumn, yColumn)

    End Sub

    Private Sub Form1_Map_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load


        myMap.Size = New System.Drawing.Size(500, 350)  '//Set output size
        myMap.MinimumZoom = 100  '//Minimum zoom allowed
        myMap.BackColor = Color.LightYellow  '//Set background
        myMap.Center = New SharpMap.Geometries.Point(7450000, 5036000)  '//Set center of map

        myLayer.MaxVisible = 40000
        myLayer.Style.Symbol = SqcMap.My.Resources.LL_Cog
        'myLayer.style.Fill = New SolidBrush(Color.Green)
        'myLayer.Style.Outline = System.Drawing.Pens.Black
        'myLayer.Style.EnableOutline = True

        myMap.Layers.Add(myLayer)
        myMap.ZoomToExtents()

        MImage1.Image = myMap.GetMap()

        MImage1.Dock = DockStyle.Fill
        MImage1.Location = New System.Drawing.Point(0, 0)
        MImage1.ActiveTool = SharpMap.Forms.MapImage.Tools.Pan
        MImage1.Size = New System.Drawing.Size(600, 400)
        MImage1.Refresh()

        Me.Controls.Add(MImage1)

        'Dim imgMap = myMap.GetMap()
        'Me.PictureBox1.Image = imgMap
        'Me.PictureBox1.Refresh()

    End Sub

End Class
Coordinator
Jan 17, 2012 at 9:21 PM

Please remove the minimum/maximum zoom value from the layer/map, since that may prevent the layer from rendering if your zoom level is not in the valid range.

Why do you use MapBox and MapImage in the same form? Please use MapBox and nothing else.
And please do not forget to assign your map to the MapBox instance (MBox1.Map = myMap).

Hth FObermaier