[OpenLayers-Users] Having difficulty creating my own feature layer....
nick@hogweed.org
nick at hogweed.org
Tue Jun 20 15:40:18 CDT 2006
Erik, Paul,
> The explanation that Paul gives here sounds good and is very thorough...
> thanks for tackling that one! Can you let us know if this fixes the problem
> you were having, Nick? Do you need some more help? I wrote most of the code
> that is that WFS.js class, so feel free to fire away... :-)
>
> Thanks,
>
> Erik
>
> On 6/20/06, Paul Spencer <pspencer at dmsolutions.ca> wrote:
> > Nick,
> >
> > I'm not that familiar with the openlayers code yet, but it seems to
> > me that you need to call this.layer.addMarker(a)
I tried that originally, as it seemed the most obvious thing to do :-) If you
look at my code I have commented out
/*
this.layer.addMarker
( new OpenLayers.Marker
(lonLat,new OpenLayers.Icon('images/amenity.png')));
*/
However, that gave an error "this.layer has no properties". Since the
Layer.OSMtest indeed does "inherit" from Layer.Markers I was puzzled by that.
Also the Tile.WFS references this.layer so I'm doubly puzzled....
Nick
> > From what I understand, the syntax that invokes
> > xxx.prototype.xxx.apply(this, ...) is used to call base-class
> > functions that have the same name as a sub-class function name. In
> > javascript, there is no concept of a super class so you have to
> > resort to 'tricks' like this.
> >
> > The addMarker method is a method of the Markers layer type. Since
> > Layer.OSMtest extends Markers, you automatically gain an addMarker
> > method in OSMtest.
> >
> > Your call to addMarker is coming from Tile.OSMtest. Tile has a
> > member variable layer which points to the layer containing the tile.
> > Therefore you can call addMarker directly.
> >
> > You would have needed to use the prototype/apply thing if you had
> > defined an addMarker function in your Layer.OSMtest but actually
> > needed to call addMarker in the Layers.Markers code.
> >
> > Um. Not sure if that explains things very well. It all makes sense
> > in my head, though :)
> >
> > Cheers
> >
> > Paul
More information about the Users
mailing list