This project has moved and is read-only. For the latest updates, please go here.

the map cannot be shown on the web page

Topics: Web Controls
Sep 10, 2009 at 6:39 PM
Edited Sep 10, 2009 at 6:49 PM


I am new to the SharpMap and just create a simple page to show the map. it seems dose not work.

no error message but the image cannot be shown on the web page.

dose anyone can help me to figure it out?


here is the code:

        SharpMap.Map myMap = new SharpMap.Map(new Size(400, 300));
        myMap.BackColor = Color.White; //Set background
        myMap.Size = new System.Drawing.Size(300, 200); //Set output size

        SharpMap.Layers.GdalRasterLayer testlayer = new SharpMap.Layers.GdalRasterLayer("test", "C:\\Downloads\\sharpmap-57305\\Trunk\\DemoWebSite\\london.jpg");

        System.Drawing.Image img = myMap.GetMap();
        string imgID = Caching.InsertIntoCache(1, img);
        imgMap.ImageUrl = "getmap.aspx?ID=" + HttpUtility.UrlEncode(imgID);


thanks a lot



Sep 11, 2009 at 12:22 PM

Hi Phil, make sure the getmap.aspx url is mapped appropriately - see the httpHandlers section of web.config in the demo project and create an equivalent in your project.. hth jd

Sep 11, 2009 at 4:07 PM

Hi johndiss,

Thanks for your reply. But I think I already add 

      <add verb="*" path="GetMap.aspx" type="SharpMap.Web.HttpHandler,SharpMap"/>

to the web.config file.

i am using

System.Drawing.Image img = myMap.GetMap();
        img.Save("c:\\ddd.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

to save the image to the hard disk and the image is black.

do you have any suggestions



Sep 11, 2009 at 6:38 PM

Hi Phil, I dont really use the GDAL layer but it sounds like  and may be relavent hth jd

Sep 14, 2009 at 4:17 PM

Hi johndiss

another quick question, is it possible that i just show a normal jpg file as a map using sharpmap?

Thanks  lot




Sep 14, 2009 at 5:22 PM

Hi Phil, I haven't tried but I would assume you could as long as the jpeg was georeferenced - but this would still be done via GDAL hth jd