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

Sharpmap & Openlayers

Topics: SharpMap v2.0, Web Controls
Oct 18, 2007 at 9:25 AM
Hello list,

Is there anyone out there who has set up a succesfull implementation of Sharpmap with openlayers and AJAX? We prefer this as a more standarized approach then the AJAXmap sample. Please contact me, I am even considering contracting an expert on this part so if you are, let me know!
Oct 18, 2007 at 9:25 AM
P.S If we come up with a generic integration, it will be donated back to sharpmap. Even if it is a commercial contracted research project.
Oct 18, 2007 at 10:38 PM
I haven't do it myself (I did something similar using kaMap) but I think you have at least two ways to integrate SharpMap to OpenLayers:
  1. Using WMS: SharpMap and OpenLayers support it.
  2. Using SharpMap to generate tiles a la Google Maps (see this example with Virtual Earth and then OpenLayers. Layer.TMS with a proper getURL function.

Best regards,
Ricardo Stuven.
Oct 19, 2007 at 8:56 AM
I am using option 1 allready, this works excellent.

But I need integration with server side script and this is a topic I am not good at.

So basically, I am looking for a ajax developer that is willing to build this functionallity (paid) so we can use it in our businesscase and donate a sharpmap - openlayer integration back to this community.

Oct 22, 2007 at 5:01 AM
If you using the OpenLayers.Layer.WMS, you need to modif the WmsServer in SharpMap to to handle WMS 1.1.1, because the openlayers only support the WMS 1.1.1

You also can create you own http handler for the your custom layer extend to OpenLayers.Layer.
Oct 22, 2007 at 8:11 AM
I already posted a change set with 1.0.0 and 1.1.1 WMS support. But no, I am not going to use Sharpmap as a WMS server only. I want to make use of the available functionallity and use it's own layers and click events so I need a developer...
Sep 11, 2008 at 5:15 AM
So has anyone made progress on OpenLayers/SharpMap integration?

This thread is almost a year old now and there has surely been progress on this.  Anyone care to share?

Sep 11, 2008 at 10:38 AM
I have made a start on something which will create the OpenLayers javascript from while trying to follow the ajax style, unfortunately there are issues with initializing js objects through the ms $create system.
At some point i will try to redevelop it writing plain OL javascript which should be easier to
a) do
b) keep current with openlayers releases.

The current one is called sharplayers and can be found in the sharpmapwebmerge branch of the svn. It doesnt have server side handlers  though and involved modifying the openlayers code.
There is also a GeoJson renderer which creates json which can be consumed by OL vector layers though it needs a bit of wiring to do so.. hth jd
Sep 16, 2008 at 4:19 AM
hi, milovanderlinden
you can code like this:
var wmsLayer = new OpenLayers.Layer.WMS( "WmsLayer",
            {layers: "PrimiaryRoad,PrimiaryRoadLabel,SubordinateRoadLabel,SubordinateRoad,"+
            format: "image/jpeg", request: "GetMap", CRS: "EPSG:4326",
            BBOX: "-180, -90, 180, 90", WIDTH: "600", HEIGHT: "300",
            BGCOLOR: "0XF5F1E6",
            version: "1.3.0"});
add layer to map. then openlayers will get wms map automatically. :-)
Mar 4, 2010 at 9:02 PM

It works for me!

var wmsLayer = new OpenLayers.Layer.WMS( "WmsLayer",
            {layers: "PrimiaryRoad,PrimiaryRoadLabel,SubordinateRoadLabel,SubordinateRoad,"+
            format: "image/jpeg", request: "GetMap", CRS: "EPSG:4326",
            BBOX: "-180, -90, 180, 90", WIDTH: "600", HEIGHT: "300",
            BGCOLOR: "0XF5F1E6",
            version: "1.3.0"});

Very very nice!!! my first map!  wuauuuuuu

But now just a question...  what about CACHE of the tile that Open Layer ask every time to my brand new WMS Server?

There is something of ready off the shelf proxy that make cache for me....  in the end...  each tile asked from open layer to wms i hope is in the same "box" more or less..  so it can be cached !


In this way...   niiiiiceeee...  i can cache base map layer and ask every time just some few points with status up-to date on every request!  

Mar 5, 2010 at 1:42 AM

Hi sandex, have a look at or  you could customise the handler to cache for you. hth jd

Mar 5, 2010 at 8:45 AM


you can also use this:

with the Virtual Earth TileServer you can cache WMS-services. Or you write a SharpMap tile provider, so you don't need to provide your own WMS.


Mar 11, 2011 at 12:33 PM

Dear All,

I am new to sharpmap and openlayer. I tried the following code to load map from sharpmap wms to openlayer.

But it doesnot work. Pls suggest  a solution.

	function init() {

            map = new OpenLayers.Map('map');

              var wmsLayer = new OpenLayers.Layer.WMS("WmsLayer",
            { layers: "Countries,Rivers,Country labels",
                format: "image/jpeg", request: "GetMap", CRS: "EPSG:4326",
                BBOX: "-180, -90, 180, 90", WIDTH: "500", HEIGHT: "200",
                BGCOLOR: "0XF5F1E6",
                version: "1.3.0"


            map.addControl(new OpenLayers.Control.LayerSwitcher());
Mar 14, 2011 at 9:50 AM

I suppose that OpenLayers shows you the error images instead of the images you want?

Then get the url of this image and try to open it directly in your browser.

You will get a XML error message which will get you further.

Mar 16, 2011 at 5:56 AM
Edited Mar 16, 2011 at 7:02 AM

Thanks to your reply,

In this case no error is showing ,but the image is not showing in  open layer.

But when I open the url directly in browser the image is displaying without any issue.

Is this because of proxy ?

Pls suggest me a solution.

Mar 16, 2011 at 8:59 AM
Edited Mar 16, 2011 at 12:27 PM

Dear All

I solved the problem.

The error was in the line ...


Replaced it with


Now the image is displaying. But the tiles are displaying in wrong order when zooming.

Pls suggest me a solution to this.




Mar 16, 2011 at 1:21 PM
Edited Mar 16, 2011 at 1:21 PM

I got solution to the problem from the link.



Jun 27, 2011 at 7:52 AM

Hi i am jaffar from coimbatore. i am using sharp map with ajax map control. i want to know how to set progress layer (status ) on ajaxmap. for example while i am trying to "zoom in" or "zoom out"

the mape generating image by downloading shapfile, on that time i need to display some text to user like please wait "Map generating...". 


please help me..


thanks in advance

M. Jaffar Ali