[GIS] Publish a Leaflet map with vector overlay on a WMS server (e.g. GeoServer)

geoserverleafletmapproxywms

Is it possible to set up a WMS server (I am a bit familiar with GeoServer so this would be my preferred option but of course I'm open to learn something new…) that publishes an instance of a Leaflet map together with some vector overlays (e.g. GeoJSON, shapefile, whatever..)? Or am I mixing up things completely here because maps created in JavaScript cannot be published like this?

This would be nice to have for my usecase as I have set up a nice map with Leaflet which receives map tiles from our company's own tile server, does some styling, uses Leaflet plugins to display interesting stuff etc.

I would like to do some automated GetMap requests on that map for bounding box extents that I generate programmatically and save the resulting images to disk.

The closest I could think of would be to use MapProxy to combine my custom tile layer with my vector overlays (directly or prepared by and connected through GeoServer) and publish that as a WMS server. However, this would lack the styling and plugin stuff that I can do in Leaflet.

Best Answer

I think you are mixing up a couple of things.

When you install Geoserver, it comes with a lite distribution of OpenLayers. That is used to preview the data once you publish some. But this functionality is only suitable for previewing, and not as a production front-end.

If you want a Production quality front end, you need to develop that yourself. You can use any client which supports Geoserver's OGC Services( i.e. WMS, WFS etc).

Many people use OpenLayers as a JavaScript Library for this, or you could also use Leaflet.

There are many examples on this site which talk about doing so, for example: Combine Leaflet with Geoserver WMS map

If your Geoserver or data cannot be projected in Web Mercator, then you can us a Leaflet plugin called Proj4Leaflet, which can display a Map in projections other than Web Mercator. See this example.