Changeset 5286
- Timestamp:
- 11/27/07 05:59:03 (1 year ago)
- Files:
-
- sandbox/elemoine/regular-polygon/doc/authors.txt (modified) (1 diff)
- sandbox/elemoine/regular-polygon/examples/modify-feature.html (modified) (3 diffs)
- sandbox/elemoine/regular-polygon/examples/select-feature.html (modified) (5 diffs)
- sandbox/elemoine/regular-polygon/examples/smoothDragging.html (copied) (copied from trunk/openlayers/examples/smoothDragging.html)
- sandbox/elemoine/regular-polygon/examples/spherical-mercator.html (modified) (2 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Control/ModifyFeature.js (modified) (4 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Events.js (modified) (1 diff)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Format/GML.js (modified) (8 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Format/GeoRSS.js (modified) (5 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Geometry/Polygon.js (modified) (5 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Handler/RegularPolygon.js (modified) (1 diff)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/EventPane.js (modified) (2 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Google.js (modified) (3 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Grid.js (modified) (6 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Vector.js (modified) (1 diff)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/VirtualEarth.js (modified) (2 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Yahoo.js (modified) (2 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Map.js (modified) (1 diff)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Renderer/Elements.js (modified) (2 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Renderer/SVG.js (modified) (1 diff)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Renderer/VML.js (modified) (2 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Tile/Image.js (modified) (5 diffs)
- sandbox/elemoine/regular-polygon/lib/OpenLayers/Util.js (modified) (4 diffs)
- sandbox/elemoine/regular-polygon/tests/Format/test_GML.html (modified) (3 diffs)
- sandbox/elemoine/regular-polygon/tests/Format/test_GeoRSS.html (modified) (2 diffs)
- sandbox/elemoine/regular-polygon/tests/test_Map.html (modified) (1 diff)
- sandbox/elemoine/regular-polygon/tests/test_Util.html (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/elemoine/regular-polygon/doc/authors.txt
r3785 r5286 4 4 John Cole 5 5 Jeff Dege 6 Roald de Wit 6 7 Schuyler Erle 7 8 Christian López EspÃnola sandbox/elemoine/regular-polygon/examples/modify-feature.html
r5196 r5286 34 34 35 35 var modifyOptions = { 36 regular: true,37 36 onModificationStart: function(feature) { 38 37 OpenLayers.Console.log("start modifying", feature.id); … … 55 54 polygon: new OpenLayers.Control.DrawFeature(vectors, 56 55 OpenLayers.Handler.Polygon), 57 regular: new OpenLayers.Control.DrawFeature(vectors,58 OpenLayers.Handler.RegularPolygon,59 {handlerOptions: {sides: 40}}),60 56 modify: new OpenLayers.Control.ModifyFeature(vectors, 61 57 modifyOptions) … … 107 103 </li> 108 104 <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>113 105 <input type="radio" name="type" value="modify" id="modifyToggle" 114 106 onclick="toggleControl(this);" /> sandbox/elemoine/regular-polygon/examples/select-feature.html
r4222 r5286 1 1 <html xmlns="http://www.w3.org/1999/xhtml"> 2 2 <head> 3 <title>Select Feature</title> 3 4 <style type="text/css"> 4 5 #map { … … 14 15 <script type="text/javascript"> 15 16 var map, drawControls, select; 17 OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2'; 16 18 function init(){ 17 19 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 ); 20 25 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]); 24 28 map.addControl(new OpenLayers.Control.LayerSwitcher()); 25 29 map.addControl(new OpenLayers.Control.MousePosition()); 26 30 27 31 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 ) 33 45 }; 34 46 … … 53 65 </head> 54 66 <body onload="init()"> 55 <h 1>OpenLayers Draw Feature Example</h1>67 <h3>OpenLayers Select Feature Example</h3> 56 68 <div id="map"></div> 57 69 <ul id="controlToggle"> … … 60 72 onclick="toggleControl(this);" checked="checked" /> 61 73 <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> 62 84 </li> 63 85 <li> … … 69 91 <input type="radio" name="type" value="select" id="selectToggle" 70 92 onclick="toggleControl(this);" /> 71 <label for="selectToggle">select polygonon click</label>93 <label for="selectToggle">select feature on click</label> 72 94 </li> 73 95 <li> 74 96 <input type="radio" name="type" value="hover" id="hoverToggle" 75 97 onclick="toggleControl(this);" /> 76 <label for="hoverToggle">select polygonon hover</label>98 <label for="hoverToggle">select feature on hover</label> 77 99 </li> 78 100 </ul> sandbox/elemoine/regular-polygon/examples/spherical-mercator.html
r5064 r5286 7 7 border: 1px solid gray; 8 8 } 9 .olControlAttribution { bottom: 0px!important } 9 10 </style> 10 11 11 12 <script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script> 12 <script src='http://maps.google.com/maps?file=api&v=2 &key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>13 <script src='http://maps.google.com/maps?file=api&v=2.82&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script> 13 14 <script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script> 14 15 … … 81 82 { 82 83 type: 'png', getURL: osm_getTileURL, 83 displayOutsideMaxExtent: true 84 displayOutsideMaxExtent: true, 85 attribution: '<a href="http://www.openstreetmap.org/">OpenStreetMap</a>' 84 86 } 85 87 ); sandbox/elemoine/regular-polygon/lib/OpenLayers/Control/ModifyFeature.js
r5196 r5286 87 87 */ 88 88 virtualStyle: null, 89 90 /**91 * APIProperty: regular92 * {Boolean} If true, regular polygons will remain regular polygons after93 * modifications.94 */95 regular: false,96 89 97 90 /** … … 393 386 if(vertex && 394 387 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) { 398 389 // remove the vertex 399 390 vertex.geometry.parent.removeComponent(vertex.geometry); … … 417 408 function collectComponentVertices(geometry) { 418 409 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") { 425 411 vertex = new OpenLayers.Feature.Vector(geometry); 426 412 control.vertices.push(vertex); … … 458 444 } 459 445 } 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); 505 447 }, 506 448 sandbox/elemoine/regular-polygon/lib/OpenLayers/Events.js
r5002 r5286 296 296 297 297 //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 } 302 304 } 303 305 return foundEntry; sandbox/elemoine/regular-polygon/lib/OpenLayers/Format/GML.js
r5028 r5286 73 73 74 74 /** 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 /** 75 82 * Constructor: OpenLayers.Format.GML 76 83 * Create a new parser for GML. … … 131 138 var order = ["MultiPolygon", "Polygon", 132 139 "MultiLineString", "LineString", 133 "MultiPoint", "Point" ];140 "MultiPoint", "Point", "Envelope"]; 134 141 var type, nodeList, geometry, parser; 135 142 for(var i=0; i<order.length; ++i) { … … 198 205 * 3) <gml:coord><gml:X>x</gml:X><gml:Y>y</gml:Y></gml:coord> 199 206 */ 200 var nodeList ;207 var nodeList, coordString; 201 208 var coords = []; 202 209 … … 204 211 var nodeList = this.getElementsByTagNameNS(node, this.gmlns, "pos"); 205 212 if(nodeList.length > 0) { 206 varcoordString = nodeList[0].firstChild.nodeValue;213 coordString = nodeList[0].firstChild.nodeValue; 207 214 coordString = coordString.replace(this.regExes.trimSpace, ""); 208 215 coords = coordString.split(this.regExes.splitSpace); … … 241 248 coords[2] = null; 242 249 } 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], 244 253 coords[2]); 254 } 255 else{ 256 return new OpenLayers.Geometry.Point(coords[1], coords[0], 257 coords[2]); 258 } 245 259 }, 246 260 … … 306 320 y = coords[j+1]; 307 321 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 } 309 327 } 310 328 } … … 326 344 coords[2] = null; 327 345 } 328 points.push(new OpenLayers.Geometry.Point(coords[0], 346 if (this.xy) { 347 points.push(new OpenLayers.Geometry.Point(coords[0], 329 348 coords[1], 330 349 coords[2])); 350 } else { 351 points.push(new OpenLayers.Geometry.Point(coords[1], 352 coords[0], 353 coords[2])); 354 } 331 355 } 332 356 } … … 427 451 } 428 452 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; 429 511 } 430 512 }, sandbox/elemoine/regular-polygon/lib/OpenLayers/Format/GeoRSS.js
r4985 r5286 60 60 61 61 /** 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 /** 62 76 * Constructor: OpenLayers.Format.GeoRSS 63 77 * Create a new parser for GeoRSS. … … 92 106 this.georssns, 93 107 "polygon"); 94 108 var where = this.getElementsByTagNameNS(item, 109 this.georssns, 110 "where"); 95 111 if (point.length > 0 || (lat.length > 0 && lon.length > 0)) { 112 var location; 96 113 if (point.length > 0) { 97 varlocation = OpenLayers.String.trim(114 location = OpenLayers.String.trim( 98 115 point[0].firstChild.nodeValue).split(/\s+/); 99 100 116 if (location.length !=2) { 101 varlocation = OpenLayers.String.trim(117 location = OpenLayers.String.trim( 102 118 point[0].firstChild.nodeValue).split(/\s*,\s*/); 103 119 } 104 120 } else { 105 varlocation = [parseFloat(lat[0].firstChild.nodeValue),121 location = [parseFloat(lat[0].firstChild.nodeValue), 106 122 parseFloat(lon[0].firstChild.nodeValue)]; 107 123 } 124 108 125 var geometry = new OpenLayers.Geometry.Point(parseFloat(location[1]), 109 parseFloat(location[0])); 126 parseFloat(location[0])); 127 110 128 } else if (line.length > 0) { 111 129 var coords = OpenLayers.String.trim(line[0].firstChild.nodeValue).split(/\s+/); 112 130 var components = []; 131 var point; 113 132 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])); 115 135 components.push(point); 116 136 } … … 119 139 var coords = OpenLayers.String.trim(polygon[0].firstChild.nodeValue).split(/\s+/); 120 140 var components = []; 141 var point; 121 142 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])); 123 145 components.push(point); 124 146 } 125 147 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; 126 154 } 127 155 return geometry; … … 140 168 createFeatureFromItem: function(item) { 141 169 var geometry = this.createGeometryFromItem(item); 170 142 171 /* Provide defaults for title and description */ 143 172 var title = this.getChildValue(item, "*", "title", this.featureTitle); … … 341 370 path = parts.join(" "); 342 371 } else { 343 path = geometry.y + " " + geometry.x;372 path = geometry.y + " " + geometry.x; 344 373 } 345 374 return this.createTextNode(path); sandbox/elemoine/regular-polygon/lib/OpenLayers/Geometry/Polygon.js
r5196 r5286 25 25 26 26 /** 27 * Property: regular28 * {Boolean} Specifies whether the polygon is a regular polygon.29 */30 regular: false,31 32 /**33 * Property: radius34 * {Float} This property is read only and defined only for regular polygons.35 */36 radius: null,37 38 /**39 * Property: rotation40 * {Float} This property is read only and defined only for regular polygons.41 */42 rotation: null,43 44 /**45 * Property: origin46 * {<OpenLayers.Geometry.Point>} This property is read only and defined only47 * for regular polygons.48 */49 origin: null,50 51 /**52 27 * Constructor: OpenLayers.Geometry.Polygon 53 28 * Constructor for a Polygon geometry. … … 63 38 arguments); 64 39 }, 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 79 41 /** 80 42 * APIMethod: getArea … … 96 58 }, 97 59 98 /**99 * Method: move100 * If the polygon has an origin (regular polygons do), also move the101 * origin when moving the polygon.102 */103 move: function(x, y) {104 if(this.origin) { // for maintaining regular polygon's attributes105 this.origin.move(x, y);106 }107 OpenLayers.Geometry.Collection.prototype.move.apply(this, arguments);108 },109 110 60 CLASS_NAME: "OpenLayers.Geometry.Polygon" 111 61 }); … … 122 72 * rotation - {Float} original angle of rotation, in degrees. 123 73 */ 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) { 74 OpenLayers.Geometry.Polygon.createRegularPolygon = function(origin, radius, sides, rotation) { 150 75 var angle = Math.PI * ((1/sides) - (1/2)); 151 76 if(rotation) { 152 77 angle += (rotation / 180) * Math.PI; 153 78 } 154 var x, y;79 var rotateAngle, x, y; 155 80 var points = []; 156 81 for(var i=0; i<sides; ++i) { … … 160 85 points.push(new OpenLayers.Geometry.Point(x, y)); 161 86 } 162 return new OpenLayers.Geometry.LinearRing(points); 87 var ring = new OpenLayers.Geometry.LinearRing(points); 88 return new OpenLayers.Geometry.Polygon([ring]); 163 89 }; sandbox/elemoine/regular-polygon/lib/OpenLayers/Handler/RegularPolygon.js
r5196 r5286 293 293 this.origin, this.radius, this.sides, this.snapAngle 294 294 ); 295 if (!this.irregular) {296 // mark the polygon as regular297 this.feature.geometry.regular = true;298 }299 295 }, 300 296 sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/EventPane.js
r5028 r5286 16 16 */ 17 17 OpenLayers.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, 18 31 19 32 /** … … 226 239 227 240 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 } 230 252 } 231 253 } sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Google.js
r5002 r5286 69 69 * APIProperty: sphericalMercator 70 70 * {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. 73 74 */ 74 75 sphericalMercator: false, … … 119 120 termsOfUse.style.right = ""; 120 121 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 } 121 129 122 130 } catch (e) { … … 336 344 337 345 /** 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 /** 338 359 * APIMethod: getMapObjectCenter 339 360 * sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Grid.js
r4991 r5286 341 341 342 342 var rowidx = 0; 343 344 var layerContainerDivLeft = parseInt(this.map.layerContainerDiv.style.left); 345 var layerContainerDivTop = parseInt(this.map.layerContainerDiv.style.top); 346 343 347 344 348 do { … … 361 365 362 366 var x = tileoffsetx; 363 x -= parseInt(this.map.layerContainerDiv.style.left);367 x -= layerContainerDivLeft; 364 368 365 369 var y = tileoffsety; 366 y -= parseInt(this.map.layerContainerDiv.style.top);370 y -= layerContainerDivTop; 367 371 368 372 var px = new OpenLayers.Pixel(x, y); … … 561 565 shiftRow:function(prepend) { 562 566 var modelRowIndex = (prepend) ? 0 : (this.grid.length - 1); 563 var modelRow = this.grid[modelRowIndex]; 567 var grid = this.grid; 568 var modelRow = grid[modelRowIndex]; 564 569 565 570 var resolution = this.map.getResolution(); … … 567 572 var deltaLat = resolution * -deltaY; 568 573 569 var row = (prepend) ? this.grid.pop() : this.grid.shift();574 var row = (prepend) ? grid.pop() : grid.shift(); 570 575 571 576 for (var i=0; i < modelRow.length; i++) { … … 580 585 581 586 if (prepend) { 582 this.grid.unshift(row);587 grid.unshift(row); 583 588 } else { 584 this.grid.push(row);589 grid.push(row); 585 590 } 586 591 }, … … 613 618 tile.moveTo(bounds, position); 614 619 if (prepend) { 615 this.grid[i].unshift(tile);620 row.unshift(tile); 616 621 } else { 617 this.grid[i].push(tile);622 row.push(tile); 618 623 } 619 624 } sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/Vector.js
r4985 r5286 318 318 319 319 /** 320 * Method: drawFeature320 * APIMethod: drawFeature 321 321 * Draw (or redraw) a feature on the layer. If the optional style argument 322 322 * is included, this style will be used. If no style is included, the sandbox/elemoine/regular-polygon/lib/OpenLayers/Layer/VirtualEarth.js
r5002 r5286 104 104 if (this.mapObject != null) { 105 105 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 107 114 } catch (e) {
