Could not get map to display in the demo

Feb 20, 2014 at 1:49 AM
Hello everyone, I am new to this, so really need your help. I have this code which I converted into from the demo website:
Private myMap As SharpMap.Map

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        'Set up the map
        myMap = InitializeMap(New System.Drawing.Size(CInt(imgMap.Width.Value), CInt(imgMap.Height.Value)))
        If Page.IsPostBack Then
            'Page is post back. Restore center and zoom-values from viewstate
            myMap.Center = DirectCast(ViewState("mapCenter"), GeoAPI.Geometries.IPoint)
            myMap.Zoom = CDbl(ViewState("mapZoom"))
            'This is the initial view of the map. Zoom to the extents of the map:
            'Save the current mapcenter and zoom in the viewstate
            ViewState.Add("mapCenter", myMap.Center)
            ViewState.Add("mapZoom", myMap.Zoom)
            'Create the map
        End If
    End Sub

    Protected Sub imgMap_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
        'Set center of the map to where the client clicked
        myMap.Center = SharpMap.Utilities.Transform.MapToWorld(New System.Drawing.Point(e.X, e.Y), myMap)
        'Set zoom value if any of the zoom tools were selected
        If (rblMapTools.SelectedValue = "0") Then
            myMap.Zoom = (myMap.Zoom * 0.5)
        ElseIf (rblMapTools.SelectedValue = "1") Then
            myMap.Zoom = (myMap.Zoom * 2)
        End If
        'Save the new map's zoom and center in the viewstate
        ViewState.Add("mapCenter", myMap.Center)
        ViewState.Add("mapZoom", myMap.Zoom)
        'Create the map
    End Sub

    Private Function InitializeMap(ByVal outputsize As System.Drawing.Size) As SharpMap.Map
        'Initialize a new map of size 'imagesize'
        Dim map As SharpMap.Map = New SharpMap.Map(outputsize)
        'Set up the countries layer
        Dim layCountries As SharpMap.Layers.VectorLayer = New SharpMap.Layers.VectorLayer("State")
        'Set the datasource to a shapefile in the App_data folder
        layCountries.DataSource = New SharpMap.Data.Providers.ShapeFile(Server.MapPath("~\App_data\states_ugl.shp"), True)
        'Set fill-style to green
        layCountries.Style.Fill = New SolidBrush(Color.Green)
        'Set the polygons to have a black outline
        layCountries.Style.Outline = System.Drawing.Pens.Black
        layCountries.Style.EnableOutline = True
        Return map
    End Function

    Private Sub CreateMap()
        Dim img As System.Drawing.Image = myMap.GetMap
        Dim imgID As String = SharpMap.Web.Caching.InsertIntoCache(1, img)
        imgMap.ImageUrl = ("GetMap.aspx?ID=" + HttpUtility.UrlEncode(imgID))
    End Sub
Here is my code in the web.config file:
      <compilation debug="false" strict="false" explicit="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
      <add verb="*" path="GetMap.aspx" type="SharpMap.Web.HttpHandler,SharpMap.Web" />
    <validation validateIntegratedModeConfiguration="false"/>
The code doesn't throw any error but the map doesn't show up in the image. What did I miss? I have spent so much time trying to figure out why but no luck. So please help me out. I use Sharpmap 1.1 and also add sharpmap.web reference to my web application.

Feb 20, 2014 at 3:11 AM
I am not sure what's going on. I tried to recreate the demo website in C# just to make sure that I am not missing anything in Copy the exact same code from the demo project and ran it. Still it doesn't show me the map from the shapefile. Exact same code. Test the demo website and it is working. Anyone knows what's going on?

Thanks a lot.
Aug 19, 2014 at 2:33 PM
Did you ever get this figured out... same code and it only displays a X"