[OpenLayers-Users] An App-Specific Feature.WMS subclass example, begs a slight API addition

mfrumin mfrumin at rpa.org
Thu Jun 7 17:15:09 EDT 2007


check it out, a Feature.WMS app-specific subclass which uses a WFS attribute
to put pictures on the map and make popups for the pics.
http://transit.frumin.net/olexample/

I'm sending this because a) I think it's a nice example of what you can do
with OpenLayers/WFS to make something cool, but b) because I think it shows
something that needs to be added to the API.

Note how when you create the WFS layer, you pass in the Class to be used to
handle it:

layer = new OpenLayers.Layer.WFS( "Pics WFS", wfs,
        { typename: 'frumin:pictures', maxfeatures: 100 } ,
        { featureClass: OpenLayers.Feature.WFS.Pics}
);

But also notice that to avoid storing full URL's in my database/WFS layer, I
had to hardcode some URL's into my Pics class
(http://transit.frumin.net/olexample/Pics.js), eg in processXMLNode:

    ...
    var file =
OpenLayers.Util.getXmlNodeValue(xmlNode.getElementsByTagName('file')[0]);
    ...
    data.icon = new
OpenLayers.Icon("http://frumin.net/rpa/trx/pics/fb2br/icons/" + file,
isize);

so, what I would really like is a "client data" that you give it when you
create the WFS layer that then gets passed into the either the constructor
or the processXML node method.  this way, it would work like this:

layer = new OpenLayers.Layer.WFS( "Pics WFS", wfs,
        { typename: 'frumin:pictures', maxfeatures: 100 } ,
        { featureClass: OpenLayers.Feature.WFS.Pics, clientData: {
picUrlRoot: "http://frumin.net/pics/"}}
);

and 

processXMLNode: function(xmlNode, clientData) {
...
    data.icon = new OpenLayers.Icon(clientData.picUrlRoot + file, isize);
...
}

feel me?

thanks for the awesome software as usual.

-mike
-- 
View this message in context: http://www.nabble.com/An-App-Specific-Feature.WMS-subclass-example%2C-begs-a-slight-API-addition-tf3886464.html#a11016410
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list