PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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