/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

  1. package {
  2. import flash.display.Sprite;
  3. import flash.display.StageAlign;
  4. import flash.display.StageScaleMode;
  5. import flash.geom.Point;
  6. import com.google.maps.LatLng;
  7. import com.google.maps.Map;
  8. import com.google.maps.MapEvent;
  9. import com.google.maps.MapOptions;
  10. import com.google.maps.controls.ZoomControl;
  11. import com.google.maps.extras.rubberbandctrl.RubberBandCtrl;
  12. /**
  13. * The HelloRubberBandCtrl class is a simple but complete Google Map
  14. * application that demonstrates how to integrate <code>RubberBandCtrl</code>
  15. * functionality into the map. To understand how to use this control, please
  16. * consult the documentation for <code>RubberBandCtrl</code>.
  17. *
  18. * <p>
  19. * <strong>Contacts:</strong>
  20. * <ul>
  21. * <li>To contact the author of RubberBandCtrl, email kevin.macdonald AT thinkwrap DOT com</li>
  22. * <li>Visit <code>http://www.spatialdatabox.com</code> for other Google Flash Map demos and related information.</li>
  23. * </ul>
  24. * </p>
  25. *
  26. * <p>
  27. * <strong>Copyright Notice:</strong><br>
  28. * <br>
  29. * Copyright 2009 Kevin Macdonald<br>
  30. * <br>
  31. * 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>
  32. * <br>
  33. * http://www.apache.org/licenses/LICENSE-2.0<br>
  34. * <br>
  35. * 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>
  36. * </p>
  37. */
  38. public class HelloRubberBandCtrl extends Sprite
  39. {
  40. public function HelloRubberBandCtrl ()
  41. {
  42. stage.align = StageAlign.TOP_LEFT;
  43. stage.scaleMode = StageScaleMode.NO_SCALE;
  44. map.key = " .. your API key goes here .. ";
  45. map.setSize (MAP_SIZE);
  46. map.addControl (new ZoomControl ());
  47. map.addEventListener (MapEvent.MAP_PREINITIALIZE, onMapPreinitialize);
  48. map.addEventListener (MapEvent.MAP_READY, onMapReady);
  49. addChild (map);
  50. }
  51. private function onMapPreinitialize (event:MapEvent):void
  52. {
  53. map.setInitOptions (
  54. new MapOptions ( {
  55. center: MAP_CENTER,
  56. zoom: MAP_ZOOM
  57. }
  58. ));
  59. }
  60. /**
  61. * This function contains the one integration point between this application and
  62. * RubberBandCtrl.
  63. *
  64. * <p>
  65. * RubberBandCtrl provides other functions that allow you to customize its look
  66. * and behavior. Consult its documentation for more details.
  67. * </p>
  68. */
  69. private function onMapReady (event:MapEvent):void
  70. {
  71. // Attach the control to the map.
  72. rbCtrl.enable (map);
  73. }
  74. private static const MAP_SIZE:Point = new Point (1024, 600);
  75. private static const MAP_CENTER:LatLng = new LatLng (30, 0);
  76. private static const MAP_ZOOM:int = 2;
  77. private const map:Map = new Map ();
  78. // Create one RubberBandCtrl object.
  79. private const rbCtrl:RubberBandCtrl = new RubberBandCtrl ();
  80. }
  81. }