PageRenderTime 29ms CodeModel.GetById 19ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/HelloRubberBandCtrl/src/HelloRubberBandCtrl.as

http://gmaps-utility-library-flash.googlecode.com/
ActionScript | 94 lines | 44 code | 13 blank | 37 comment | 0 complexity | 773e259d39ce4f6d252717434feb7c24 MD5 | raw file
 1package {
 2
 3import flash.display.Sprite;
 4import flash.display.StageAlign;
 5import flash.display.StageScaleMode;
 6import flash.geom.Point;
 7
 8import com.google.maps.LatLng;
 9import com.google.maps.Map;
10import com.google.maps.MapEvent;
11import com.google.maps.MapOptions;
12import com.google.maps.controls.ZoomControl;
13import com.google.maps.extras.rubberbandctrl.RubberBandCtrl;
14
15/**
16 * The HelloRubberBandCtrl class is a simple but complete Google Map
17 * application that demonstrates how to integrate <code>RubberBandCtrl</code>
18 * functionality into the map. To understand how to use this control, please
19 * consult the documentation for <code>RubberBandCtrl</code>.
20 *
21 * <p>
22 * <strong>Contacts:</strong>
23 * <ul>
24 * <li>To contact the author of RubberBandCtrl, email kevin.macdonald AT thinkwrap DOT com</li>
25 * <li>Visit <code>http://www.spatialdatabox.com</code> for other Google Flash Map demos and related information.</li>
26 * </ul>
27 * </p>
28 * 
29 * <p>
30 * <strong>Copyright Notice:</strong><br>
31 * <br>
32 * Copyright 2009 Kevin Macdonald<br>
33 * <br>
34 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at<br>
35 * <br>
36 *     http://www.apache.org/licenses/LICENSE-2.0<br>
37 * <br>
38 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.<br>
39 * </p>
40 */
41public class HelloRubberBandCtrl extends Sprite
42{
43
44public function HelloRubberBandCtrl ()
45{
46	stage.align = StageAlign.TOP_LEFT;
47	stage.scaleMode = StageScaleMode.NO_SCALE;
48	
49	map.key = " .. your API key goes here .. ";
50	map.setSize (MAP_SIZE);
51	map.addControl (new ZoomControl ());
52	map.addEventListener (MapEvent.MAP_PREINITIALIZE, onMapPreinitialize);
53	map.addEventListener (MapEvent.MAP_READY, onMapReady);
54	
55	addChild (map);
56}
57
58private function onMapPreinitialize (event:MapEvent):void
59{
60	map.setInitOptions (
61		new MapOptions ( {
62			center: MAP_CENTER,
63			zoom: MAP_ZOOM
64		}
65		));
66}
67
68/**
69 * This function contains the one integration point between this application and
70 * RubberBandCtrl.
71 * 
72 * <p>
73 * RubberBandCtrl provides other functions that allow you to customize its look
74 * and behavior. Consult its documentation for more details.
75 * </p>
76*/
77private function onMapReady (event:MapEvent):void
78{
79	//	Attach the control to the map.
80	rbCtrl.enable (map);
81}
82
83private static const MAP_SIZE:Point = new Point (1024, 600);
84private static const MAP_CENTER:LatLng = new LatLng (30, 0);
85private static const MAP_ZOOM:int = 2;
86
87private const map:Map = new Map ();
88
89//	Create one RubberBandCtrl object.
90private const rbCtrl:RubberBandCtrl = new RubberBandCtrl ();
91
92}
93
94}