PageRenderTime 168ms CodeModel.GetById 160ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://gmaps-utility-library-flash.googlecode.com/
ActionScript | 92 lines | 64 code | 8 blank | 20 comment | 1 complexity | 5e1c61bab4c01f11705ef587d2d90dbf 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(Mars.ELEVATION_MAP_TYPE);
18	 * addMapType(Mars.VISIBLE_MAP_TYPE);
19	 * addMapType(Mars.INFRARED_MAP_TYPE);
20	 */
21	public class Mars {
22		
23        private static var PLANETARY_MAPS_SERVER:String =  "http://mw1.google.com/mw-planetary/";
24        
25        private static var MARS_PARAMETERS:Object = {
26        "elevation": {
27            name: "elevation",
28            url: PLANETARY_MAPS_SERVER + "mars/elevation/",
29            zoom_levels: 8,
30            credits: "NASA/JPL/GSFC"
31            },
32        "visible": {
33            url: PLANETARY_MAPS_SERVER + "mars/visible/",
34            zoom_levels: 9,
35            credits: "NASA/JPL/ASU/MSSS"
36            },
37        "infrared": {
38            url: PLANETARY_MAPS_SERVER + "mars/infrared/",
39            zoom_levels: 12,
40            credits: "NASA/JPL/ASU"
41            }
42        };  
43        
44        private static var MARS_MAP_TYPES:Object = {};
45        
46        /**
47        * This map type displays a shaded relief map of the surface of Mars, color-coded by altitude. 
48        */
49        public static function get ELEVATION_MAP_TYPE():MapType {
50        	return getMapType("elevation");
51        }
52        
53        /**
54        * This map type displays photographs taken from orbit around Mars. 
55        */
56        public static function get VISIBLE_MAP_TYPE():MapType {
57            return getMapType("visible");
58        }
59        
60        /**
61        * This map type displays a shaded infrared map of the surface of Mars, where warmer areas appear brighter and colder areas appear darker.
62        */
63        public static function get INFRARED_MAP_TYPE():MapType {
64            return getMapType("infrared");
65        }      
66        
67        private static function getMapType(name:String):MapType {
68        	if (!MARS_MAP_TYPES[name]) {
69	            var params:Object = MARS_PARAMETERS[name];
70	            var copyright:CopyrightCollection = new CopyrightCollection();
71	            copyright.addCopyright(
72	                new Copyright(
73	                  "mars_" + name,
74	                   new LatLngBounds(new LatLng(-180, -90), new LatLng(180,90)), 
75	                   0, 
76	                   params.credits));
77	            var layer:MarsTileLayer = new MarsTileLayer(params.url, copyright, params.zoom_levels);
78	            var maptype:MapType = new MapType(
79	                [layer],  
80	                MapType.NORMAL_MAP_TYPE.getProjection(), 
81	                name, 
82	                new MapTypeOptions({
83	                                  radius: 3396200,
84	                                  shortName: name,
85	                                  alt: "Show " + name + " map"
86	                }));
87	            MARS_MAP_TYPES[name] = maptype;
88	        }
89            return MARS_MAP_TYPES[name];
90        }
91    } 
92}