map rendering

Topics: General Topics, SharpMap v0.9 / v1.x
Oct 11, 2011 at 4:48 PM


I have a lot of geometries on the map, so it's rendering slowly.

I'm thinking is there a way to render invalidation part only of the whole map when I'm using a pan tool to move the map.

What I mean is when I zoom to a particular zoom of the map. The part of map that I move out of screen will still exist. So next time I move to this part, I do not need to render it again and that will improve the speed.

I think google map is using this tech. I'm using SharpMap 0.9 Mapbox samples


Oct 12, 2011 at 5:00 AM
Edited Oct 12, 2011 at 5:01 AM


Google's map and some webmap use title cache for rendering images of map.

SharpMap can also save title cache. Pleased view:

Now, SharpMap haven't created cached layer but you can save title layer ( above) and use titlelayer class on sharpmap for cache layer



Oct 12, 2011 at 10:59 AM


I've tried to use a cache and that improve a lot the rending (during zooming, ranning,...) it's about 3 or 4 times faster, depends on, of course, of the layer. I made the test on 30 000 geoms.

I used this code in SQLServer2008.cs

     Collection<Geometry> _features = new Collection<Geometry>();
        Collection<BoundingBox> _fBB = new Collection<BoundingBox>();
        /// <summary>  
        /// Returns geometries within the specified bounding box  
        /// </summary>  
        /// <param name="bbox"></param>  
        /// <returns></returns>  
        public Collection<Geometry> GetGeometriesInView(BoundingBox bbox)
           -----if the datas already loaded
         if (_features.Count > 0)
               Collection<Geometry>  featuresBB = new Collection<Geometry>();
                for (int i = 0; i < _features.Count; i++)
                if (_fBB[i].Intersects(bbox))
                return featuresBB;

-------- Loading geom from database -> the first time

                                 Geometry geom = Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr[0]);
                                 if (geom != null)

------ return the feature

It's not realy optimising and shouldn't use like this in a real application (I done this code only for test).


@TrieuVy: Tile layer is for raster layaer , isn't it ? Is is possible to use Tile layers on vectors ?


Oct 13, 2011 at 1:34 AM

Hi Eric,

we can create title layer from vector layers . Follow me title layer is static vector layers. Title layer is good when you only use to show map ( read only ).

sharp map have both title layer and vevtor layer. We can add a lot of layers in Sharmap


Oct 13, 2011 at 11:22 AM

Hi, trieuvy

Thanks a lot,  I will try it.

And can I use this method to cache the the google map background so that when I am offline I still can use google map images

Oct 14, 2011 at 2:01 AM
Edited Oct 14, 2011 at 2:07 AM


Check committed version 93263  added support cached files title layer