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

Scrollbars around Map

Topics: SharpMap v0.9 / v1.x, Web Controls
Jan 20, 2009 at 9:27 AM

I using 0.9 version in .net 2.0 web application. When I select zoom in tool and click any where in map, it zoom in. I can see more details on map but some part of map disappear. Pan tool is there but can I use Scroll bars around map, so that I can view complete map with of help of scroll bars.

Jan 20, 2009 at 10:26 AM
I am not aware of anyone doing this with sharpmap, though I have seen it in some other gis apps. You would have to code this yourself hth jd
Jan 20, 2009 at 10:31 AM

Thanks for reply. Can you please provide some tips to implement this functionality?
Jan 20, 2009 at 11:22 AM
Perhaps you could start with creating some scrollbar-esque or slider controls and use them to navigate. When zooming in you will calculate the extents of your whole map in pixels and apply some scaling function to set the min and max values of your slider and position the slider handle appropriately. Add delegate handlers to the slider handles' moved events and use these to re-center the map appropriately before rerendering the map. Warning - this will be extremely sensitive when zoomed in on a large map as the relative scale of real world units to slider pixel will be very large - _it may be unusable_. hth jd
Jan 23, 2009 at 11:43 AM

I have vb6 based application which generates shape file. I load these shape files on web application based on SharpMap 0.9. Some time generated application throughs following exception

<title>Unable to read beyond the end of the stream.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } </style>

Unable to read beyond the end of the stream.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

System.IO.EndOfStreamException: Unable to read beyond the end of the stream.

Source Error:

Line 313:        ViewState.Add("mapZoom", map.Zoom);
Line 314:        //Render map
Line 315:        System.Drawing.Image img = map.GetMap();
Line 316:        
Line 317:        string imgID = SharpMap.Web.Caching.InsertIntoCache(1, img);

Source File: c:\Inetpub\wwwroot\WebGIS\Default.aspx.cs    Line: 315

Stack Trace:

[EndOfStreamException: Unable to read beyond the end of the stream.]
   System.IO.__Error.EndOfFile() +54
   System.IO.BinaryReader.FillBuffer(Int32 numBytes) +2761208
   System.IO.BinaryReader.ReadInt32() +47
   SharpMap.Data.Providers.ShapeFile.GetShapeIndex(UInt32 n) +42
   SharpMap.Data.Providers.ShapeFile.ReadGeometry(UInt32 oid) +54
   SharpMap.Data.Providers.ShapeFile.GetGeometryByID(UInt32 oid) +32
   SharpMap.Data.Providers.ShapeFile.GetGeometriesInView(BoundingBox bbox) +143
   SharpMap.Layers.VectorLayer.Render(Graphics g, Map map) +753
   SharpMap.Map.GetMap() +407
   _Default.GenerateMap() in c:\Inetpub\wwwroot\WebGIS\Default.aspx.cs:315
   _Default.Page_Load(Object sender, EventArgs e) in c:\Inetpub\wwwroot\WebGIS\Default.aspx.cs:305
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Jan 23, 2009 at 12:00 PM
It looks like the index file is shorter than expected, possibly corrupt. Do the shapefiles open in other apps? cheers jd
Jan 23, 2009 at 12:29 PM
Yes it is successfully loaded by other applications.
Jan 23, 2009 at 2:01 PM
When loaded in other apps, are all the expected fetaures there or are some missing?
Jan 26, 2009 at 4:49 AM
Yes Loading all features. Please provide your email to me so that I can send you shape files.
Jan 26, 2009 at 11:00 AM
Using the data you sent me, I recieved the same output as your 'other app' image and did not get the exception above. cheers jd
Jan 27, 2009 at 10:57 AM
Edited Jan 27, 2009 at 11:10 AM
John Thanks for reply

What is purpose of Shape.shp.sidx file. This file is created in shape folder as I load shape files in web application. Deleting this file removes exception a number of time.  

Jan 27, 2009 at 12:07 PM
Hi Sheraz, sidx is a spatial index file, you can disable it by using the constructor 
public ShapeFile(string filename, bool fileBasedIndex)
and setting fileBasedIndex = false.

Are you serving tiles? I wonder if you are getting 2+ w3p processes attempting to write the sidx file at the same time and ending up with a corrupted file.
hth jd
Jan 27, 2009 at 12:19 PM
Hi John
No sure about Tiles as donot have any knowlege about it.
Now related to spatial index. When ever I have new data, I copy shape files to web application folder. Now here old spatial index file create problem.
Jan 27, 2009 at 12:36 PM
I see, so the old sidx file is pointing to records that no longer exist in the new shapefile.. hence 'Unable to read beyoyn the end of the stream'.
Using a sidx file should improve the performance and a new one will be created if fileBasedIndex is true. So it seems the best solution is to use a fileBasedIndex but ensure that the old sidx file is deleted everytime new data is created.. cheers jd