My tilecache.cfg is like so (working with MapServer)
[mylayer]
type=WMS
url=http://server/mapserver/app
spherical_mercator=true
layers=mylayer
The following works just fine
var mylayer = new OpenLayers.Layer.WMS(
"My Layer",
"http://server/tilecache/tilecache.cgi",
{layers: "mylayer", transparent: true},
{isBaseLayer: false, opacity: 0.6, visibility: true}
);
However, when I change the above to Leafletjs like below
var mylayer = L.tileLayer.wms("http://server/tilecache/tilecache.cgi", {
layers: 'mylayer',
format: 'image/png',
transparent: true,
attribution: 'Data from blah blah'
});
I get the following error
An error occurred: Current y value -5009377.085697 is too far from tile corner y -10018754.170400
Suggestions?
Update2: (top-posted). I tried adding srs
definitions (srs:"EPSG:4326"
or srs:"EPSG:900913"
). While the latter didn't help at all, the particular error I reported above went away with 4326, and a couple of tiles were also returned, though most tiles were just blank. This tells me something is goofy with the way Leaflet expects the projection. I'd rather not change anything on the source (MapServer or Tilecache side), if possible, as other applications are depending on that to be working.
Update: Adding the MapServer map file, in case that might help
MAP
EXTENT -180.150250417362 -90 180.150250417362 90
IMAGECOLOR 255 255 255
IMAGETYPE "png"
NAME "mylayer"
SIZE 1200 600
STATUS ON
UNITS DD
DEBUG 3
CONFIG "MS_ERRORFILE" "/tmp/ms_mylayer_error.log"
OUTPUTFORMAT
NAME "png24"
MIMETYPE "image/png"
DRIVER "AGG/PNG"
EXTENSION "png"
IMAGEMODE RGBA
TRANSPARENT ON
END
SHAPEPATH "/path/to/files"
PROJECTION
"init=epsg:4326"
END
WEB
IMAGEPATH "/tmp/ms_tmp/"
METADATA
ows_enable_request "*"
wms_abstract "This WMS mapservice serves a map of mylayer"
wms_accessconstraints "none"
wms_title "mylayer"
wms_onlineresource "http://sever/cgi-bin/mylayer?"
wms_srs "EPSG:900913 EPSG:4269 EPSG:4326"
wms_keywordlist "World,mylayer"
wms_enable_request "*"
END
END
LAYER
NAME "global"
TYPE RASTER
..
METADATA
wms_srs "EPSG:4326"
wms_name "global"
wms_server_version "1.1.1"
wms_format "image/png"
wms_enable_reques "*"
wms_extent "-180 -90 180 90"
END
END
END