Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
    
Just request the WMS in the SRS of your base map - GeoServer will handle the reprojection for you. –  iant Nov 27 '12 at 8:31
    
@iant can you provide an example of how to do this with Leaflet? I understand in GeoServer's WMS we just append something like &srsName=epsg:3857 to the URL, but how can we pass this into Leaflet? –  Lucas Dec 16 at 0:42

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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