OpenLayers OpenLayers

Changeset 5286

Show
Ignore:
Timestamp:
11/27/07 05:59:03 (1 year ago)
Author:
elemoine
Message:

replace with trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/elemoine/regular-polygon/doc/authors.txt

    r3785 r5286  
    44John Cole 
    55Jeff Dege 
     6Roald de Wit 
    67Schuyler Erle 
    78Christian López Espínola 
  • sandbox/elemoine/regular-polygon/examples/modify-feature.html

    r5196 r5286  
    3434             
    3535            var modifyOptions = { 
    36                 regular: true, 
    3736                onModificationStart: function(feature) { 
    3837                    OpenLayers.Console.log("start modifying", feature.id); 
     
    5554                polygon: new OpenLayers.Control.DrawFeature(vectors, 
    5655                            OpenLayers.Handler.Polygon), 
    57                 regular: new OpenLayers.Control.DrawFeature(vectors, 
    58                             OpenLayers.Handler.RegularPolygon, 
    59                             {handlerOptions: {sides: 40}}), 
    6056                modify: new OpenLayers.Control.ModifyFeature(vectors, 
    6157                                                             modifyOptions) 
     
    107103            </li> 
    108104            <li> 
    109                 <input type="radio" name="type" value="regular" id="regularToggle" onclick="toggleControl(this);" /> 
    110                 <label for="regularToggle">draw regular polygon</label> 
    111             </li> 
    112             <li> 
    113105                <input type="radio" name="type" value="modify" id="modifyToggle" 
    114106                       onclick="toggleControl(this);" /> 
  • sandbox/elemoine/regular-polygon/examples/select-feature.html

    r4222 r5286  
    11<html xmlns="http://www.w3.org/1999/xhtml"> 
    22  <head> 
     3    <title>Select Feature</title> 
    34    <style type="text/css"> 
    45        #map { 
     
    1415    <script type="text/javascript"> 
    1516        var map, drawControls, select; 
     17        OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2'; 
    1618        function init(){ 
    1719            map = new OpenLayers.Map('map'); 
    18             var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",  
    19                 "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});  
     20            var wmsLayer = new OpenLayers.Layer.WMS( 
     21                "OpenLayers WMS",  
     22                "http://labs.metacarta.com/wms/vmap0", 
     23                {layers: 'basic'} 
     24            );  
    2025 
    21             var polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer"); 
    22  
    23             map.addLayers([wmsLayer, polygonLayer]); 
     26            var vectors = new OpenLayers.Layer.Vector("Vector Layer"); 
     27            map.addLayers([wmsLayer, vectors]); 
    2428            map.addControl(new OpenLayers.Control.LayerSwitcher()); 
    2529            map.addControl(new OpenLayers.Control.MousePosition()); 
    2630             
    2731            drawControls = { 
    28                 polygon: new OpenLayers.Control.DrawFeature(polygonLayer, 
    29                             OpenLayers.Handler.Polygon), 
    30                 select: new OpenLayers.Control.SelectFeature(polygonLayer), 
    31                 hover: new OpenLayers.Control.SelectFeature(polygonLayer, 
    32                                                             {hover: true}) 
     32                point: new OpenLayers.Control.DrawFeature( 
     33                    vectors, OpenLayers.Handler.Point 
     34                ), 
     35                line: new OpenLayers.Control.DrawFeature( 
     36                    vectors, OpenLayers.Handler.Path 
     37                ), 
     38                polygon: new OpenLayers.Control.DrawFeature( 
     39                    vectors, OpenLayers.Handler.Polygon 
     40                ), 
     41                select: new OpenLayers.Control.SelectFeature(vectors), 
     42                hover: new OpenLayers.Control.SelectFeature( 
     43                    vectors, {hover: true} 
     44                ) 
    3345            }; 
    3446             
     
    5365  </head> 
    5466  <body onload="init()"> 
    55     <h1>OpenLayers Draw Feature Example</h1
     67    <h3>OpenLayers Select Feature Example</h3
    5668    <div id="map"></div> 
    5769    <ul id="controlToggle"> 
     
    6072                   onclick="toggleControl(this);" checked="checked" /> 
    6173            <label for="noneToggle">navigate</label> 
     74        </li> 
     75        <li> 
     76            <input type="radio" name="type" value="point" id="pointToggle" 
     77                   onclick="toggleControl(this);" /> 
     78            <label for="pointToggle">draw point</label> 
     79        </li> 
     80        <li> 
     81            <input type="radio" name="type" value="line" id="lineToggle" 
     82                   onclick="toggleControl(this);" /> 
     83            <label for="lineToggle">draw line</label> 
    6284        </li> 
    6385        <li> 
     
    6991            <input type="radio" name="type" value="select" id="selectToggle" 
    7092                   onclick="toggleControl(this);" /> 
    71             <label for="selectToggle">select polygon on click</label> 
     93            <label for="selectToggle">select feature on click</label> 
    7294        </li> 
    7395        <li> 
    7496            <input type="radio" name="type" value="hover" id="hoverToggle" 
    7597                   onclick="toggleControl(this);" /> 
    76             <label for="hoverToggle">select polygon on hover</label> 
     98            <label for="hoverToggle">select feature on hover</label> 
    7799        </li> 
    78100    </ul>         
  • sandbox/elemoine/regular-polygon/examples/spherical-mercator.html

    r5064 r5286  
    77            border: 1px solid gray; 
    88        } 
     9        .olControlAttribution { bottom: 0px!important } 
    910    </style> 
    1011 
    1112    <script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script> 
    12     <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script> 
     13    <script src='http://maps.google.com/maps?file=api&amp;v=2.82&amp;key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script> 
    1314    <script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script> 
    1415 
     
    8182                { 
    8283                    type: 'png', getURL: osm_getTileURL, 
    83                     displayOutsideMaxExtent: true 
     84                    displayOutsideMaxExtent: true, 
     85                    attribution: '<a href="http://www.openstreetmap.org/">OpenStreetMap</a>' 
    8486                } 
    8587            ); 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Control/ModifyFeature.js

    r5196 r5286  
    8787     */ 
    8888    virtualStyle: null, 
    89  
    90     /** 
    91      * APIProperty: regular 
    92      * {Boolean} If true, regular polygons will remain regular polygons after 
    93      *     modifications. 
    94      */ 
    95     regular: false, 
    9689     
    9790    /** 
     
    393386            if(vertex && 
    394387               OpenLayers.Util.indexOf(this.vertices, vertex) != -1 && 
    395                !this.dragControl.dragHandler.dragging && 
    396                vertex.geometry.parent /* don't remove pseudo 
    397                                          points from regular polygons */) { 
     388               !this.dragControl.dragHandler.dragging) { 
    398389                // remove the vertex 
    399390                vertex.geometry.parent.removeComponent(vertex.geometry); 
     
    417408        function collectComponentVertices(geometry) { 
    418409            var i, vertex, component; 
    419             if(this.regular && 
    420                geometry.regular && 
    421                geometry.CLASS_NAME == "OpenLayers.Geometry.Polygon") { 
    422                 // deal with regular polygons 
    423                 this.collectRegularPolygonVertices(geometry); 
    424             } else if(geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { 
     410            if(geometry.CLASS_NAME == "OpenLayers.Geometry.Point") { 
    425411                vertex = new OpenLayers.Feature.Vector(geometry); 
    426412                control.vertices.push(vertex); 
     
    458444            } 
    459445        }        
    460         collectComponentVertices.call(this, this.feature.geometry); 
    461     }, 
    462  
    463     /** 
    464      * Method: collectRegularPolygonVertices 
    465      * Collect the vertices from the regular polygon (center, radius). 
    466      */ 
    467     collectRegularPolygonVertices: function(regularPolygon) { 
    468         var points = regularPolygon.components[0].components; 
    469          
    470         var centerGeometry = new OpenLayers.Geometry.Point( 
    471             regularPolygon.origin.x, regularPolygon.origin.y); 
    472         var center = new OpenLayers.Feature.Vector(centerGeometry); 
    473  
    474         var radiusGeometry = points[0].clone(); 
    475         var radius = new OpenLayers.Feature.Vector(radiusGeometry); 
    476  
    477         var numPoints = points.length - 1; 
    478         var layer = this.layer; 
    479  
    480         centerGeometry.move = function(x, y) { 
    481             OpenLayers.Geometry.Point.prototype.move.call(this, x, y); 
    482             OpenLayers.Geometry.Point.prototype.move.call(radiusGeometry, x, y); 
    483             regularPolygon.move(x, y); 
    484             layer.drawFeature(radius); 
    485         } 
    486  
    487         radiusGeometry.move = function(x, y) { 
    488             OpenLayers.Geometry.Point.prototype.move.call(this, x, y); 
    489             var dy = this.y - centerGeometry.y; 
    490             var dx = this.x - centerGeometry.x; 
    491             var angle = Math.atan2(dy, dx); 
    492             angle -= Math.PI * ((1 / numPoints) - (1 / 2)); 
    493             angle *= 180 / Math.PI; 
    494             radius = Math.sqrt(dx * dx + dy * dy); 
    495             regularPolygon.removeComponent(regularPolygon.components[0]); 
    496             regularPolygon.addComponent( 
    497                 OpenLayers.Geometry.Polygon.createRegularLinearRing( 
    498                     centerGeometry, radius, numPoints, angle)); 
    499             regularPolygon.radius = radius; 
    500             regularPolygon.rotation = angle; 
    501         } 
    502  
    503         this.vertices.push(center); 
    504         this.vertices.push(radius); 
     446        collectComponentVertices(this.feature.geometry); 
    505447    }, 
    506448 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Events.js

    r5002 r5286  
    296296     
    297297        //actually remove the event listener from browser 
    298         if (element.removeEventListener) { 
    299             element.removeEventListener(name, observer, useCapture); 
    300         } else if (element && element.detachEvent) { 
    301             element.detachEvent('on' + name, observer); 
     298        if (foundEntry) { 
     299            if (element.removeEventListener) { 
     300                element.removeEventListener(name, observer, useCapture); 
     301            } else if (element && element.detachEvent) { 
     302                element.detachEvent('on' + name, observer); 
     303            } 
    302304        } 
    303305        return foundEntry; 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Format/GML.js

    r5028 r5286  
    7373     
    7474    /** 
     75     * APIProperty: xy 
     76     * {Boolean} Order of the GML coordinate true:(x,y) or false:(y,x) 
     77     * Changing is not recommended, a new Format should be instantiated. 
     78     */  
     79    xy: true, 
     80     
     81    /** 
    7582     * Constructor: OpenLayers.Format.GML 
    7683     * Create a new parser for GML. 
     
    131138        var order = ["MultiPolygon", "Polygon", 
    132139                     "MultiLineString", "LineString", 
    133                      "MultiPoint", "Point"]; 
     140                     "MultiPoint", "Point", "Envelope"]; 
    134141        var type, nodeList, geometry, parser; 
    135142        for(var i=0; i<order.length; ++i) { 
     
    198205             * 3) <gml:coord><gml:X>x</gml:X><gml:Y>y</gml:Y></gml:coord> 
    199206             */ 
    200             var nodeList
     207            var nodeList, coordString
    201208            var coords = []; 
    202209 
     
    204211            var nodeList = this.getElementsByTagNameNS(node, this.gmlns, "pos"); 
    205212            if(nodeList.length > 0) { 
    206                 var coordString = nodeList[0].firstChild.nodeValue; 
     213                coordString = nodeList[0].firstChild.nodeValue; 
    207214                coordString = coordString.replace(this.regExes.trimSpace, ""); 
    208215                coords = coordString.split(this.regExes.splitSpace); 
     
    241248                coords[2] = null; 
    242249            } 
    243             return new OpenLayers.Geometry.Point(coords[0], coords[1], 
     250             
     251            if (this.xy) { 
     252                return new OpenLayers.Geometry.Point(coords[0], coords[1], 
    244253                                                 coords[2]); 
     254            } 
     255            else{ 
     256                return new OpenLayers.Geometry.Point(coords[1], coords[0], 
     257                                                 coords[2]); 
     258            } 
    245259        }, 
    246260         
     
    306320                    y = coords[j+1]; 
    307321                    z = (dim == 2) ? null : coords[j+2]; 
    308                     points.push(new OpenLayers.Geometry.Point(x, y, z)); 
     322                    if (this.xy) { 
     323                        points.push(new OpenLayers.Geometry.Point(x, y, z)); 
     324                    } else { 
     325                        points.push(new OpenLayers.Geometry.Point(y, x, z)); 
     326                    } 
    309327                } 
    310328            } 
     
    326344                            coords[2] = null; 
    327345                        } 
    328                         points.push(new OpenLayers.Geometry.Point(coords[0], 
     346                        if (this.xy) { 
     347                            points.push(new OpenLayers.Geometry.Point(coords[0], 
    329348                                                                  coords[1], 
    330349                                                                  coords[2])); 
     350                        } else { 
     351                            points.push(new OpenLayers.Geometry.Point(coords[1], 
     352                                                                  coords[0], 
     353                                                                  coords[2])); 
     354                        } 
    331355                    } 
    332356                } 
     
    427451            } 
    428452            return new OpenLayers.Geometry.MultiPolygon(components); 
     453        }, 
     454         
     455        envelope: function(node) { 
     456            var components = []; 
     457            var coordString; 
     458            var envelope; 
     459             
     460            var lpoint = this.getElementsByTagNameNS(node, this.gmlns, "lowerCorner"); 
     461            if (lpoint.length > 0) { 
     462                var coords = []; 
     463                 
     464                if(lpoint.length > 0) { 
     465                    coordString = lpoint[0].firstChild.nodeValue; 
     466                    coordString = coordString.replace(this.regExes.trimSpace, ""); 
     467                    coords = coordString.split(this.regExes.splitSpace); 
     468                } 
     469                 
     470                if(coords.length == 2) { 
     471                    coords[2] = null; 
     472                } 
     473                if (this.xy) { 
     474                    var lowerPoint = new OpenLayers.Geometry.Point(coords[0], coords[1],coords[2]); 
     475                } else { 
     476                    var lowerPoint = new OpenLayers.Geometry.Point(coords[1], coords[0],coords[2]); 
     477                } 
     478            } 
     479             
     480            var upoint = this.getElementsByTagNameNS(node, this.gmlns, "upperCorner"); 
     481            if (upoint.length > 0) { 
     482                var coords = []; 
     483                 
     484                if(upoint.length > 0) { 
     485                    coordString = upoint[0].firstChild.nodeValue; 
     486                    coordString = coordString.replace(this.regExes.trimSpace, ""); 
     487                    coords = coordString.split(this.regExes.splitSpace); 
     488                } 
     489                 
     490                if(coords.length == 2) { 
     491                    coords[2] = null; 
     492                } 
     493                if (this.xy) { 
     494                    var upperPoint = new OpenLayers.Geometry.Point(coords[0], coords[1],coords[2]); 
     495                } else { 
     496                    var upperPoint = new OpenLayers.Geometry.Point(coords[1], coords[0],coords[2]); 
     497                } 
     498            } 
     499             
     500            if (lowerPoint && upperPoint) { 
     501                components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y)); 
     502                components.push(new OpenLayers.Geometry.Point(upperPoint.x, lowerPoint.y)); 
     503                components.push(new OpenLayers.Geometry.Point(upperPoint.x, upperPoint.y)); 
     504                components.push(new OpenLayers.Geometry.Point(lowerPoint.x, upperPoint.y)); 
     505                components.push(new OpenLayers.Geometry.Point(lowerPoint.x, lowerPoint.y)); 
     506                 
     507                var ring = new OpenLayers.Geometry.LinearRing(components); 
     508                envelope = new OpenLayers.Geometry.Polygon([ring]); 
     509            } 
     510            return envelope;  
    429511        } 
    430512    }, 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Format/GeoRSS.js

    r4985 r5286  
    6060     
    6161    /** 
     62     * Property: gmlParse 
     63     * {Object} GML Format object for parsing features 
     64     * Non-API and only created if necessary 
     65     */ 
     66    gmlParser: null, 
     67 
     68    /** 
     69     * APIProperty: xy 
     70     * {Boolean} Order of the GML coordinate: true:(x,y) or false:(y,x) 
     71     * For GeoRSS the default is (y,x), therefore: false 
     72     */  
     73    xy: false, 
     74     
     75    /** 
    6276     * Constructor: OpenLayers.Format.GeoRSS 
    6377     * Create a new parser for GeoRSS. 
     
    92106                                                this.georssns, 
    93107                                                "polygon"); 
    94          
     108        var where = this.getElementsByTagNameNS(item,  
     109                                                this.georssns,  
     110                                                "where"); 
    95111        if (point.length > 0 || (lat.length > 0 && lon.length > 0)) { 
     112            var location; 
    96113            if (point.length > 0) { 
    97                 var location = OpenLayers.String.trim( 
     114                location = OpenLayers.String.trim( 
    98115                                point[0].firstChild.nodeValue).split(/\s+/); 
    99                  
    100116                if (location.length !=2) { 
    101                     var location = OpenLayers.String.trim( 
     117                    location = OpenLayers.String.trim( 
    102118                                point[0].firstChild.nodeValue).split(/\s*,\s*/); 
    103119                } 
    104120            } else { 
    105                 var location = [parseFloat(lat[0].firstChild.nodeValue), 
     121                location = [parseFloat(lat[0].firstChild.nodeValue), 
    106122                                parseFloat(lon[0].firstChild.nodeValue)]; 
    107123            }     
     124 
    108125            var geometry = new OpenLayers.Geometry.Point(parseFloat(location[1]), 
    109                                                      parseFloat(location[0])); 
     126                                                         parseFloat(location[0])); 
     127               
    110128        } else if (line.length > 0) { 
    111129            var coords = OpenLayers.String.trim(line[0].firstChild.nodeValue).split(/\s+/); 
    112130            var components = [];  
     131            var point; 
    113132            for (var i=0; i < coords.length; i+=2) { 
    114                 var point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), parseFloat(coords[i])); 
     133                point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]),  
     134                                                     parseFloat(coords[i])); 
    115135                components.push(point); 
    116136            } 
     
    119139            var coords = OpenLayers.String.trim(polygon[0].firstChild.nodeValue).split(/\s+/); 
    120140            var components = [];  
     141            var point; 
    121142            for (var i=0; i < coords.length; i+=2) { 
    122                 var point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]), parseFloat(coords[i])); 
     143                point = new OpenLayers.Geometry.Point(parseFloat(coords[i+1]),  
     144                                                     parseFloat(coords[i])); 
    123145                components.push(point); 
    124146            } 
    125147            geometry = new OpenLayers.Geometry.Polygon([new OpenLayers.Geometry.LinearRing(components)]); 
     148        } else if (where.length > 0) {  
     149            if (!this.gmlParser) { 
     150              this.gmlParser = new OpenLayers.Format.GML({'xy': this.xy}); 
     151            } 
     152            var feature = this.gmlParser.parseFeature(where[0]); 
     153            geometry = feature.geometry; 
    126154        } 
    127155        return geometry; 
     
    140168    createFeatureFromItem: function(item) { 
    141169        var geometry = this.createGeometryFromItem(item); 
     170      
    142171        /* Provide defaults for title and description */ 
    143172        var title = this.getChildValue(item, "*", "title", this.featureTitle); 
     
    341370            path = parts.join(" "); 
    342371        } else { 
    343            path = geometry.y + " " + geometry.x; 
     372            path = geometry.y + " " + geometry.x; 
    344373        } 
    345374        return this.createTextNode(path); 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Geometry/Polygon.js

    r5196 r5286  
    2525 
    2626    /** 
    27      * Property: regular 
    28      * {Boolean} Specifies whether the polygon is a regular polygon. 
    29      */ 
    30     regular: false, 
    31  
    32     /** 
    33      * Property: radius 
    34      * {Float} This property is read only and defined only for regular polygons. 
    35      */ 
    36     radius: null, 
    37  
    38     /** 
    39      * Property: rotation 
    40      * {Float} This property is read only and defined only for regular polygons. 
    41      */ 
    42     rotation: null, 
    43  
    44     /** 
    45      * Property: origin  
    46      * {<OpenLayers.Geometry.Point>} This property is read only and defined only 
    47      * for regular polygons. 
    48      */ 
    49     origin: null, 
    50  
    51     /** 
    5227     * Constructor: OpenLayers.Geometry.Polygon 
    5328     * Constructor for a Polygon geometry.  
     
    6338                                                                  arguments); 
    6439    }, 
    65  
    66     /** 
    67      * APIMethod: clone 
    68      * Clone this polygon. 
    69      * 
    70      * Returns: 
    71      * {<OpenLayers.Geometry.Polygon>} An exact clone of this polygon 
    72      */ 
    73     clone: function() { 
    74         var clone = OpenLayers.Geometry.Collection.prototype.clone.call(this); 
    75         clone.regular = this.regular; 
    76         return clone; 
    77     }, 
    78  
     40     
    7941    /**  
    8042     * APIMethod: getArea 
     
    9658    }, 
    9759 
    98     /** 
    99      * Method: move 
    100      * If the polygon has an origin (regular polygons do), also move the 
    101      * origin when moving the polygon. 
    102      */ 
    103     move: function(x, y) { 
    104         if(this.origin) {  // for maintaining regular polygon's attributes 
    105             this.origin.move(x, y); 
    106         } 
    107         OpenLayers.Geometry.Collection.prototype.move.apply(this, arguments); 
    108     }, 
    109  
    11060    CLASS_NAME: "OpenLayers.Geometry.Polygon" 
    11161}); 
     
    12272 * rotation - {Float} original angle of rotation, in degrees. 
    12373 */ 
    124 OpenLayers.Geometry.Polygon.createRegularPolygon = function(origin, radius, 
    125                                                             sides, rotation) { 
    126     var ring = OpenLayers.Geometry.Polygon.createRegularLinearRing( 
    127             origin, radius, sides, rotation); 
    128     var polygon = new OpenLayers.Geometry.Polygon([ring]); 
    129  
    130     //save some attributes (may be used by ModifyFeature) 
    131     polygon.radius = radius; 
    132     polygon.rotation = rotation; 
    133     polygon.origin = origin; 
    134     return polygon; 
    135 }; 
    136  
    137 /** 
    138  * Method: createRegularLinearRing 
    139  * Create a regular linear ring around a radius. Useful for creating circles 
    140  * and the like. 
    141  * 
    142  * Parameters: 
    143  * origin - {<OpenLayers.Geometry.Point>} center of polygon. 
    144  * radius - {Float} distance to vertex, in map units. 
    145  * sides - {Integer} Number of sides. 20 approximates a circle. 
    146  * rotation - {Float} original angle of rotation, in degrees. 
    147  */ 
    148 OpenLayers.Geometry.Polygon.createRegularLinearRing = function(origin, radius, 
    149                                                                sides, rotation) { 
     74OpenLayers.Geometry.Polygon.createRegularPolygon = function(origin, radius, sides, rotation) {   
    15075    var angle = Math.PI * ((1/sides) - (1/2)); 
    15176    if(rotation) { 
    15277        angle += (rotation / 180) * Math.PI; 
    15378    } 
    154     var x, y; 
     79    var rotateAngle, x, y; 
    15580    var points = []; 
    15681    for(var i=0; i<sides; ++i) { 
     
    16085        points.push(new OpenLayers.Geometry.Point(x, y)); 
    16186    } 
    162     return new OpenLayers.Geometry.LinearRing(points); 
     87    var ring = new OpenLayers.Geometry.LinearRing(points); 
     88    return new OpenLayers.Geometry.Polygon([ring]); 
    16389}; 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Handler/RegularPolygon.js

    r5196 r5286  
    293293            this.origin, this.radius, this.sides, this.snapAngle 
    294294        ); 
    295         if (!this.irregular) { 
    296             // mark the polygon as regular 
    297             this.feature.geometry.regular = true; 
    298         } 
    299295    }, 
    300296     
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/EventPane.js

    r5028 r5286  
    1616 */ 
    1717OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, { 
     18     
     19    /** 
     20     * APIProperty: smoothDragPan 
     21     * {Boolean} smoothDragPan determines whether non-public/internal API 
     22     *     methods are used for better performance while dragging EventPane  
     23     *     layers. When not in sphericalMercator mode, the smoother dragging  
     24     *     doesn't actually move north/south directly with the number of  
     25     *     pixels moved, resulting in a slight offset when you drag your mouse  
     26     *     north south with this option on. If this visual disparity bothers  
     27     *     you, you should turn this option off, or use spherical mercator.  
     28     *     Default is on. 
     29     */ 
     30    smoothDragPan: true, 
    1831 
    1932    /** 
     
    226239 
    227240                    var center = this.getMapObjectLonLatFromOLLonLat(newCenter); 
    228                     var zoom = this.getMapObjectZoomFromOLZoom(newZoom); 
    229                     this.setMapObjectCenter(center, zoom); 
     241 
     242                    if (dragging && this.dragPanMapObject &&  
     243                        this.smoothDragPan) { 
     244                        var resolution = this.map.getResolution(); 
     245                        var dX = (newCenter.lon - oldCenter.lon) / resolution; 
     246                        var dY = (newCenter.lat - oldCenter.lat) / resolution; 
     247                        this.dragPanMapObject(dX, dY); 
     248                    } else { 
     249                        var zoom = this.getMapObjectZoomFromOLZoom(newZoom); 
     250                        this.setMapObjectCenter(center, zoom, dragging); 
     251                    } 
    230252                } 
    231253            } 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Google.js

    r5002 r5286  
    6969     * APIProperty: sphericalMercator 
    7070     * {Boolean} Should the map act as a mercator-projected map? This will 
    71      * cause all interactions with the map to be in the actual map projection, 
    72      * which allows support for vector drawing, overlaying other maps, etc.  
     71     *     cause all interactions with the map to be in the actual map  
     72     *     projection, which allows support for vector drawing, overlaying  
     73     *     other maps, etc.  
    7374     */ 
    7475    sphericalMercator: false,  
     
    119120            termsOfUse.style.right = ""; 
    120121            termsOfUse.style.bottom = ""; 
     122 
     123            //can we do smooth panning? (some versions don't) 
     124            if ( !this.mapObject.G || !this.mapObject.G.qb || 
     125                 (typeof this.mapObject.G.qb != "function") ) { 
     126 
     127                this.dragPanMapObject = null; 
     128            } 
    121129 
    122130        } catch (e) { 
     
    336344    
    337345    /** 
     346     * APIMethod: dragPanMapObject 
     347     *  
     348     * Parameters: 
     349     * dX - {Integer} 
     350     * dY - {Integer} 
     351     */ 
     352    dragPanMapObject: function(dX, dY) { 
     353        var newX = this.mapObject.G.left - dX; 
     354        var newY = this.mapObject.G.top + dY; 
     355        this.mapObject.G.qb(newX, newY); 
     356    }, 
     357    
     358    /** 
    338359     * APIMethod: getMapObjectCenter 
    339360     *  
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Grid.js

    r4991 r5286  
    341341 
    342342        var rowidx = 0; 
     343         
     344        var layerContainerDivLeft = parseInt(this.map.layerContainerDiv.style.left); 
     345        var layerContainerDivTop = parseInt(this.map.layerContainerDiv.style.top); 
     346         
    343347     
    344348        do { 
     
    361365 
    362366                var x = tileoffsetx; 
    363                 x -= parseInt(this.map.layerContainerDiv.style.left)
     367                x -= layerContainerDivLeft
    364368 
    365369                var y = tileoffsety; 
    366                 y -= parseInt(this.map.layerContainerDiv.style.top)
     370                y -= layerContainerDivTop
    367371 
    368372                var px = new OpenLayers.Pixel(x, y); 
     
    561565    shiftRow:function(prepend) { 
    562566        var modelRowIndex = (prepend) ? 0 : (this.grid.length - 1); 
    563         var modelRow = this.grid[modelRowIndex]; 
     567        var grid = this.grid; 
     568        var modelRow = grid[modelRowIndex]; 
    564569 
    565570        var resolution = this.map.getResolution(); 
     
    567572        var deltaLat = resolution * -deltaY; 
    568573 
    569         var row = (prepend) ? this.grid.pop() : this.grid.shift(); 
     574        var row = (prepend) ? grid.pop() : grid.shift(); 
    570575 
    571576        for (var i=0; i < modelRow.length; i++) { 
     
    580585 
    581586        if (prepend) { 
    582             this.grid.unshift(row); 
     587            grid.unshift(row); 
    583588        } else { 
    584             this.grid.push(row); 
     589            grid.push(row); 
    585590        } 
    586591    }, 
     
    613618            tile.moveTo(bounds, position); 
    614619            if (prepend) { 
    615                 this.grid[i].unshift(tile); 
     620                row.unshift(tile); 
    616621            } else { 
    617                 this.grid[i].push(tile); 
     622                row.push(tile); 
    618623            } 
    619624        } 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Vector.js

    r4985 r5286  
    318318 
    319319    /** 
    320      * Method: drawFeature 
     320     * APIMethod: drawFeature 
    321321     * Draw (or redraw) a feature on the layer.  If the optional style argument 
    322322     * is included, this style will be used.  If no style is included, the 
  • sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/VirtualEarth.js

    r5002 r5286  
    104104        if (this.mapObject != null) { 
    105105            try { // this is to catch a Mozilla bug without falling apart 
    106                 this.mapObject.LoadMap(null, null, this.type); 
     106 
     107                // The fourth argument is whether the map is 'fixed' -- not  
     108                // draggable. See:  
     109                // http://blogs.msdn.com/virtualearth/archive/2007/09/28/locking-a-virtual-earth-map.aspx 
     110                // 
     111                this.mapObject.LoadMap(null, null, this.type, true); 
     112                this.mapObject.AttachEvent("onmousedown", function() {return true; }); 
     113 
    107114            } catch (e) {