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

http://gmaps-utility-library-flash.googlecode.com/ · ActionScript · 78 lines · 55 code · 7 blank · 16 comment · 1 complexity · 28ffd41c48d6c89091a50917164a15fd 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.Copyright;
  8. import com.google.maps.CopyrightCollection;
  9. import com.google.maps.LatLng;
  10. import com.google.maps.LatLngBounds;
  11. import com.google.maps.MapType;
  12. import com.google.maps.MapTypeOptions;
  13. import com.google.maps.TileLayerBase;
  14. /**
  15. * Contains all the static Mars map types. To use, import this class and then call on your Map object:
  16. * addMapType(Moon.ELEVATION_MAP_TYPE);
  17. * addMapType(Moon.VISIBLE_MAP_TYPE);
  18. */
  19. public class Moon {
  20. private static var PLANETARY_MAPS_SERVER:String = "http://mw1.google.com/mw-planetary/";
  21. private static var MOON_PARAMETERS:Object = {
  22. "visible" : {
  23. name: "visible",
  24. url: PLANETARY_MAPS_SERVER + "lunar/lunarmaps_v1/clem_bw/",
  25. zoom_levels: 9
  26. },
  27. "elevation": {
  28. name: "elevation",
  29. url: PLANETARY_MAPS_SERVER + "lunar/lunarmaps_v1/terrain/",
  30. zoom_levels: 7
  31. }
  32. };
  33. private static var MOON_MAP_TYPES:Object = {};
  34. /**
  35. * This map type displays a shaded terrain map of the surface of the Moon, color-coded by altitude.
  36. */
  37. public static function get ELEVATION_MAP_TYPE():MapType {
  38. return getMapType("elevation");
  39. }
  40. /**
  41. * This map type displays photographs taken from orbit around the moon.
  42. */
  43. public static function get VISIBLE_MAP_TYPE():MapType {
  44. return getMapType("visible");
  45. }
  46. private static function getMapType(name:String):MapType {
  47. if (!MOON_MAP_TYPES[name]) {
  48. var params:Object = MOON_PARAMETERS[name];
  49. var copyright:CopyrightCollection = new CopyrightCollection();
  50. copyright.addCopyright(
  51. new Copyright(
  52. "moon_" + name,
  53. new LatLngBounds(new LatLng(-180, -90), new LatLng(180,90)),
  54. 0,
  55. "NASA/USGS"));
  56. var layer:MoonTileLayer = new MoonTileLayer(params.url, copyright, params.zoom_levels);
  57. var maptype:MapType = new MapType(
  58. [layer],
  59. MapType.NORMAL_MAP_TYPE.getProjection(),
  60. name,
  61. new MapTypeOptions({
  62. radius: 1738000,
  63. shortName: name,
  64. alt: "Show " + name + " map"
  65. }));
  66. MOON_MAP_TYPES[name] = maptype;
  67. }
  68. return MOON_MAP_TYPES[name];
  69. }
  70. }
  71. }