[GIS] Slippy map format

geoserverleafletmapboxopenstreetmapwms

When do you decide which to use? I've started using Geoserver and it seems like map files are downloaded to the browser (using Leaflet) in the WFS format.

When I look at OSM, Mapbox etc, they use what I believe is the slippy map format: /zoom/x/y.png 256×256 tiles.

Should Geoserver be configured to use slippy map format? And will using WMS prevent slippy map interactions like Google maps and Leaflet?

What are your recommendations if I'm using Geoserver and Leaflet and want to serve some map tiles.

Best Answer

I think what you want to do is make a slippy map, right?

This is very easy with Leaflet and GeoServer, so long as you only want to view information.

In GeoServer, style a layer, and test it. Then, with Leaflet, add the layer from GeoServer via WMS. Example is included below, replace all the with your values:

<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />
<!--[if lte IE 8]>
 <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.ie.css" />
<![endif]-->

<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>

<div id="map"  style="width: 800px; height: 600px"></div>

<script>
    var center = new L.LatLng(<LAT>,<LON>);
    var map = new L.Map('map', { center: center, zoom: 14, attributionControl:true, zoomControl:false});   
    var gi = new L.TileLayer.WMS("http://<SERVER>:8080/geoserver/gwc/service/wms", {
        layers: '<WORKSPACE>:<LAYER NAME>',
        format: 'image/png',
        maxZoom: 20
    }).addTo(map)
</script>

If you actually want vectors, consider carefully why. You can achieve it using tileJSON, but it isn't simple. You can query the WMS layer, though, and highlight individual features, which is quite nice!

Related Question