Changeset 6961
- Timestamp:
- 04/17/08 19:41:40 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/edgemaster/openlayers/lib/OpenLayers/Layer/Vector.js
r6888 r6961 494 494 }, 495 495 496 /* APIMethod: transform 497 * Transform the Vector layer from source to dest projection. 496 /** 497 * APIMethod: transform 498 * Transform the Vector layer from source to dest projection. 499 * * Please note that you may have to manually change other 500 * options such as resolutions to get the layer to display as 501 * you intend on a base layer (see adjustResolutions()) 498 502 * 499 503 * Parameters: … … 502 506 * 503 507 * Returns: 504 * {<OpenLayers.Layer. Markers>} Itself, for use in chaining operations.508 * {<OpenLayers.Layer.Vector>} Itself, for use in chaining operations. 505 509 */ 506 510 transform: function(source, dest) { … … 509 513 feature.geometry.transform(source, dest); 510 514 } 515 if(this.maxExtent != null) { 516 this.maxExtent.transform(source, dest); 517 } 518 this.projection = dest; 511 519 this.redraw(); 512 520 return this; 521 }, 522 523 /** 524 * Method: adjustResolutions 525 * Attempts to adjust resolution options to that of a new base layer if 526 * originally copied from a base layer or the map object. 527 * 528 * Parameters: 529 * layer - {<OpenLayers.Layer>} Layer to copy new resolution options from 530 */ 531 adjustResolutions: function(layer) { 532 // These are the relevant options which are used for comparing 533 // resolutions information. 534 // (copied from OpenLayers.Layer.initResolutions()) 535 var props = new Array( 536 'projection', 'units', 537 'scales', 'resolutions', 538 'maxScale', 'minScale', 539 'maxResolution', 'minResolution', 540 'minExtent', 'maxExtent', 541 'numZoomLevels', 'maxZoomLevel' 542 ); 543 544 // This is probably ugly - we clobber derived properties 545 for(var i=0; i < props.length; i++) { 546 if((this.options[props[i]] === undefined) && (this[props[i]])) { 547 this[props[i]] = layer[props[i]]; 548 } 549 } 513 550 }, 514 551 sandbox/edgemaster/openlayers/lib/OpenLayers/Map.js
r6888 r6961 971 971 setBaseLayer: function(newBaseLayer) { 972 972 var oldExtent = null; 973 var oldProjection = null; 973 974 if (this.baseLayer) { 974 975 oldExtent = this.baseLayer.getExtent(); … … 1007 1008 // Convert centre point to new layer projection - so we can 1008 1009 // maintain roughly the same view 1009 if(!oldProjection.equals(this.getProjectionObject())) { 1010 newCenter.transform(oldProjection, this.getProjectionObject()); 1011 oldExtent.transform(oldProjection, this.getProjectionObject()); 1010 var newProjection = this.getProjectionObject(); 1011 if(!oldProjection.equals(newProjection)) { 1012 newCenter.transform(oldProjection, newProjection); 1013 oldExtent.transform(oldProjection, newProjection); 1014 1015 // Also convert vector layers - assuming they are in the 1016 // same projection as the original baseLayer - we cannot 1017 // trust the projection property all the time as it is 1018 // used as a shortcut for externalProjection 1012 1019 vectorLayers = this.getLayersBy("isVector", true); 1013 1020 for (l = 0; l < vectorLayers.length; l++) { 1014 vectorLayers[l].transform(oldProjection, this.getProjectionObject()); 1021 vectorLayers[l].transform(oldProjection, newProjection); 1022 vectorLayers[l].adjustResolutions(this.baseLayer); 1015 1023 } 1016 1024 } 1017 1025 1018 1026 //the new zoom will either come from the old Extent or 1019 // from the current resolution of the map 1027 // from the current resolution of the map 1020 1028 var newZoom = (oldExtent) 1021 1029 ? this.getZoomForExtent(oldExtent, true)
