Ticket #1620: ticket1620.2.patch
| File ticket1620.2.patch, 3.5 kB (added by bartvde, 4 months ago) |
|---|
-
OverviewMap.js
old new 402 402 Math.max(mapExtent.bottom, maxExtent.bottom), 403 403 Math.min(mapExtent.right, maxExtent.right), 404 404 Math.min(mapExtent.top, maxExtent.top)); 405 406 if (this.ovmap.getProjection() != this.map.getProjection()) { 407 testExtent = testExtent.transform( 408 this.map.getProjectionObject(), 409 this.ovmap.getProjectionObject() ); 410 } 411 405 412 var resRatio = this.ovmap.getResolution() / this.map.getResolution(); 406 413 return ((resRatio > this.minRatio) && 407 414 (resRatio <= this.maxRatio) && … … 423 430 // zoom out overview map 424 431 targetRes = this.maxRatio * mapRes; 425 432 } 426 this.ovmap.setCenter(this.map.center, 427 this.ovmap.getZoomForResolution(targetRes)); 433 var center; 434 var factor = 1; 435 if (this.ovmap.getProjection() != this.map.getProjection()) { 436 var sourceUnits = this.map.getProjectionObject().getUnits(); 437 if (sourceUnits == null) { 438 sourceUnits = 'degrees'; 439 } 440 var targetUnits = this.ovmap.getProjectionObject().getUnits(); 441 if (targetUnits == null) { 442 targetUnits = 'degrees'; 443 } 444 factor = OpenLayers.INCHES_PER_UNIT[targetUnits] / 445 OpenLayers.INCHES_PER_UNIT[sourceUnits]; 446 center = this.map.center.clone(); 447 center.transform(this.map.getProjectionObject(), 448 this.ovmap.getProjectionObject() ); 449 } else { 450 center = this.map.center; 451 } 452 this.ovmap.setCenter(center, 453 this.ovmap.getZoomForResolution(targetRes/factor)); 428 454 this.updateRectToMap(); 429 455 }, 430 456 … … 493 524 * Updates the extent rectangle position and size to match the map extent 494 525 */ 495 526 updateRectToMap: function() { 496 // The base layer for overview map needs to be in the same projection 497 // as the base layer for the main map. This should be made more robust. 498 if(this.map.units != 'degrees') { 499 if(this.ovmap.getProjection() && (this.map.getProjection() != this.ovmap.getProjection())) { 500 alert(OpenLayers.i18n("sameProjection")); 501 } 527 // If the projections differ we need to reproject 528 var bounds; 529 if (this.ovmap.getProjection() != this.map.getProjection()) { 530 bounds = this.map.getExtent().transform( 531 this.map.getProjectionObject(), 532 this.ovmap.getProjectionObject() ); 533 } else { 534 bounds = this.map.getExtent(); 502 535 } 503 var pxBounds = this.getRectBoundsFromMapBounds( this.map.getExtent());536 var pxBounds = this.getRectBoundsFromMapBounds(bounds); 504 537 if (pxBounds) { 505 538 this.setRectPxBounds(pxBounds); 506 539 } … … 512 545 */ 513 546 updateMapToRect: function() { 514 547 var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds); 548 if (this.ovmap.getProjection() != this.map.getProjection()) { 549 lonLatBounds = lonLatBounds.transform( 550 this.ovmap.getProjectionObject(), 551 this.map.getProjectionObject() ); 552 } 515 553 this.map.panTo(lonLatBounds.getCenterLonLat()); 516 554 }, 517 555
