So my basemap is a world Mercator projection and in wfs format and I'm trying to put a WMS overlay in a different projection over it? Leaflet's API didn't give me much info on changing the epsg so is it even possible?
Leaflet supports PseudoMercator projection out-of-the-box (EPSG:3857). You can force Leaflet to use a few other projections listed here in the documentation. Don't worry, I found leaflet's API documentation kind of 'meh'. Documentation by programmers...
World Mercator is supported with a easy to use method, lucky you.
L.CRS.EPSG3395
You just place that anywhere in the global scope of your script and it should set your projection for you map.
Additionally, there is a plugin for leaflet that can allow you to use more 'uncommon' projections. Proj4Leaflet
Note: It doesn't appear that Leaflet will tranform your layer into another projection like ArcGIS or QGIS but will just take the data at face value and render it that way. You will need to serve your data in the projection that your tell Leaflet to use.
-
Thx, I'm actually taking over a leaflet related project and I was able to find that bit of code, but the issue was that it was part of a minified library called leaf-custom.js and so the code is just one long horizontal line that won't wrap so I have to disseminate it. – Carl Carlson Nov 27 '12 at 14:39
-
Oh so the actual map implementation is an external, minified library? If so, try just adding the projection line in the script body like you would if building the map yourself. I think it would behave just the same. – RomaH Nov 27 '12 at 14:44
-
Not exactly, certain configurations are being hard-coded within the external minified library, but there is a map implementation file and a few other files to render the views all part of a namespace that draws from the minified library so I have to figure out where to make modifications. – Carl Carlson Nov 27 '12 at 14:55
In Leaflet 0.7 you can assign a different CRS to each WMS Layer by using its csr option.
var myLayer = L.tileLayer.wms(...);
myLayer.options.crs = L.CRS.EPSG4326;
-
I have same requirement. The point is that is it possible to add wms layer with crs different than the map's crs? – senol ozgur Mar 22 '18 at 12:55
&srsName=epsg:3857
to the URL, but how can we pass this into Leaflet? – modulitos Dec 16 '14 at 0:42