Ticket #3181 (closed bug: invalid)
multiple issues (sorry to group as one)
|Reported by:||michaelkatz||Owned by:|
Sorry if some of this is due to user misunderstanding, but I thought it was better to say something than not.
I was trying to use an XYZ layer to implement essentially my own open street map server. I ran into a few problems.
First, a general question, I was trying to debug OpenLayers.js in firebug and it's not formatted. I tried autoformatting with editor but that didn't work very well. I ended up checking out the source code in SVN and replacing the parts from OpenLayers.js that I needed to debug with the formatted code from SVN. So the general question is: Can you make a formatted version of OpenLayers.js available for people who want to debug it? (or maybe it's already available and I just couldn't find it...)
As I was doing this, I noticed a couple problems. One is that
appears more than once in the file, as do several other Layer subclass definitions. So it took me a long time to realize that the code changes I was making to those classes (i.e., to the first instance higher up in the file) were not having any effect. My guess is that somehow those classes are being included into OpenLayers.js more than once by mistake in your build process.
The final problem is that it seems to me the OpenLayers.Layer.XYZ has a problem in that it has sphericalMercator false by default. So I was trying to set myLayer.sphericalMercator = true after the layer had been created. But it turned out that several internal variables in the class were already initialized with lat/lon values. The net result was that my map was almost working but not really. Like it would only draw the northern hemisphere when drawing the four tiles of zoom level 1 (i.e., it only drew the top two tiles). It took me a long time to figure out that this was an issue with the projection being initialized incorrectly. I actually went ahead and initialized sphericalMercator = true in my own copy of the XYZ class, as the only way I could make it work. Some of this may be due to me not understanding the API, but the bottom line is that I went from and OSM layer to an XYZ layer, and I expected it to just work and it didn't. So either a bug fix or some clarification in the documentation would be good, since I imagine many users who are interested in the XYZ class are trying to make their own OSM functionality using a local tile cache.