PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/com/google/maps/extras/planetary/MoonTileLayer.as

http://gmaps-utility-library-flash.googlecode.com/
ActionScript | 54 lines | 29 code | 8 blank | 17 comment | 0 complexity | 1925eee97600ac07d24995373632222a MD5 | raw file
 1/*
 2* Copyright 2008 Google Inc. 
 3* Licensed under the Apache License, Version 2.0:
 4*  http://www.apache.org/licenses/LICENSE-2.0
 5*/
 6package com.google.maps.extras.planetary {
 7
 8import com.google.maps.CopyrightCollection;
 9import com.google.maps.TileLayerBase;
10
11import flash.display.DisplayObject;
12import flash.display.Loader;
13import flash.events.*;
14import flash.geom.Point;
15import flash.net.URLRequest;
16
17/**
18 * @private
19 */
20public class MoonTileLayer extends TileLayerBase {
21
22  private var _baseUrl:String;
23  
24  /**
25   * Constructor for the class.
26   */
27  public function MoonTileLayer(baseUrl:String, copyrightCollection:CopyrightCollection, zoomLevels:Number) {
28    super(copyrightCollection, 0, zoomLevels);
29    this._baseUrl = baseUrl; 
30  }
31
32  /**
33   * Creates and loads a tile (x, y) at the given zoom level.
34   * @param tilePos  Tile coordinates.
35   * @param zoom  Tile zoom.
36   * @return  Display object representing the tile.
37   */
38  public override function loadTile(tilePos:Point, zoom:Number):DisplayObject {
39    var bound:Number = Math.pow(2, zoom);
40    var url:String = this._baseUrl + zoom + "/" + tilePos.x + "/" +
41      (bound - tilePos.y - 1) + ".jpg";
42      
43    var testLoader:Loader = new Loader();
44    var urlRequest:URLRequest = new URLRequest(url); 
45    testLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
46    testLoader.load(urlRequest);	
47    return testLoader;
48  }
49
50  private function ioErrorHandler(event:IOErrorEvent):void {
51    trace("ioErrorHandler: " + event);
52  }
53}
54}