Closed sellonen closed 10 years ago
For this functionality, OpenLayers uses older Proj4js version's functionality to dynamically load projection information from spatialreference.org. That is, the EPSG code in itself is not enough, but it will make a call to spatialreference to get the required information.
This functionality is not built in for newer Proj4js versions, and for good reason, since that asynchronous loading was quite poorly designed and was really outside the scope of Proj4js.
If you want to achieve the same thing, you can make the call yourself. An example of how it can be done can be seen here: https://github.com/perliedman/gis-nerd-tools/blob/master/src/projections.js (although that is part of an application, and I'm sure it can be done in fewer lines of code if you use for example jQuery or similar).
I could not have wished for a better answer, thanks a lot! I certainly do not want to make an asynchronous call every time before the slowest part of my application starts loading, so I will try to find a way to cache the projections my customers need.
Sounds like a good thing, if you know the EPSG codes in advance!
Hi,
When I send a GetCapabilities request to a wms server, I receive for each layer an EPSG code and bounding box. In openlayers they are enough to define a projection, it is really as simple as
I have reasons to prefer Leaflet, but I'm a bit at loss why I need to define the projections so explicitly in proj4Leaflet. Does openlayers do a lot of magical mathematics to get from the epsg code and extent to the full crs specification?
I guess my main question is: can someone estimate how difficult it would be to make projection definitions so easy in leaflet that one could define the crs based on the response of GetCapabilities?