[76] | 1 | /* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for |
---|
| 2 | * full list of contributors). Published under the Clear BSD license. |
---|
| 3 | * See http://svn.openlayers.org/trunk/openlayers/license.txt for the |
---|
| 4 | * full text of the license. */ |
---|
| 5 | |
---|
| 6 | /** |
---|
| 7 | * @requires OpenLayers/Feature.js |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * Class: OpenLayers.Feature.WFS |
---|
| 12 | * WFS handling class, for use as a featureClass on the WFS layer for handling |
---|
| 13 | * 'point' WFS types. Good for subclassing when creating a custom WFS like |
---|
| 14 | * XML application. |
---|
| 15 | * |
---|
| 16 | * Inherits from: |
---|
| 17 | * - <OpenLayers.Feature> |
---|
| 18 | */ |
---|
| 19 | OpenLayers.Feature.WFS = OpenLayers.Class(OpenLayers.Feature, { |
---|
| 20 | |
---|
| 21 | /** |
---|
| 22 | * Constructor: OpenLayers.Feature.WFS |
---|
| 23 | * Create a WFS feature. |
---|
| 24 | * |
---|
| 25 | * Parameters: |
---|
| 26 | * layer - {<OpenLayers.Layer>} |
---|
| 27 | * xmlNode - {XMLNode} |
---|
| 28 | */ |
---|
| 29 | initialize: function(layer, xmlNode) { |
---|
| 30 | var newArguments = arguments; |
---|
| 31 | var data = this.processXMLNode(xmlNode); |
---|
| 32 | newArguments = new Array(layer, data.lonlat, data); |
---|
| 33 | OpenLayers.Feature.prototype.initialize.apply(this, newArguments); |
---|
| 34 | this.createMarker(); |
---|
| 35 | this.layer.addMarker(this.marker); |
---|
| 36 | }, |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * Method: destroy |
---|
| 40 | * nullify references to prevent circular references and memory leaks |
---|
| 41 | */ |
---|
| 42 | destroy: function() { |
---|
| 43 | if (this.marker != null) { |
---|
| 44 | this.layer.removeMarker(this.marker); |
---|
| 45 | } |
---|
| 46 | OpenLayers.Feature.prototype.destroy.apply(this, arguments); |
---|
| 47 | }, |
---|
| 48 | |
---|
| 49 | /** |
---|
| 50 | * Method: processXMLNode |
---|
| 51 | * When passed an xmlNode, parses it for a GML point, and passes |
---|
| 52 | * back an object describing that point. |
---|
| 53 | * |
---|
| 54 | * For subclasses of Feature.WFS, this is the feature to change. |
---|
| 55 | * |
---|
| 56 | * Parameters: |
---|
| 57 | * xmlNode - {XMLNode} |
---|
| 58 | * |
---|
| 59 | * Returns: |
---|
| 60 | * {Object} Data Object with 'id', 'lonlat', and private properties set |
---|
| 61 | */ |
---|
| 62 | processXMLNode: function(xmlNode) { |
---|
| 63 | //this should be overridden by subclasses |
---|
| 64 | // must return an Object with 'id' and 'lonlat' values set |
---|
| 65 | var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://www.opengis.net/gml", "gml", "Point"); |
---|
| 66 | var text = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(point[0], "http://www.opengis.net/gml","gml", "coordinates")[0]); |
---|
| 67 | var floats = text.split(","); |
---|
| 68 | return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]), |
---|
| 69 | parseFloat(floats[1])), |
---|
| 70 | id: null}; |
---|
| 71 | |
---|
| 72 | }, |
---|
| 73 | |
---|
| 74 | CLASS_NAME: "OpenLayers.Feature.WFS" |
---|
| 75 | }); |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|