0

Recently I am using Geoserver grammatically through its REST api. When I request for a map it gives me a map image.

My request code is like this:

public string GetMap(string name)
            {
                WebRequest req = WebRequest.Create("http://localhost:8888/geoserver/wms/reflect?layers=" + name);

                using (WebResponse resp = req.GetResponse())
                {
                    FileStream imageStream;
                    using (imageStream = new FileStream(@"E:\image.png", FileMode.OpenOrCreate))
                    {
                        var responseStream = resp.GetResponseStream();
                        if (responseStream != null) responseStream.CopyTo(imageStream);
                    }
                }
                return @"E:\image.png";
            }

It gives me an image like this:

enter image description here

But i need the whole control of Geoserver map like zooming or others:

the whole map control

How can i do that?

2

Add &format=application/openlayers to your reflector URL, it will give you back the usual preview. Some docs here: http://docs.geoserver.org/stable/en/user/tutorials/wmsreflector.html

0

The image of the "whole control" is the OpenLayers client, not really GeoServer. To use openlayers (which is in Javascript), you'd need a JS interpreter.

If you want a C# control for a thick client or ASP.NET application, take a look at:

Those are alternatives ways to access the WMS/WMTS/etc APIs (which is what you are really doing with your WebRequest GET, and what OpenLayers does).

Which of the C# alternatives will meet your needs depends on what you need to do (which would have been good to put in the question, perhaps next time). I'd start with SharpMap.

  • Thanks, I am going through your links, then I will give you feedback. – Moshii Mar 2 '14 at 6:28
  • You given links are above my level, so i gave up. – Moshii Mar 2 '14 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.