1

In Geoserver I have a layer based on SQL view. I enabled WMS direct integration in GeoWebcache and I enabled caching in layer.

In Google Maps javascript API I add a layer in this way. Layer is projected, but caching not happens:

var wmsLayer =
new google.maps.ImageMapType({
getTileUrl: function (coord, zoom) {

    var s = Math.pow(2, zoom);
    var twidth = 256;
    var theight = 256;

    //define boundingbox
    var gBl = cmap.getProjection().fromPointToLatLng(
        new google.maps.Point(coord.x * twidth / s, (coord.y + 1) * theight / s)); //zuidwest coördinaat
    var gTr = cmap.getProjection().fromPointToLatLng(
        new google.maps.Point((coord.x + 1) * twidth / s, coord.y * theight / s)); //noordoost coördinaat

    var bbox = gBl.lng() + "," + gBl.lat() + "," + gTr.lng() + "," + gTr.lat();

    //basics WMS URL
    var url = "http://geoserver.xxx.be/geoserver/rcs/wms?";

    url += "&service=WMS";
    url += "&version=1.1.0";
    url += "&request=GetMap";
    url += "&layers=rcs:rcs-sql-server-source-with-parameters-public";
    url += "&styles=";
    url += "&format=image/png";
    url += "&TRANSPARENT=TRUE";
    url += "&srs=EPSG:4326";
    url += "&bbox=" + bbox;
    url += "&width=256";
    url += "&height=256";
    url += "&customheader=" + new Date().getTime();
    url += "&viewparams=kind:bike;groupid:1";
    url += "&tiled=true";

    return url;
},

tileSize: new google.maps.Size(256, 256),
opacity: 0.85,
isPng: true
});
3
  • Does it create cache if you use the demo viewer from /geoserver/gwc?
    – user30184
    Commented Apr 1, 2017 at 13:52
  • Yes, then cache is created. But demo doesn't use viewparams, only default parameters. So when I don't add viewparams parameter to wms URL, cache is created. I use GeoServer 2.10, maybe I have to upgrade to 2.11?
    – Sven Nijs
    Commented Apr 1, 2017 at 14:52
  • 1
    Would it make sense to create cache with view parameters? Then you would need a separate cache for each parameter combination. But I can't say what GeoServer is supposed to do.
    – user30184
    Commented Apr 1, 2017 at 15:18

1 Answer 1

1

You need to declare the viewparams as a "parameter filter" in the tile cache description and provide an indication of which combinations will be cached, because indeed, each combination generates a separate tile cache.

See the documentation here: http://docs.geoserver.org/latest/en/user/geowebcache/webadmin/layers.html#parameter-filters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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