OpenLayers OpenLayers

Ticket #1406: projected_wfs.patch

File projected_wfs.patch, 3.1 kB (added by crschmidt, 10 months ago)
  • lib/OpenLayers/Layer/WFS.js

    old new  
    277277         
    278278            var params = {BBOX: this.encodeBBOX ? tileBounds.toBBOX()  
    279279                                                : tileBounds.toArray()}; 
     280             
     281            if (this.map && !this.projection.equals(this.map.getProjectionObject())) { 
     282                var projectedBounds = tileBounds.clone(); 
     283                projectedBounds.transform(this.map.getProjectionObject(),  
     284                                          this.projection); 
     285                params.BBOX = this.encodeBBOX ? projectedBounds.toBBOX()  
     286                                              : projectedBounds.toArray(); 
     287            }                                   
     288 
    280289            url += "&" + OpenLayers.Util.getParameterString(params); 
    281290 
    282291            if (!this.tile) { 
     
    434443     */ 
    435444    commit: function() { 
    436445        if (!this.writer) { 
    437             this.writer = new OpenLayers.Format.WFS({},this); 
     446            var options = {}; 
     447            if (this.map && !this.projection.equals(this.map.getProjectionObject())) { 
     448                options.externalProjection = this.projection; 
     449                options.internalProjection = this.map.getProjectionObject(); 
     450            }     
     451             
     452            this.writer = new OpenLayers.Format.WFS(options,this); 
    438453        } 
    439454 
    440455        var data = this.writer.write(this.features); 
  • examples/spherical-mercator.html

    old new  
    2424        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; 
    2525        OpenLayers.Util.onImageLoadErrorColor = "transparent"; 
    2626 
     27        // Ability to load WFS data 
     28        OpenLayers.ProxyHost = '/proxy/?url='; 
     29 
    2730        function init(){ 
    2831            var options = { 
    2932                projection: new OpenLayers.Projection("EPSG:900913"), 
     
    110113                    'isBaseLayer': false,'wrapDateLine': true 
    111114                } 
    112115            ); 
     116            // create WFS layer, which is in EPSG:4326 
     117            wfs = new OpenLayers.Layer.WFS("WFS",  
     118              "http://featureserver.org/featureserver.cgi/scribble?format=WFS", 
     119              {maxfeatures: "50"},  
     120              { 
     121                extractAttributes: true,  
     122                projection: new OpenLayers.Projection("EPSG:4326") 
     123               } 
     124            ); 
    113125 
    114126            // create a vector layer for drawing 
    115127            var vector = new OpenLayers.Layer.Vector("Editable Vectors"); 
    116128 
    117129            map.addLayers([gmap, gsat, ghyb, veroad, veaer, vehyb, 
    118130                           yahoo, yahoosat, yahoohyb, mapnik, osmarender, 
    119                            wms, vector]); 
     131                           wms, vector, wfs]); 
    120132            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
    121133            map.addControl(new OpenLayers.Control.EditingToolbar(vector)); 
    122134            map.addControl(new OpenLayers.Control.Permalink());