the map cannot be shown on the web page

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

Hi

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");
       

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

 

thanks a lot

phil

 

Coordinator
Sep 11, 2009 at 11:22 AM

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 3:07 PM

Hi johndiss,

Thanks for your reply. But I think I already add 

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

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

Thanks

Phil

Coordinator
Sep 11, 2009 at 5:38 PM

Hi Phil, I dont really use the GDAL layer but it sounds like http://sharpmap.codeplex.com/WorkItem/View.aspx?WorkItemId=8873  and http://epsg27700.blogspot.com/2009/09/gdalrasterlayer-and-ordnance-survey.html may be relavent hth jd

Sep 14, 2009 at 3: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

 

Phil

 

Coordinator
Sep 14, 2009 at 4: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