OpenLayers OpenLayers

Changeset 5518

Show
Ignore:
Timestamp:
12/19/07 17:17:27 (1 year ago)
Author:
enjahova
Message:

merged trunk from 5367 to 5510

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/enjahova/openlayers/apidoc_config/Menu.txt

    r5289 r5518  
    169169      }  # Group: Marker 
    170170 
     171   File: Projection  (no auto-title, OpenLayers/Projection.js) 
     172 
    171173   Group: Popup  { 
    172174 
  • sandbox/enjahova/openlayers/doc/authors.txt

    r5238 r5518  
    1414Philip Lindsay 
    1515Corey Puffault 
     16Gregers Rygg 
    1617Tim Schaub 
    1718Christopher Schmidt 
  • sandbox/enjahova/openlayers/doc_config/Menu.txt

    r5289 r5518  
    169169      }  # Group: Marker 
    170170 
     171   File: Projection  (no auto-title, OpenLayers/Projection.js) 
     172 
    171173   Group: Popup  { 
    172174 
  • sandbox/enjahova/openlayers/examples/custom-control.html

    r5362 r5518  
    3434 
    3535                    notice: function (bounds) { 
    36                         alert(bounds); 
     36                        var ll = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.left, bounds.bottom));  
     37                        var ur = map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.right, bounds.top));  
     38                        alert(ll.lon.toFixed(4) + ", " +  
     39                              ll.lat.toFixed(4) + ", " +  
     40                              ur.lon.toFixed(4) + ", " +  
     41                              ur.lat.toFixed(4)); 
    3742                    } 
    3843                }); 
  • sandbox/enjahova/openlayers/examples/modify-feature.html

    r5362 r5518  
    7070         
    7171        function update() { 
     72            // reset modification mode 
     73            controls.modify.mode = OpenLayers.Control.ModifyFeature.RESHAPE; 
    7274            var rotate = document.getElementById("rotate").checked; 
    73             controls.modify.rotate = rotate; 
     75            if(rotate) { 
     76                controls.modify.mode |= OpenLayers.Control.ModifyFeature.ROTATE; 
     77            } 
    7478            var resize = document.getElementById("resize").checked; 
    75             controls.modify.resize = resize; 
     79            if(resize) { 
     80                controls.modify.mode |= OpenLayers.Control.ModifyFeature.RESIZE; 
     81            } 
    7682            var drag = document.getElementById("drag").checked; 
    77             controls.modify.drag = drag; 
     83            if(drag) { 
     84                controls.modify.mode |= OpenLayers.Control.ModifyFeature.DRAG; 
     85            } 
     86            // disable reshape mode if at least one of modes rotate, resize, 
     87            // drag is enabled 
     88            if (rotate || resize || drag) { 
     89                controls.modify.mode &= ~OpenLayers.Control.ModifyFeature.RESHAPE; 
     90            } 
    7891            var sides = parseInt(document.getElementById("sides").value); 
    7992            sides = Math.max(3, isNaN(sides) ? 0 : sides); 
     
    98111  <body onload="init()"> 
    99112    <h3 id="title">OpenLayers Modify Feature Example</h3> 
    100     <div id="shortdesc">A demonstraton of the ModifyFeature control for editing vector features.</div> 
     113    <div id="shortdesc">A demonstration of the ModifyFeature control for editing vector features.</div> 
    101114    <div id="map"></div> 
    102115    <div id="controls"> 
  • sandbox/enjahova/openlayers/examples/select-feature.html

    r5362 r5518  
    1414    <script src="../lib/OpenLayers.js"></script> 
    1515    <script type="text/javascript"> 
    16         var map, drawControls, select
     16        var map, drawControls
    1717        OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2'; 
    1818        function init(){ 
     
    3939                    vectors, OpenLayers.Handler.Polygon 
    4040                ), 
    41                 select: new OpenLayers.Control.SelectFeature(vectors), 
    42                 hover: new OpenLayers.Control.SelectFeature( 
    43                     vectors, {hover: true} 
     41                select: new OpenLayers.Control.SelectFeature( 
     42                    vectors, 
     43                    { 
     44                        clickout: false, toggle: false, 
     45                        multiple: false, hover: false, 
     46                        toggleKey: "ctrlKey", // ctrl key removes from selection 
     47                        multipleKey: "shiftKey" // shift key adds to selection 
     48                    } 
    4449                ) 
    4550            }; 
     
    6065                    control.deactivate(); 
    6166                } 
     67            } 
     68        } 
     69 
     70        function update() { 
     71            var clickout = document.getElementById("clickout").checked; 
     72            drawControls.select.clickout = clickout; 
     73            var hover = document.getElementById("hover").checked; 
     74            drawControls.select.hover = hover; 
     75            if(hover && drawControls.select.active) { 
     76                // turn on/off to clear feature property of handler 
     77                drawControls.select.deactivate(); 
     78                drawControls.select.activate(); 
    6279            } 
    6380        } 
     
    95112            <input type="radio" name="type" value="select" id="selectToggle" 
    96113                   onclick="toggleControl(this);" /> 
    97             <label for="selectToggle">select feature on click</label> 
     114            <label for="selectToggle">select feature</label> 
     115            <ul> 
     116                <li> 
     117                    <input id="clickout" type="checkbox" 
     118                           name="clickout" onchange="update()" /> 
     119                    <label for="clickout">click out to unselect features</label> 
     120                </li> 
     121                <li> 
     122                    <input id="hover" type="checkbox" 
     123                           name="hover" onchange="update()" /> 
     124                    <label for="hover">hover to select features</label> 
     125                </li> 
     126            </ul> 
    98127        </li> 
    99         <li> 
    100             <input type="radio" name="type" value="hover" id="hoverToggle" 
    101                    onclick="toggleControl(this);" /> 
    102             <label for="hoverToggle">select feature on hover</label> 
    103         </li> 
    104     </ul>         
     128    </ul> 
     129    <p>Use the shift key to select multiple features.  Use the ctrl key to 
     130    toggle selection on features one at a time.  Note: the "clickout" option has no 
     131    effect when "hover" is selected.</p> 
    105132  </body> 
    106133</html> 
  • sandbox/enjahova/openlayers/lib/OpenLayers.js

    r5413 r5518  
    7979            "OpenLayers/Ajax.js", 
    8080            "OpenLayers/Events.js", 
     81            "OpenLayers/Projection.js", 
    8182            "OpenLayers/Map.js", 
    8283            "OpenLayers/Layer.js", 
     
    116117            "OpenLayers/Feature/WFS.js", 
    117118            "OpenLayers/Handler.js", 
     119            "OpenLayers/Handler/Click.js", 
    118120            "OpenLayers/Handler/Point.js", 
    119121            "OpenLayers/Handler/Path.js", 
     
    168170            "OpenLayers/Layer/Vector.js", 
    169171            "OpenLayers/Layer/GML.js", 
     172            "OpenLayers/Style.js", 
     173            "OpenLayers/Rule.js", 
     174            "OpenLayers/Rule/FeatureId.js", 
     175            "OpenLayers/Rule/Logical.js", 
     176            "OpenLayers/Rule/Comparison.js", 
    170177            "OpenLayers/Format.js", 
    171178            "OpenLayers/Format/XML.js", 
     
    175182            "OpenLayers/Format/WFS.js", 
    176183            "OpenLayers/Format/WKT.js", 
     184            "OpenLayers/Format/Text.js", 
    177185            "OpenLayers/Format/JSON.js", 
    178186            "OpenLayers/Format/GeoJSON.js", 
     
    183191        ); // etc. 
    184192 
    185  
    186  
    187         var allScriptTags = ""; 
    188         var host = OpenLayers._getScriptLocation() + "lib/"; 
    189      
     193        var agent = navigator.userAgent; 
     194        var docWrite = (agent.match("MSIE") || agent.match("Safari")); 
     195        if(docWrite) { 
     196            var allScriptTags = new Array(jsfiles.length); 
     197        } 
     198        var host = OpenLayers._getScriptLocation() + "lib/";     
    190199        for (var i = 0; i < jsfiles.length; i++) { 
    191             if (/MSIE/.test(navigator.userAgent) || /Safari/.test(navigator.userAgent)) { 
    192                 var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";  
    193                 allScriptTags += currentScriptTag; 
     200            if (docWrite) { 
     201                allScriptTags[i] = "<script src='" + host + jsfiles[i] + 
     202                                   "'></script>";  
    194203            } else { 
    195204                var s = document.createElement("script"); 
     
    201210            } 
    202211        } 
    203         if (allScriptTags) { 
    204             document.write(allScriptTags); 
     212        if (docWrite) { 
     213            document.write(allScriptTags.join("")); 
    205214        } 
    206215    } 
  • sandbox/enjahova/openlayers/lib/OpenLayers/BaseTypes/Bounds.js

    r4985 r5518  
    426426        return quadrant;  
    427427    }, 
     428     
     429    /** 
     430     * APIMethod: transform 
     431     * Transform the Bounds object from source to dest.  
     432     * 
     433     * Parameters:  
     434     * source - {<OpenLayers.Projection>} Source projection.  
     435     * dest   - {<OpenLayers.Projection>} Destination projection.  
     436     * 
     437     * Returns: 
     438     * {<OpenLayers.Bounds>} Itself, for use in chaining operations. 
     439     */ 
     440    transform: function(source, dest) { 
     441        var ll = OpenLayers.Projection.transform( 
     442            {'x': this.left, 'y': this.bottom}, source, dest); 
     443        var ur = OpenLayers.Projection.transform( 
     444            {'x': this.right, 'y': this.top}, source, dest); 
     445        this.left   = ll.x; 
     446        this.bottom = ll.y; 
     447        this.right  = ur.x; 
     448        this.top    = ur.y; 
     449        return this; 
     450    }, 
    428451 
    429452    /** 
  • sandbox/enjahova/openlayers/lib/OpenLayers/BaseTypes/LonLat.js

    r4985 r5518  
    113113        return equals; 
    114114    }, 
     115 
     116    /** 
     117     * APIMethod: transform 
     118     * Transform the LonLat object from source to dest.  
     119     * 
     120     * Parameters:  
     121     * source - {<OpenLayers.Projection>} Source projection.  
     122     * dest   - {<OpenLayers.Projection>} Destination projection.  
     123     * 
     124     * Returns: 
     125     * {<OpenLayers.LonLat>} Itself, for use in chaining operations. 
     126     */ 
     127    transform: function(source, dest) { 
     128        var point = OpenLayers.Projection.transform( 
     129            {'x': this.lon, 'y': this.lat}, source, dest); 
     130        this.lon = point.x; 
     131        this.lat = point.y; 
     132        return this; 
     133    }, 
    115134     
    116135    /** 
  • sandbox/enjahova/openlayers/lib/OpenLayers/Control/ModifyFeature.js

    r5301 r5518  
    3030 
    3131    /** 
     32     * APIProperty: clickout 
     33     * {Boolean} Unselect features when clicking outside any feature. 
     34     *     Default is true. 
     35     */ 
     36    clickout: true, 
     37 
     38    /** 
     39     * APIProperty: toggle 
     40     * {Boolean} Unselect a selected feature on click. 
     41     *      Default is true. 
     42     */ 
     43    toggle: true, 
     44 
     45    /** 
    3246     * Property: layer 
    3347     * {<OpenLayers.Layer.Vector>} 
     
    89103 
    90104    /** 
    91      * APIProperty: rotate 
    92      * {Boolean} Allow rotation of feature instead of vertex modification. 
    93      */ 
    94     rotate: false, 
    95  
    96     /** 
    97      * APIProperty: resize 
    98      * {Boolean} Allow resizing of feature instead of vertex modification. 
    99      */ 
    100     resize: false, 
     105     * APIProperty: mode 
     106     * {Integer} Bitfields specifying the modification mode. Defaults to 
     107     *      OpenLayers.Control.ModifyFeature.RESHAPE. To set the mode to a 
     108     *      combination of options, use the | operator. or example, to allow 
     109     *      the control to both resize and rotate features, use the following 
     110     *      syntax 
     111     * (code) 
     112     * control.mode = OpenLayers.Control.ModifyFeature.RESIZE | 
     113     *                OpenLayers.Control.ModifyFeature.ROTATE; 
     114     *  (end) 
     115     */ 
     116    mode: null, 
    101117 
    102118    /** 
     
    106122    radiusHandle: null, 
    107123 
    108     /** 
    109      * APIProperty: drag 
    110      * {Boolean} Allow dragging of feature with a drag handle. 
    111      */ 
    112     drag: false, 
    113      
    114124    /** 
    115125     * Property: dragHandle 
     
    160170        this.styleVirtual.strokeOpacity = 0.3; 
    161171        this.deleteCodes = [46, 100]; 
     172        this.mode = OpenLayers.Control.ModifyFeature.RESHAPE; 
    162173        OpenLayers.Control.prototype.initialize.apply(this, [options]); 
    163174        if(!(this.deleteCodes instanceof Array)) { 
     
    169180        var selectOptions = { 
    170181            geometryTypes: this.geometryTypes, 
     182            clickout: this.clickout, 
     183            toggle: this.toggle, 
    171184            onSelect: function(feature) { 
    172185                control.selectFeature.apply(control, [feature]); 
     
    428441        if(this.feature && 
    429442           this.feature.geometry.CLASS_NAME != "OpenLayers.Geometry.Point") { 
    430             if(this.drag) { 
     443            if((this.mode & OpenLayers.Control.ModifyFeature.DRAG)) { 
    431444                this.collectDragHandle(); 
    432445            } 
    433             if(this.rotate || this.resize) { 
     446            if((this.mode & (OpenLayers.Control.ModifyFeature.ROTATE | 
     447                             OpenLayers.Control.ModifyFeature.RESIZE))) { 
    434448                this.collectRadiusHandle(); 
    435             } else { 
     449            } 
     450            if((this.mode & OpenLayers.Control.ModifyFeature.RESHAPE)) { 
    436451                this.collectVertices(); 
    437452            } 
     
    516531        } 
    517532        collectComponentVertices.call(this, this.feature.geometry); 
    518         this.layer.addFeatures(this.vertices); 
    519         this.layer.addFeatures(this.virtualVertices); 
     533        this.layer.addFeatures(this.vertices, {silent: true}); 
     534        this.layer.addFeatures(this.virtualVertices, {silent: true}); 
    520535    }, 
    521536 
     
    536551        } 
    537552        this.dragHandle = origin; 
    538         this.layer.addFeatures([this.dragHandle]); 
     553        this.layer.addFeatures([this.dragHandle], {silent: true}); 
    539554    }, 
    540555 
     
    554569        ); 
    555570        var radius = new OpenLayers.Feature.Vector(radiusGeometry); 
    556         var resize = this.resize
    557         var rotate = this.rotate
     571        var resize = (this.mode & OpenLayers.Control.ModifyFeature.RESIZE)
     572        var rotate = (this.mode & OpenLayers.Control.ModifyFeature.ROTATE)
    558573        radiusGeometry.move = function(x, y) { 
    559574            OpenLayers.Geometry.Point.prototype.move.call(this, x, y); 
     
    576591        } 
    577592        this.radiusHandle = radius; 
    578         this.layer.addFeatures([this.radiusHandle]); 
     593        this.layer.addFeatures([this.radiusHandle], {silent: true}); 
    579594    }, 
    580595 
     
    594609    CLASS_NAME: "OpenLayers.Control.ModifyFeature" 
    595610}); 
     611 
     612/** 
     613 * Constant: RESHAPE 
     614 * {Integer} Constant used to make the control work in reshape mode 
     615 */ 
     616OpenLayers.Control.ModifyFeature.RESHAPE = 1; 
     617/** 
     618 * Constant: RESIZE 
     619 * {Integer} Constant used to make the control work in resize mode 
     620 */ 
     621OpenLayers.Control.ModifyFeature.RESIZE = 2; 
     622/** 
     623 * Constant: ROTATE 
     624 * {Integer} Constant used to make the control work in rotate mode 
     625 */ 
     626OpenLayers.Control.ModifyFeature.ROTATE = 4; 
     627/** 
     628 * Constant: DRAG 
     629 * {Integer} Constant used to make the control work in drag mode 
     630 */ 
     631OpenLayers.Control.ModifyFeature.DRAG = 8; 
  • sandbox/enjahova/openlayers/lib/OpenLayers/Control/MousePosition.js

    r4985 r5518  
    1919    /**  
    2020     * APIProperty: prefix 
     21     * {String} 
    2122     */ 
    2223    prefix: '', 
     
    109110 
    110111            lonLat = this.map.getLonLatFromPixel(evt.xy); 
     112            if (!lonLat) {  
     113                // map has not yet been properly initialized 
     114                return; 
     115            }     
    111116            this.lastXy = evt.xy; 
    112117        } 
  • sandbox/enjahova/openlayers/lib/OpenLayers/Control/Permalink.js

    r4985 r5518  
    8989            this.div.className = this.displayClass; 
    9090            this.element = document.createElement("a"); 
    91             this.element.style.fontSize="smaller"; 
    9291            this.element.innerHTML = "Permalink"; 
    9392            this.element.href=""; 
  • sandbox/enjahova/openlayers/lib/OpenLayers/Control/Scale.js

    r5333 r5518  
    4343            this.element = document.createElement("div"); 
    4444            this.div.className = this.displayClass; 
    45             this.element.style.fontSize="smaller"; 
    4645            this.div.appendChild(this.element); 
    4746        } 
  • sandbox/enjahova/openlayers/lib/OpenLayers/Control/SelectFeature.js

    r5157 r5518  
    1717     
    1818    /** 
     19     * Property: multipleKey 
     20     * {String} An event modifier ('altKey' or 'shiftKey') that temporarily sets 
     21     *     the <multiple> property to true.  Default is null. 
     22     */ 
     23    multipleKey: null, 
     24     
     25    /** 
     26     * Property: toggleKey 
     27     * {String} An event modifier ('altKey' or 'shiftKey') that temporarily sets 
     28     *     the <toggle> property to true.  Default is null. 
     29     */ 
     30    toggleKey: null, 
     31     
     32    /** 
    1933     * APIProperty: multiple 
    20      * {Boolean} Allow selection of multiple geometries 
     34     * {Boolean} Allow selection of multiple geometries.  Default is false. 
    2135     */ 
    2236    multiple: false,  
     37 
     38    /** 
     39     * APIProperty: clickout 
     40     * {Boolean} Unselect features when clicking outside any feature. 
     41     *     Default is true. 
     42     */ 
     43    clickout: true, 
     44 
     45    /** 
     46     * APIProperty: toggle 
     47     * {Boolean} Unselect a selected feature on click.  Default is false.  Only 
     48     *     has meaning if hover is false. 
     49     */ 
     50    toggle: false, 
    2351 
    2452    /** 
     
    86114        this.callbacks = OpenLayers.Util.extend({ 
    87115                                                  click: this.clickFeature, 
     116                                                  clickout: this.clickoutFeature, 
    88117                                                  over: this.overFeature, 
    89118                                                  out: this.outFeature 
    90119                                                }, this.callbacks); 
    91         var handlerOptions = {geometryTypes: this.geometryTypes}; 
     120        var handlerOptions = { geometryTypes: this.geometryTypes}; 
    92121        this.handler = new OpenLayers.Handler.Feature(this, layer, 
    93122                                                      this.callbacks, 
     
    96125 
    97126    /** 
     127     * Method: unselectAll 
     128     * Unselect all selected features. 
     129     */ 
     130    unselectAll: function() { 
     131        // we'll want an option to supress notification here 
     132        while (this.layer.selectedFeatures.length > 0) { 
     133            this.unselect(this.layer.selectedFeatures[0]); 
     134        } 
     135    }, 
     136 
     137    /** 
    98138     * Method: clickFeature 
    99      * Called when the feature handler detects a click on a feature 
     139     * Called on click in a feature 
     140     * Only responds if this.hover is false. 
    100141     * 
    101142     * Parameters: 
     
    106147            return; 
    107148        } 
    108         if (this.multiple) { 
    109             if(OpenLayers.Util.indexOf(this.layer.selectedFeatures, feature) > -1) { 
     149        var selected = (OpenLayers.Util.indexOf(this.layer.selectedFeatures, 
     150                                                feature) > -1); 
     151        if(!this.multiple && !this.handler.evt[this.multipleKey]) { 
     152            // perhaps an "except" argument 
     153            this.unselectAll(); 
     154        } 
     155        if(selected) { 
     156            if(this.toggle || this.handler.evt[this.toggleKey]) { 
     157                // notify here 
    110158                this.unselect(feature); 
    111159            } else { 
     160                // don't notify here - could be removed if unselectAll is modified 
    112161                this.select(feature); 
    113162            } 
    114163        } else { 
    115             if(OpenLayers.Util.indexOf(this.layer.selectedFeatures, feature) > -1) { 
    116                 this.unselect(feature); 
    117             } else { 
    118                 if (this.layer.selectedFeatures) { 
    119                     for (var i = 0; i < this.layer.selectedFeatures.length; i++) { 
    120                         this.unselect(this.layer.selectedFeatures[i]); 
    121                     } 
    122                 } 
    123                 this.select(feature); 
    124             } 
     164            this.select(feature); 
     165        } 
     166    }, 
     167 
     168    /** 
     169     * Method: clickoutFeature 
     170     * Called on click outside a previously clicked (selected) feature. 
     171     * Only responds if this.hover is false. 
     172     * 
     173     * Parameters: 
     174     * feature - {<OpenLayers.Vector.Feature>}  
     175     */ 
     176    clickoutFeature: function(feature) { 
     177        if(!this.hover && this.clickout) {