/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. */
  6. package com.google.maps.extras.planetary {
  7. import com.google.maps.CopyrightCollection;
  8. import com.google.maps.TileLayerBase;
  9. import flash.display.DisplayObject;
  10. import flash.display.Loader;
  11. import flash.events.*;
  12. import flash.geom.Point;
  13. import flash.net.URLRequest;
  14. /**
  15. * @private
  16. */
  17. public class MoonTileLayer extends TileLayerBase {
  18. private var _baseUrl:String;
  19. /**
  20. * Constructor for the class.
  21. */
  22. public function MoonTileLayer(baseUrl:String, copyrightCollection:CopyrightCollection, zoomLevels:Number) {
  23. super(copyrightCollection, 0, zoomLevels);
  24. this._baseUrl = baseUrl;
  25. }
  26. /**
  27. * Creates and loads a tile (x, y) at the given zoom level.
  28. * @param tilePos Tile coordinates.
  29. * @param zoom Tile zoom.
  30. * @return Display object representing the tile.
  31. */
  32. public override function loadTile(tilePos:Point, zoom:Number):DisplayObject {
  33. var bound:Number = Math.pow(2, zoom);
  34. var url:String = this._baseUrl + zoom + "/" + tilePos.x + "/" +
  35. (bound - tilePos.y - 1) + ".jpg";
  36. var testLoader:Loader = new Loader();
  37. var urlRequest:URLRequest = new URLRequest(url);
  38. testLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  39. testLoader.load(urlRequest);
  40. return testLoader;
  41. }
  42. private function ioErrorHandler(event:IOErrorEvent):void {
  43. trace("ioErrorHandler: " + event);
  44. }
  45. }
  46. }