OpenLayers OpenLayers

Changeset 8012

Show
Ignore:
Timestamp:
09/12/08 13:24:20 (3 months ago)
Author:
euzuro
Message:

Batch merge for rc2 of 2.7. 'svn merge -r7967:HEAD from trunk (Closes #1733) (Closes #1489) (Closes #1639) (Closes #1718) (Closes #1723) (Closes #1732) (Closes #1616) (Closes #1722)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.7/build/license.txt

    r7335 r8012  
    5353 * http://www.apache.org/licenses/LICENSE-2.0 
    5454 */ 
     55 
     56/** 
     57 * Contains portions of Gears <http://code.google.com/apis/gears/> 
     58 * 
     59 * Copyright 2007, Google Inc. 
     60 * 
     61 * Redistribution and use in source and binary forms, with or without 
     62 * modification, are permitted provided that the following conditions are met: 
     63 * 
     64 *  1. Redistributions of source code must retain the above copyright notice, 
     65 *     this list of conditions and the following disclaimer. 
     66 *  2. Redistributions in binary form must reproduce the above copyright notice, 
     67 *     this list of conditions and the following disclaimer in the documentation 
     68 *     and/or other materials provided with the distribution. 
     69 *  3. Neither the name of Google Inc. nor the names of its contributors may be 
     70 *     used to endorse or promote products derived from this software without 
     71 *     specific prior written permission. 
     72 * 
     73 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
     74 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
     75 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
     76 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     77 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
     78 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
     79 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
     80 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
     81 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
     82 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     83 * 
     84 * Sets up google.gears.*, which is *the only* supported way to access Gears. 
     85 * 
     86 * Circumvent this file at your own risk! 
     87 * 
     88 * In the future, Gears may automatically define google.gears.* without this 
     89 * file. Gears may use these objects to transparently fix bugs and compatibility 
     90 * issues. Applications that use the code below will continue to work seamlessly 
     91 * when that happens. 
     92 */ 
  • branches/openlayers/2.7/examples/measure.html

    r7965 r8012  
    9393            document.getElementById('noneToggle').checked = true; 
    9494        } 
     95 
     96        function calcVincenty(geometry) { 
     97            /** 
     98             * Note: this function assumes geographic coordinates and 
     99             *     will fail otherwise.  OpenLayers.Util.distVincenty takes 
     100             *     two objects representing points with geographic coordinates 
     101             *     and returns the geodesic distance between them (shortest 
     102             *     distance between the two points on an ellipsoid) in *kilometers*. 
     103             * 
     104             * It is important to realize that the segments drawn on the map 
     105             *     are *not* geodesics (or "great circle" segments).  This means 
     106             *     that in general, the measure returned by this function 
     107             *     will not represent the length of segments drawn on the map. 
     108             */ 
     109            var dist = 0; 
     110            for (var i = 1; i < geometry.components.length; i++) { 
     111                var first = geometry.components[i-1]; 
     112                var second = geometry.components[i]; 
     113                dist += OpenLayers.Util.distVincenty( 
     114                    {lon: first.x, lat: first.y}, 
     115                    {lon: second.x, lat: second.y} 
     116                ); 
     117            } 
     118            return dist; 
     119        }     
    95120         
    96121        function handleMeasurements(event) { 
     
    103128            if(order == 1) { 
    104129                out += "measure: " + measure.toFixed(3) + " " + units; 
     130                if (map.getProjection() == "EPSG:4326") { 
     131                    out += "<br /> Great Circle Distance: " +  
     132                        calcVincenty(geometry).toFixed(3) + " km *";  
     133                }         
    105134            } else { 
    106135                out += "measure: " + measure.toFixed(3) + " " + units + "<sup>2</" + "sup>"; 
     
    145174            </li> 
    146175        </ul> 
     176        <p>* Note that the geometries drawn are planar geometries and the 
     177        metrics returned by the measure control are planar measures.  The 
     178        "great circle" distance does not necessarily represent the length 
     179        of the segments drawn on the map.  Instead, it is a geodesic metric that 
     180        represents the cumulative shortest path between all vertices in the 
     181        geometry were they projected onto a sphere.</p> 
    147182    </div> 
    148183  </body> 
  • branches/openlayers/2.7/examples/proxy.cgi

    r7134 r8012  
    1919                'labs.metacarta.com', 'world.freemap.in',  
    2020                'prototype.openmnnd.org', 'geo.openplans.org', 
    21                 'sigma.openplans.org' 
     21                'sigma.openplans.org', 
    2222                'www.openstreetmap.org'] 
    2323 
     
    4141        print "Content-Type: text/plain" 
    4242        print 
    43         print "This proxy does not allow you to access that location." 
    44         print  
     43        print "This proxy does not allow you to access that location (%s)." % (host,) 
     44        print 
    4545        print os.environ 
    4646   
  • branches/openlayers/2.7/examples/spherical-mercator.html

    r7676 r8012  
    2929                displayProjection: new OpenLayers.Projection("EPSG:4326"), 
    3030                units: "m", 
     31                numZoomLevels: 18, 
    3132                maxResolution: 156543.0339, 
    3233                maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 
     
    8788                } 
    8889            ); 
    89             // create OSM layer 
    90             var mapnik = new OpenLayers.Layer.TMS( 
     90            // create OAM layer 
     91            var oam = new OpenLayers.Layer.TMS( 
    9192                "OpenAerialMap", 
    9293                "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/", 
     
    9798 
    9899            // create OSM layer 
     100            var mapnik = new OpenLayers.Layer.TMS( 
     101                "OpenStreetMap (Mapnik)", 
     102                  "http://a.tile.openstreetmap.org/", 
     103                { 
     104                    type: 'png', getURL: osm_getTileURL, 
     105                    displayOutsideMaxExtent: true, 
     106                    attribution: '<a href="http://www.openstreetmap.org/">OpenStreetMap</a>' 
     107                } 
     108            ); 
     109            // create OSM layer 
    99110            var osmarender = new OpenLayers.Layer.TMS( 
    100111                "OpenStreetMap (Tiles@Home)", 
    101                 "http://tah.openstreetmap.org/Tiles/tile.php/", 
     112                "http://tah.openstreetmap.org/Tiles/tile/", 
    102113                { 
    103114                    type: 'png', getURL: osm_getTileURL, 
     
    123134 
    124135            map.addLayers([gmap, gsat, ghyb, veroad, veaer, vehyb, 
    125                            yahoo, yahoosat, yahoohyb, mapnik, osmarender, 
     136                           yahoo, yahoosat, yahoohyb, oam, mapnik, osmarender, 
    126137                           wms, vector]); 
    127138            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
  • branches/openlayers/2.7/examples/vector-formats.html

    r7095 r8012  
    5353                'internalProjection': map.baseLayer.projection, 
    5454                'externalProjection': new OpenLayers.Projection(OpenLayers.Util.getElement("inproj").value) 
    55             }     
     55            };    
    5656            var out_options = { 
    5757                'internalProjection': map.baseLayer.projection, 
    5858                'externalProjection': new OpenLayers.Projection(OpenLayers.Util.getElement("outproj").value) 
    59             }     
     59            }; 
     60            var gmlOptions = { 
     61                featureType: "feature", 
     62                featureNS: "http://example.com/feature" 
     63            }; 
     64            var gmlOptionsIn = OpenLayers.Util.extend( 
     65                OpenLayers.Util.extend({}, gmlOptions), 
     66                in_options 
     67            ); 
     68            var gmlOptionsOut = OpenLayers.Util.extend( 
     69                OpenLayers.Util.extend({}, gmlOptions), 
     70                out_options 
     71            ); 
    6072            formats = { 
    6173              'in': { 
     
    6375                geojson: new OpenLayers.Format.GeoJSON(in_options), 
    6476                georss: new OpenLayers.Format.GeoRSS(in_options), 
    65                 gml: new OpenLayers.Format.GML(in_options), 
     77                gml2: new OpenLayers.Format.GML.v2(gmlOptionsIn), 
     78                gml3: new OpenLayers.Format.GML.v3(gmlOptionsIn), 
    6679                kml: new OpenLayers.Format.KML(in_options) 
    6780              },  
     
    7083                geojson: new OpenLayers.Format.GeoJSON(out_options), 
    7184                georss: new OpenLayers.Format.GeoRSS(out_options), 
    72                 gml: new OpenLayers.Format.GML(out_options), 
     85                gml2: new OpenLayers.Format.GML.v2(gmlOptionsOut), 
     86                gml3: new OpenLayers.Format.GML.v3(gmlOptionsOut), 
    7387                kml: new OpenLayers.Format.KML(out_options) 
    7488              }  
     
    170184                <option value="kml">KML</option> 
    171185                <option value="georss">GeoRSS</option> 
    172                 <option value="gml">GML</option> 
     186                <option value="gml2">GML (v2)</option> 
     187                <option value="gml3">GML (v3)</option> 
    173188                <option value="wkt">Well-Known Text (WKT)</option> 
    174189            </select> 
  • branches/openlayers/2.7/examples/wfs-reprojection.html

    r7884 r8012  
    4646            var wfs = layer = new OpenLayers.Layer.WFS( 
    4747                "States (SVG)", 
    48                 "http://sigma.openplans.org:8080/geoserver/ows", 
     48                "http://sigma.openplans.org/geoserver/ows", 
    4949                {typename: 'topp:states'}, 
    5050                { 
     
    6161            var wfs = layer = new OpenLayers.Layer.WFS( 
    6262                "States (Canvas)", 
    63                 "http://sigma.openplans.org:8080/geoserver/ows", 
     63                "http://sigma.openplans.org/geoserver/ows", 
    6464                {typename: 'topp:states'}, 
    6565                { 
  • branches/openlayers/2.7/lib/OpenLayers.js

    r7952 r8012  
    8484            "Rico/Corner.js", 
    8585            "Rico/Color.js", 
     86            "Gears/gears_init.js", 
    8687            "OpenLayers/Ajax.js", 
    8788            "OpenLayers/Request.js", 
     
    165166            "OpenLayers/Control/SelectFeature.js", 
    166167            "OpenLayers/Control/NavigationHistory.js", 
     168            "OpenLayers/Control/Measure.js", 
    167169            "OpenLayers/Geometry.js", 
    168170            "OpenLayers/Geometry/Rectangle.js", 
     
    185187            "OpenLayers/Strategy.js", 
    186188            "OpenLayers/Strategy/Fixed.js", 
     189            "OpenLayers/Strategy/Cluster.js", 
     190            "OpenLayers/Strategy/Paging.js", 
     191            "OpenLayers/Strategy/BBOX.js", 
    187192            "OpenLayers/Protocol.js", 
    188193            "OpenLayers/Protocol/HTTP.js", 
     194            "OpenLayers/Protocol/SQL.js", 
     195            "OpenLayers/Protocol/SQL/Gears.js", 
    189196            "OpenLayers/Layer/PointTrack.js", 
    190197            "OpenLayers/Layer/GML.js", 
     
    200207            "OpenLayers/Format/XML.js", 
    201208            "OpenLayers/Format/GML.js", 
     209            "OpenLayers/Format/GML/Base.js", 
     210            "OpenLayers/Format/GML/v2.js", 
     211            "OpenLayers/Format/GML/v3.js", 
    202212            "OpenLayers/Format/KML.js", 
    203213            "OpenLayers/Format/GeoRSS.js", 
  • branches/openlayers/2.7/lib/OpenLayers/Control/Permalink.js

    r7881 r8012  
    169169    createParams: function(center, zoom, layers) { 
    170170        center = center || this.map.getCenter(); 
    171         zoom = zoom || this.map.getZoom(); 
    172         layers = layers || this.map.layers;   
    173171           
    174172        var params = OpenLayers.Util.getParameters(this.base); 
     
    178176        // base link. 
    179177        if (center) {  
    180      
    181             params.zoom = this.map.getZoom();  
     178 
     179            //zoom 
     180            params.zoom = zoom || this.map.getZoom();  
     181 
     182            //lon,lat 
    182183            var lat = center.lat; 
    183184            var lon = center.lon; 
     
    193194            params.lat = Math.round(lat*100000)/100000; 
    194195            params.lon = Math.round(lon*100000)/100000; 
    195              
     196     
     197            //layers         
     198            layers = layers || this.map.layers;   
    196199            params.layers = ''; 
    197             for (var i=0, len=this.map.layers.length; i<len; i++) { 
    198                 var layer = this.map.layers[i]; 
     200            for (var i=0, len=layers.length; i<len; i++) { 
     201                var layer = layers[i]; 
    199202     
    200203                if (layer.isBaseLayer) { 
  • branches/openlayers/2.7/lib/OpenLayers/Format.js

    r7675 r8012  
    1313 */ 
    1414OpenLayers.Format = OpenLayers.Class({ 
     15     
     16    /** 
     17     * Property: options 
     18     * {Object} A reference to options passed to the constructor. 
     19     */ 
     20    options: null, 
    1521     
    1622    /** 
     
    5561    initialize: function(options) { 
    5662        OpenLayers.Util.extend(this, options); 
     63        this.options = options; 
     64    }, 
     65     
     66    /** 
     67     * APIMethod: destroy 
     68     * Clean up. 
     69     */ 
     70    destroy: function() { 
    5771    }, 
    5872 
  • branches/openlayers/2.7/lib/OpenLayers/Format/XML.js

    r7870 r8012  
    2121     
    2222    /** 
     23     * Property: namespaces 
     24     * {Object} Mapping of namespace aliases to namespace URIs.  Properties 
     25     *     of this object should not be set individually.  Read-only.  All 
     26     *     XML subclasses should have their own namespaces object.  Use 
     27     *     <setNamespace> to add or set a namespace alias after construction. 
     28     */ 
     29    namespaces: null, 
     30     
     31    /** 
     32     * Property: namespaceAlias 
     33     * {Object} Mapping of namespace URI to namespace alias.  This object 
     34     *     is read-only.  Use <setNamespace> to add or set a namespace alias. 
     35     */ 
     36    namespaceAlias: null, 
     37     
     38    /** 
     39     * Property: defaultPrefix 
     40     * {String} The default namespace alias for creating element nodes. 
     41     */ 
     42    defaultPrefix: null, 
     43     
     44    /** 
     45     * Property: readers 
     46     * Contains public functions, grouped by namespace prefix, that will 
     47     *     be applied when a namespaced node is found matching the function 
     48     *     name.  The function will be applied in the scope of this parser 
     49     *     with two arguments: the node being read and a context object passed 
     50     *     from the parent. 
     51     */ 
     52    readers: {}, 
     53     
     54    /** 
     55     * Property: writers 
     56     * As a compliment to the <readers> property, this structure contains public 
     57     *     writing functions grouped by namespace alias and named like the 
     58     *     node names they produce. 
     59     */ 
     60    writers: {}, 
     61 
     62    /** 
    2363     * Property: xmldom 
    2464     * {XMLDom} If this browser uses ActiveX, this will be set to a XMLDOM 
     
    4585        } 
    4686        OpenLayers.Format.prototype.initialize.apply(this, [options]); 
     87        // clone the namespace object and set all namespace aliases 
     88        this.namespaces = OpenLayers.Util.extend({}, this.namespaces); 
     89        this.namespaceAlias = {}; 
     90        for(var alias in this.namespaces) { 
     91            this.namespaceAlias[this.namespaces[alias]] = alias; 
     92        } 
     93    }, 
     94     
     95    /** 
     96     * APIMethod: destroy 
     97     * Clean up. 
     98     */ 
     99    destroy: function() { 
     100        this.xmldom = null; 
     101        OpenLayers.Format.prototype.destroy.apply(this, arguments); 
     102    }, 
     103     
     104    /** 
     105     * Method: setNamespace 
     106     * Set a namespace alias and URI for the format. 
     107     * 
     108     * Parameters: 
     109     * alias - {String} The namespace alias (prefix). 
     110     * uri - {String} The namespace URI. 
     111     */ 
     112    setNamespace: function(alias, uri) { 
     113        this.namespaces[alias] = uri; 
     114        this.namespaceAlias[uri] = alias; 
    47115    }, 
    48116 
     
    290358     */ 
    291359    getChildValue: function(node, def) { 
    292         var value; 
    293         if (node && node.firstChild && node.firstChild.nodeValue) {  
    294             value = node.firstChild.nodeValue; 
    295         } else { 
    296             value = (def != undefined) ? def : ""; 
     360        var value = def || ""; 
     361        if(node) { 
     362            var child = node.firstChild; 
     363            if(child) { 
     364                value = child.nodeValue || value; 
     365            } 
    297366        } 
    298367        return value; 
     
    385454    }, 
    386455 
     456    /** 
     457     * Method: createElementNSPlus 
     458     * Shorthand for creating namespaced elements with optional attributes and 
     459     *     child text nodes. 
     460     * 
     461     * Parameters: 
     462     * name - {String} The qualified node name. 
     463     * options - {Object} Optional object for node configuration. 
     464     * 
     465     * Valid options: 
     466     * uri - {String} Optional namespace uri for the element - supply a prefix 
     467     *     instead if the namespace uri is a property of the format's namespace 
     468     *     object. 
     469     * attributes - {Object} Optional attributes to be set using the 
     470     *     <setAttributes> method. 
     471     * value - {String} Optional text to be appended as a text node. 
     472     * 
     473     * Returns: 
     474     * {Element} An element node. 
     475     */ 
     476    createElementNSPlus: function(name, options) { 
     477        options = options || {}; 
     478        var loc = name.indexOf(":"); 
     479        // order of prefix preference 
     480        // 1. in the uri option 
     481        // 2. in the prefix option 
     482        // 3. in the qualified name 
     483        // 4. from the defaultPrefix 
     484        var uri = options.uri || this.namespaces[options.prefix]; 
     485        if(!uri) { 
     486            loc = name.indexOf(":"); 
     487            uri = this.namespaces[name.substring(0, loc)]; 
     488        } 
     489        if(!uri) { 
     490            uri = this.namespaces[this.defaultPrefix]; 
     491        } 
     492        var node = this.createElementNS(uri, name); 
     493        if(options.attributes) { 
     494            this.setAttributes(node, options.attributes); 
     495        } 
     496        if(options.value) { 
     497            node.appendChild(this.createTextNode(options.value)); 
     498        } 
     499        return node; 
     500    }, 
     501     
     502    /** 
     503     * Method: setAttributes 
     504     * Set multiple attributes given key value pairs from an object. 
     505     * 
     506     * Parameters: 
     507     * node - {Element} An element node. 
     508     * obj - {Object || Array} An object whose properties represent attribute 
     509     *     names and values represent attribute values.  If an attribute name 
     510     *     is a qualified name ("prefix:local"), the prefix will be looked up 
     511     *     in the parsers {namespaces} object.  If the prefix is found, 
     512     *     setAttributeNS will be used instead of setAttribute. 
     513     */ 
     514    setAttributes: function(node, obj) { 
     515        var value, loc, alias, uri; 
     516        for(var name in obj) { 
     517            if(obj[name] != null && obj[name].toString) { 
     518                value = obj[name].toString(); 
     519                // check for qualified attribute name ("prefix:local") 
     520                uri = this.namespaces[name.substring(0, name.indexOf(":"))] || null; 
     521                this.setAttributeNS(node, uri, name, value); 
     522            } 
     523        } 
     524    }, 
     525 
     526    /** 
     527     * Method: readNode 
     528     * Shorthand for applying one of the named readers given the node 
     529     *     namespace and local name.  Readers take two args (node, obj) and 
     530     *     generally extend or modify the second. 
     531     * 
     532     * Parameters: 
     533     * node - {DOMElement} The node to be read (required). 
     534     * obj - {Object} The object to be modified (optional). 
     535     * 
     536     * Returns: 
     537     * {Object} The input object, modified (or a new one if none was provided). 
     538     */ 
     539    readNode: function(node, obj) { 
     540        if(!obj) { 
     541            obj = {}; 
     542        } 
     543        var group = this.readers[this.namespaceAlias[node.namespaceURI]]; 
     544        if(group) { 
     545            var local = node.localName || node.nodeName.split(":").pop(); 
     546            var reader = group[local] || group["*"]; 
     547            if(reader) { 
     548                reader.apply(this, [node, obj]); 
     549            } 
     550        } 
     551        return obj; 
     552    }, 
     553 
     554    /** 
     555     * Method: readChildNodes 
     556     * Shorthand for applying the named readers to all children of a node. 
     557     *     For each child of type 1 (element), <readSelf> is called. 
     558     * 
     559     * Parameters: 
     560     * node - {DOMElement} The node to be read (required). 
     561     * obj - {Object} The object to be modified (optional). 
     562     * 
     563     * Returns: 
     564     * {Object} The input object, modified. 
     565     */ 
     566    readChildNodes: function(node, obj) { 
     567        if(!obj) { 
     568            obj = {}; 
     569        } 
     570        var children = node.childNodes; 
     571        var child; 
     572        for(var i=0, len=children.length; i<len; ++i) { 
     573            child = children[i]; 
     574            if(child.nodeType == 1) { 
     575                this.readNode(child, obj); 
     576            } 
     577        } 
     578        return obj; 
     579    }, 
     580 
     581    /** 
     582     * Method: writeNode 
     583     * Shorthand for applying one of the named writers and appending the 
     584     *     results to a node.  If a qualified name is not provided for the 
     585     *     second argument (and a local name is used instead), the namespace 
     586     *     of the parent node will be assumed. 
     587     * 
     588     * Parameters: 
     589     * name - {String} The name of a node to generate.  If a qualified name 
     590     *     (e.g. "pre:Name") is used, the namespace prefix is assumed to be 
     591     *     in the <writers> group.  If a local name is used (e.g. "Name") then 
     592     *     the namespace of the parent is assumed.  If a local name is used 
     593     *     and no parent is supplied, then the default namespace is assumed. 
     594     * obj - {Object} Structure containing data for the writer. 
     595     * parent - {DOMElement} Result will be appended to this node.  If no parent 
     596     *     is supplied, the node will not be appended to anything. 
     597     * 
     598     * Returns: 
     599     * {DOMElement} The child node. 
     600     */ 
     601    writeNode: function(name, obj, parent) { 
     602        var prefix, local; 
     603        var split = name.indexOf(":"); 
     604        if(split > 0) { 
     605            prefix = name.substring(0, split); 
     606            local = name.substring(split + 1); 
     607        } else { 
     608            if(parent) { 
     609                prefix = this.namespaceAlias[parent.namespaceURI]; 
     610            } else { 
     611                prefix = this.defaultPrefix; 
     612            } 
     613            local = name; 
     614        } 
     615        var child = this.writers[prefix][local].apply(this, [obj]); 
     616        if(parent) { 
     617            parent.appendChild(child); 
     618        } 
     619        return child; 
     620    }, 
     621 
    387622    CLASS_NAME: "OpenLayers.Format.XML"  
    388623 
  • branches/openlayers/2.7/lib/OpenLayers/Layer/TMS.js

    r6418 r8012  
    66/** 
    77 * @requires OpenLayers/Layer/Grid.js 
     8 * @requires OpenLayers/Tile/Image.js 
    89 */ 
    910 
  • branches/openlayers/2.7/lib/OpenLayers/Layer/Vector.js

    r7959 r8012  
    3939     *  - *beforefeatureadded* Triggered before a feature is added.  Listeners 
    4040     *      will receive an object with a *feature* property referencing the 
    41      *      feature to be added. 
     41     *      feature to be added.  To stop the feature from being added, a 
     42     *      listener should return false. 
     43     *  - *beforefeaturesadded* Triggered before an array of features is added. 
     44     *      Listeners will receive an object with a *features* property 
     45     *      referencing the feature to be added. To stop the features from 
     46     *      being added, a listener should return false. 
    4247     *  - *featureadded* Triggered after a feature is added.  The event 
    4348     *      object passed to listeners will have a *feature* property with a 
     
    7378     *      for a new set of features. 
    7479     */ 
    75     EVENT_TYPES: ["beforefeatureadded", "featureadded", "featuresadded", 
     80    EVENT_TYPES: ["beforefeatureadded", "beforefeaturesadded", 
     81                  "featureadded", "featuresadded", 
    7682                  "beforefeatureremoved", "featureremoved", "featuresremoved", 
    7783                  "beforefeatureselected", "featureselected", "featureunselected",  
     
    408414             
    409415            if(!zoomChanged && coordSysUnchanged) { 
    410                 var unrenderedFeatures = {}; 
    411416                for(var i in this.unrenderedFeatures) { 
    412417                    var feature = this.unrenderedFeatures[i]; 
    413                     if(!this.drawFeature(feature)) { 
    414                         unrenderedFeatures[i] = feature; 
    415                     } 
     418                    this.drawFeature(feature); 
    416419                } 
    417                 this.unrenderedFeatures = unrenderedFeatures; 
    418420            } 
    419421        } 
    420422         
    421423        if (!this.drawn || zoomChanged || !coordSysUnchanged) { 
    422             this.unrenderedFeatures = {}; 
    423424            this.drawn = true; 
    424425            var feature; 
     
    430431                }     
    431432                feature = this.features[i]; 
    432                 if (!this.drawFeature(feature)) { 
    433                     this.unrenderedFeatures[feature.id] = feature; 
    434                 }; 
     433                this.drawFeature(feature); 
    435434            } 
    436435        }     
     
    451450         
    452451        var notify = !options || !options.silent; 
     452        if(notify) { 
     453            var event = {features: features}; 
     454            var ret = this.events.triggerEvent("beforefeaturesadded", event); 
     455            if(ret === false) { 
     456                return; 
     457            } 
     458            features = event.features; 
     459        } 
     460         
    453461 
    454462        for (var i=0, len=features.length; i<len; i++) { 
     
    477485 
    478486            if (notify) { 
    479                 this.events.triggerEvent("beforefeatureadded", { 
    480                     feature: feature 
    481                 }); 
     487                if(this.events.triggerEvent("beforefeatureadded", 
     488                                            {feature: feature}) === false) { 
     489                    continue; 
     490                }; 
    482491                this.preFeatureInsert(feature); 
    483492            } 
    484493 
    485494            if (this.drawn) { 
    486                 if(!this.drawFeature(feature)) { 
    487                     this.unrenderedFeatures[feature.id] = feature; 
    488                 } 
     495                this.drawFeature(feature); 
    489496            } 
    490497             
     
    604611     * feature - {<OpenLayers.Feature.Vector>}  
    605612     * style - {Object} Symbolizer hash or {String} renderIntent 
    606      *  
    607      * Returns: 
    608      * {Boolean} true if the renderer was able to draw the feature, false 
    609      *     otherwise 
    610613     */ 
    611614    drawFeature: function(feature, style) { 
     
    619622        } 
    620623         
    621         return this.renderer.drawFeature(feature, style); 
     624        if (!this.renderer.drawFeature(feature, style)) { 
     625            this.unrenderedFeatures[feature.id] = feature; 
     626        } else { 
     627            delete this.unrenderedFeatures[feature.id]; 
     628        }; 
    622629    }, 
    623630     
  • branches/openlayers/2.7/lib/OpenLayers/Map.js

    r7889 r8012  
    168168    /** 
    169169     * Property: controls 
    170      * {Array(<OpenLayers.Control>)} List of controls associated with the map 
     170     * {Array(<OpenLayers.Control>)} List of controls associated with the map. 
     171     * 
     172     * If not provided in the map options at construction, the map will 
     173     *     be given the following controls by default: 
     174     *  - <OpenLayers.Control.Navigation> 
     175     *  - <OpenLayers.Control.PanZoom> 
     176     *  - <OpenLayers.Control.ArgParser> 
     177     *  - <OpenLayers.Control.Attribution> 
    171178     */