Leaflet requesting wrong tiles with local tiles generated by GeoWebCache

1,142 views
Skip to first unread message

Skipster

unread,
Oct 2, 2014, 3:43:46 PM10/2/14
to leafl...@googlegroups.com
I have a set of tiles generated from GeoWebCache inside Geoserver. I have taken the resolutions, coordinate system (EPSG 900913) and bounds from Geoserver to configure my layer within Leaflet.

However Leaflet is trying to request tiles that do not exist and I cannot get it to work. If I use the same settings and tiles on OpenLayers it works fine.

I have used the GWC layer plugin (https://github.com/njakeman/LeafletJS_GWC_layer/blob/master/src/Leaflet_GWC_Layer.js) and Proj4Leaflet.

Anything to help me understand what I am doing wrong here would be much appreciated.


Incorrect tiles requested as shown in Chrome -

My code to create the map and layer -


var crs = new L.Proj.CRS.TMS(
       
'EPSG:900913',
       
'+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs',
       
[-20037508.34,-20037508.34,20037508.34,20037508.34],
       
{ tileSize: 512,
        resolutions
: [4891.9698095703125, 2445.9849047851562, 1222.9924523925781, 611.4962261962891, 305.74811309814453, 152.87405654907226,76.43702827453613, 38.218514137268066, 19.109257068634033, 9.554628534317017, 4.777314267158508] }
   
),
map
= L.map('map', {
    crs
: crs,
    continuousWorld
: false,    worldCopyJump: false,
    zoomControl
: true
});

new L.TileLayer.GWC('http://{URL REMOVED}/Layer_0{z}/{dir_x}_{dir_y}/{x}_{y}.png8', {
    maxZoom
: 8,
    minZoom
: 0,
    subdomains
: '0123',
    continuousWorld
: false,
    attribution
: '? 2014',
    tms
: true,
    tileSize
: 512
}).addTo(map);

map
.setView(L.latLng(53.579244, -1.499634), 0);
map
.panTo(L.latLng(53.579244, -1.499634));

Abel Vázquez

unread,
Oct 6, 2014, 5:10:57 AM10/6/14
to leafl...@googlegroups.com


If you have access to that instance of GeoServer (I guess), go to GeoWebCache settings and enable direct integration with WMS. Then you can use an  L.tileLayer.wms() and add a parameter "tiled"=true to it, so it retrieves cached tiles.

Skipster

unread,
Oct 7, 2014, 3:59:23 AM10/7/14
to leafl...@googlegroups.com
Thanks for your reply.

I have tried this and it does work fine, however for this system we are unable to have GeoServer running so it must be from pre-generated tiles.

Is there anything you think I may have incorrectly configured for the layer in Leaflet?

Skipster

unread,
Oct 14, 2014, 9:06:21 AM10/14/14
to leafl...@googlegroups.com
I have resolved the first problem.

adjustTilePoint was being called twice, once within the GWC layer and once within Leaflet, causing the tilePoint to become incorrect.

After removing one of the calls I now have tiles displaying however when examining the LatLong of a point on the map, the x coordinate (long) is correct but the y coordinate (lat) is wrong. It is not far off though, when entering the coordinates on Google Maps, the y coordinate is only 10 miles out.

Any ideas on what this issue could be?
Reply all
Reply to author
Forward
0 new messages