kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
589 stars 173 forks source link

Different CRS instances do not necessarily share same options #43

Closed noiv closed 11 years ago

noiv commented 11 years ago
L.Proj.CRS.prototype.initialize(code, def, options);

While showing two maps with EPSG:3413, but different resolutions, the second call of above line overwrites the options of the first CRS. Using:

L.setOptions(this, options);

directly afterwards solved it, but I'm not sure whether side effects exists on untested conditions.

perliedman commented 11 years ago

If I understand correctly, you call L.Proj.CRS.prototype.initialize explicitly? You are not supposed to do that. Please use:

var crs = new L.Proj.CRS(code, def, options)

Then you will not have this problem, since you will have to separate instances.

noiv commented 11 years ago

No, the lib calls that line here: https://github.com/kartena/Proj4Leaflet/blob/master/src/proj4leaflet.js#L127

And yes, different instances, but with same prototype, that's why they share the options.

perliedman commented 11 years ago

Oops, yes, that's bad. Will look into it.

perliedman commented 11 years ago

Should be fixed by 5bad55c5422cdece212f1e054505411418de805d, but please verify.

noiv commented 11 years ago

Works here.

perliedman commented 11 years ago

Good. Thanks for the heads up.