[OpenLayers-Users] Change in API stopping a test app working?
Erik Uzureau
euzuro at gmail.com
Mon Jul 3 20:18:50 CDT 2006
Hi Nick,
Actually, what I think would be the (obsessive?) solution to your
problem would be
adding the following function:
setMap: function(map) {
OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);
OpenLayers.Layer.Markers.prototype.setMap.apply(this, arguments);
},
The problem here is that (like the wfs layer), you are subclassing off of both
the Grid and the Markers layer. What happens is that when loading all the script
files for openlayers and setting up all the class definitions, it goes
through and
first adds all the functions from Layer.Grid to your Layer.OSMTest, and then it
goes through and adds all the functions from Layer.Markers.
Unfortunately, the setMap() declared in Grid is an important one, and
it gets overridden
by the setMap() declared in OSMTest (which is actually just the
setMap() declared in
Layer.js, to be precise).
So, pasting the snippet chris sent is a good fix and should solve the
problem... but the
real solution is defining a new setMap() function that bubbles up and
calls *both* of the
setMap functions in the superclass.
Clearly, this is a complication/weakness. It might make sense for us
to spend a wee bit
of time to develop a generic GridMarkers.js which is just a class that
combines both
functionalities. It would still mean being attentive to the addition
of new functions in
superclasses (like the new addition of setMap(), which is what caused
your problems)
but at least they would all be dealt with in one central place.
As a matter of fact, I think I might add that to my own todo list.
Might be a handy thing if
more people are going to be using this hybrid markers and grid. :-)
Thanks for the bug report and dont hesitate to let us know if you have
other questisons,
Erik
On 7/3/06, Christopher Schmidt <crschmidt at crschmidt.net> wrote:
> On Mon, Jul 03, 2006 at 10:12:54PM +0100, nick at hogweed.org wrote:
> > Hello Erik (or anyone else),
> >
> > Remember a couple of weeks ago I talked about implementing my own annotations
> > layer? Got it to work in the end but now it appears to have stopped working
> > so I'm guessing the code has changed. I now get the error:
> >
> > Error: this.tileSize has no properties
> > Source File: http://openlayers.org/dev/lib/OpenLayers/Layer/Grid.js
> > Line: 130
>
> Ah, life on the bleeding edge. ;)
>
> > Has something in the api changed? I didn't get this error before.
>
> I'm not sure exactly what changed that caused this -- it wasn't
> happening on your site when I looked at it this morning.
>
> But you probably want something in osmlayer.js which subclasses the
> setMap call: you can just call out to the Grid.js version, probably:
>
> setMap: function(map) {
> OpenLayers.Layer.prototype.setMap.apply(this, arguments);
> if (this.tileSize == null) {
> this.tileSize = this.map.getTileSize();
> }
> },
>
> This is a relatively recent change in the API.
>
> --
> Christopher Schmidt
> Web Developer
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://mailman-viper.python-hosting.com/listinfo/users
>
More information about the Users
mailing list