| 187 | | /* |
|---|
| 188 | | * Based on a zoom level, determine appropriate initial |
|---|
| 189 | | * tile coordinate and point using calculateMapCenter(), and inform |
|---|
| 190 | | * the grid of tile coordinate and point by calling grid.resetTiles(). |
|---|
| 191 | | * |
|---|
| 192 | | * @param Desired zoom level. |
|---|
| 193 | | * |
|---|
| 194 | | * @see com.modestmaps.Map#calculateMapExtent |
|---|
| 195 | | * @see com.modestmaps.core.TileGrid#resetTiles |
|---|
| 196 | | */ |
|---|
| 197 | | public function setZoom(zoom:Number):void |
|---|
| 198 | | { |
|---|
| 199 | | if (zoom == grid.zoomLevel) { // do nothing! |
|---|
| 200 | | return; |
|---|
| 201 | | } |
|---|
| 202 | | else if (zoom - grid.zoomLevel == 1) { // if 1 step in, delegate to zoomIn animation |
|---|
| 203 | | zoomIn(); |
|---|
| 204 | | } |
|---|
| 205 | | else if (zoom - grid.zoomLevel == -1) { // if 1 step out, delegate to zoomOut animation |
|---|
| 206 | | zoomOut(); |
|---|
| 207 | | } |
|---|
| 208 | | else { // else hard reset |
|---|
| 209 | | var center:MapPosition = coordinatePosition(grid.centerCoordinate().zoomTo(zoom)); |
|---|
| 210 | | // tell grid what the rock is cooking |
|---|
| 211 | | grid.resetTiles(center.coord, center.point); |
|---|
| 212 | | onExtentChanged(this.getExtent()); |
|---|
| 213 | | Reactor.callNextFrame(callCopyright); |
|---|
| 214 | | } |
|---|
| 215 | | } |
|---|
| | 187 | /* |
|---|
| | 188 | * Based on a zoom level, determine appropriate initial |
|---|
| | 189 | * tile coordinate and point using calculateMapCenter(), and inform |
|---|
| | 190 | * the grid of tile coordinate and point by calling grid.resetTiles(). |
|---|
| | 191 | * |
|---|
| | 192 | * @param Desired zoom level. |
|---|
| | 193 | * |
|---|
| | 194 | * @see com.modestmaps.Map#calculateMapExtent |
|---|
| | 195 | * @see com.modestmaps.core.TileGrid#resetTiles |
|---|
| | 196 | */ |
|---|
| | 197 | public function setZoom(zoom:Number):void |
|---|
| | 198 | { |
|---|
| | 199 | if (zoom == grid.zoomLevel) return; |
|---|
| | 200 | // else hard reset |
|---|
| | 201 | var center:MapPosition = coordinatePosition(grid.centerCoordinate().zoomTo(zoom)); |
|---|
| | 202 | // tell grid what the rock is cooking |
|---|
| | 203 | grid.resetTiles(center.coord, center.point); |
|---|
| | 204 | onExtentChanged(this.getExtent()); |
|---|
| | 205 | Reactor.callNextFrame(callCopyright); |
|---|
| | 206 | } |
|---|
| | 532 | var center:MapPosition = coordinatePosition(__mapProvider.locationCoordinate(location).zoomTo(grid.zoomLevel)); |
|---|
| | 533 | // tell grid what the rock is cooking |
|---|
| | 534 | grid.resetTiles(center.coord, center.point); |
|---|
| | 535 | onExtentChanged(this.getExtent()); |
|---|
| | 536 | Reactor.callNextFrame(callCopyright); |
|---|
| | 537 | } |
|---|
| | 538 | |
|---|
| | 539 | /** |
|---|
| | 540 | * Put the given location in the middle of the map, animated in panFrames. |
|---|
| | 541 | * Use setCenter or setCenterZoom for big jumps, set forceAnimate to true |
|---|
| | 542 | * if you really want to animate to a location that's currently off screen. |
|---|
| | 543 | * But no promises! |
|---|
| | 544 | * |
|---|
| | 545 | * @see com.modestmaps.Map#panFrames |
|---|
| | 546 | */ |
|---|
| | 547 | public function panTo(location:Location, forceAnimate:Boolean=false):void |
|---|
| | 548 | { |
|---|
| 574 | | zoom(-1); |
|---|
| 575 | | } |
|---|
| 576 | | |
|---|
| 577 | | // keeping it DRY, as they say |
|---|
| 578 | | // dir should be 1, for in, or -1, for out |
|---|
| 579 | | private function zoom(dir:int):void |
|---|
| 580 | | { |
|---|
| | 577 | zoomBy(-1); |
|---|
| | 578 | } |
|---|
| | 579 | |
|---|
| | 580 | /** |
|---|
| | 581 | * Zoom to the given level over the course of several frames. |
|---|
| | 582 | * @see com.modestmaps.Map#zoomFrames |
|---|
| | 583 | */ |
|---|
| | 584 | public function zoomTo(level:Number):void |
|---|
| | 585 | { |
|---|
| | 586 | zoomBy(level-grid.zoomLevel); |
|---|
| | 587 | } |
|---|
| | 588 | |
|---|
| | 589 | /** |
|---|
| | 590 | * Zoom in or out over the course of several frames. |
|---|
| | 591 | * @see com.modestmaps.Map#zoomFrames |
|---|
| | 592 | */ |
|---|
| | 593 | private function zoomBy(amount:int):void |
|---|
| | 594 | { |
|---|
| | 595 | if (amount == 0) return; |
|---|
| | 596 | |
|---|