Changeset 5828
- Timestamp:
- 01/20/08 15:33:54 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/GML.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Text.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/WFS.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Tile/WFS.js (modified) (1 diff)
- trunk/openlayers/tests/Layer/test_GeoRSS.html (modified) (3 diffs)
- trunk/openlayers/tests/Layer/test_Text.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/GML.js
r5776 r5828 29 29 */ 30 30 format: null, 31 32 /** 33 * APIProperty: formatOptions 34 * {Object} Hash of options which should be passed to the format when it is 35 * created. Must be passed in the constructor. 36 */ 37 formatOptions: null, 31 38 32 39 /** … … 128 135 doc = request.responseText; 129 136 } 130 131 var gml = this.format ? new this.format() : new OpenLayers.Format.GML(); 137 138 var options = {}; 139 140 OpenLayers.Util.extend(options, this.formatOptions); 141 if (this.map && !this.projection.equals(this.map.getProjectionObject())) { 142 options.externalProjection = this.projection; 143 options.internalProjection = this.map.getProjectionObject(); 144 } 145 146 var gml = this.format ? new this.format(options) : new OpenLayers.Format.GML(options); 132 147 this.addFeatures(gml.read(doc)); 133 148 this.events.triggerEvent("loadend"); trunk/openlayers/lib/OpenLayers/Layer/GeoRSS.js
r5715 r5828 30 30 */ 31 31 features: null, 32 33 /** 34 * APIProperty: formatOptions 35 * {Object} Hash of options which should be passed to the format when it is 36 * created. Must be passed in the constructor. 37 */ 38 formatOptions: null, 32 39 33 40 /** … … 70 77 this.location = location; 71 78 this.features = []; 72 this.events.triggerEvent("loadstart");73 OpenLayers.loadURL(location, null, this, this.parseData);74 79 }, 75 80 … … 87 92 this.features = null; 88 93 }, 94 95 /** 96 * Method: loadRSS 97 * Start the load of the RSS data. Don't do this when we first add the layer, 98 * since we may not be visible at any point, and it would therefore be a waste. 99 */ 100 loadRSS: function() { 101 if (!this.loaded) { 102 this.events.triggerEvent("loadstart"); 103 OpenLayers.loadURL(this.location, null, this, this.parseData); 104 this.loaded = true; 105 } 106 }, 107 108 /** 109 * Method: moveTo 110 * If layer is visible and RSS has not been loaded, load RSS. 111 * 112 * Parameters: 113 * bounds - {Object} 114 * zoomChanged - {Object} 115 * minor - {Object} 116 */ 117 moveTo:function(bounds, zoomChanged, minor) { 118 OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments); 119 if(this.visibility && !this.loaded){ 120 this.events.triggerEvent("loadstart"); 121 this.loadRSS(); 122 } 123 }, 89 124 90 125 /** … … 114 149 } 115 150 116 var format = new OpenLayers.Format.GeoRSS(); 151 var options = {}; 152 153 OpenLayers.Util.extend(options, this.formatOptions); 154 155 if (this.map && !this.projection.equals(this.map.getProjectionObject())) { 156 options.externalProjection = this.projection; 157 options.internalProjection = this.map.getProjectionObject(); 158 } 159 160 var format = new OpenLayers.Format.GeoRSS(options); 117 161 var features = format.read(doc); 118 162 trunk/openlayers/lib/OpenLayers/Layer/Text.js
r5614 r5828 54 54 */ 55 55 features: null, 56 57 /** 58 * APIProperty: formatOptions 59 * {Object} Hash of options which should be passed to the format when it is 60 * created. Must be passed in the constructor. 61 */ 62 formatOptions: null, 56 63 57 64 /** … … 73 80 OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments); 74 81 this.features = new Array(); 75 if (this.location != null) {76 77 var onFail = function(e) {78 this.events.triggerEvent("loadend");79 };80 81 this.events.triggerEvent("loadstart");82 OpenLayers.loadURL(this.location, null,83 this, this.parseData, onFail);84 }85 82 }, 86 83 … … 99 96 }, 100 97 98 /** 99 * Method: loadText 100 * Start the load of the Text data. Don't do this when we first add the layer, 101 * since we may not be visible at any point, and it would therefore be a waste. 102 */ 103 loadText: function() { 104 if (!this.loaded) { 105 if (this.location != null) { 106 107 var onFail = function(e) { 108 this.events.triggerEvent("loadend"); 109 }; 110 111 this.events.triggerEvent("loadstart"); 112 OpenLayers.loadURL(this.location, null, 113 this, this.parseData, onFail); 114 this.loaded = true; 115 } 116 } 117 }, 118 119 /** 120 * Method: moveTo 121 * If layer is visible and Text has not been loaded, load Text. 122 * 123 * Parameters: 124 * bounds - {Object} 125 * zoomChanged - {Object} 126 * minor - {Object} 127 */ 128 moveTo:function(bounds, zoomChanged, minor) { 129 OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments); 130 if(this.visibility && !this.loaded){ 131 this.events.triggerEvent("loadstart"); 132 this.loadText(); 133 } 134 }, 101 135 102 136 /** … … 108 142 parseData: function(ajaxRequest) { 109 143 var text = ajaxRequest.responseText; 110 var parser = new OpenLayers.Format.Text(); 144 145 var options = {}; 146 147 OpenLayers.Util.extend(options, this.formatOptions); 148 149 if (this.map && !this.projection.equals(this.map.getProjectionObject())) { 150 options.externalProjection = this.projection; 151 options.internalProjection = this.map.getProjectionObject(); 152 } 153 154 var parser = new OpenLayers.Format.Text(options); 111 155 features = parser.read(text); 112 156 for (var i = 0; i < features.length; i++) { trunk/openlayers/lib/OpenLayers/Layer/WFS.js
r5614 r5828 54 54 */ 55 55 featureClass: null, 56 57 /** 58 * APIProperty: format 59 * {<OpenLayers.Format>} The format you want the data to be parsed with. 60 * Must be passed in the constructor. Should be a class, not an instance. 61 */ 62 format: null, 63 64 /** 65 * Property: formatObject 66 * {<OpenLayers.Format>} Internally created/managed format object, used by 67 * the Tile to parse data. 68 */ 69 formatObject: null, 70 71 /** 72 * APIProperty: formatOptions 73 * {Object} Hash of options which should be passed to the format when it is 74 * created. Must be passed in the constructor. 75 */ 76 formatOptions: null, 56 77 57 78 /** … … 147 168 if (this.vectorMode) { 148 169 OpenLayers.Layer.Vector.prototype.setMap.apply(this, arguments); 170 171 var options = { 172 'extractAttributes': this.extractAttributes 173 }; 174 175 OpenLayers.Util.extend(options, this.formatOptions); 176 if (this.map && !this.projection.equals(this.map.getProjectionObject())) { 177 options.externalProjection = this.projection; 178 options.internalProjection = this.map.getProjectionObject(); 179 } 180 181 this.formatObject = this.format ? new this.format(options) : new OpenLayers.Format.GML(options); 149 182 } else { 150 183 OpenLayers.Layer.Markers.prototype.setMap.apply(this, arguments); trunk/openlayers/lib/OpenLayers/Tile/WFS.js
r5777 r5828 134 134 } 135 135 if (this.layer.vectorMode) { 136 var gml = new OpenLayers.Format.GML({ 137 'extractAttributes': this.layer.options.extractAttributes 138 }); 139 this.layer.addFeatures(gml.read(doc)); 136 this.layer.addFeatures(this.formatObject.read(doc)); 140 137 } else { 141 138 var resultFeatures = OpenLayers.Ajax.getElementsByTagNameNS( trunk/openlayers/tests/Layer/test_GeoRSS.html
r4356 r5828 22 22 t.eq( layer.location, georss_txt, "layer.location is correct" ); 23 23 var markers; 24 layer.loadRSS(); 24 25 t.delay_call( 1, function() { 25 26 t.eq( layer.markers.length, 40, "marker length is correct" ); … … 44 45 t.eq( layer.location, atom_xml, "layer.location is correct" ); 45 46 var markers; 47 layer.loadRSS(); 46 48 t.delay_call( 1, function() { 47 49 t.eq( layer.markers.length, 2, "marker length is correct" ); … … 154 156 map.setCenter(new OpenLayers.LonLat(0,0),0); 155 157 var defaultIcon = OpenLayers.Marker.defaultIcon(); 156 t.delay_call( 1, function() { 158 layer.loadRSS(); 159 otherLayer.loadRSS(); 160 t.delay_call( 2, function() { 157 161 t.ok(layer.markers[0].icon, "The layer has a icon"); 158 162 t.eq(layer.markers[0].icon.url, defaultIcon.url, "The layer without icon has the default icon."); trunk/openlayers/tests/Layer/test_Text.html
r5489 r5828 22 22 23 23 layer = new OpenLayers.Layer.Text('Test Layer', { location: datafile }); 24 layer.loadText(); 24 25 t.ok( layer instanceof OpenLayers.Layer.Text, "new OpenLayers.Layer.Text returns object" ); 25 26 t.eq( layer.location, datafile, "layer.location is correct" );
