Module: nagvis Branch: master Commit: 61543e934bf5e0e85ab250fcbe4d21a6e0cd75c1 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=61543e934bf5e0e85ab250fcbe4d21a6e0cd75c1
Author: Roman Kyrylych <[email protected]> Date: Mon Aug 3 14:32:38 2009 +0300 gmap: Make Google Maps key configurable Signed-off-by: Roman Kyrylych <[email protected]> --- uifx/src/modules/gmap/GMapModule.as | 31 +++++++++++++++++++++++++++++++ uifx/src/modules/gmap/GMapModule.mxml | 6 +----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/uifx/src/modules/gmap/GMapModule.as b/uifx/src/modules/gmap/GMapModule.as index 33a66f5..d611acf 100644 --- a/uifx/src/modules/gmap/GMapModule.as +++ b/uifx/src/modules/gmap/GMapModule.as @@ -20,10 +20,14 @@ *****************************************************************************/ import com.google.maps.LatLng; +import com.google.maps.Map; +import com.google.maps.MapEvent; import com.google.maps.controls.ZoomControl; import com.google.maps.overlays.Polyline; import flash.events.Event; +import flash.events.IOErrorEvent; +import flash.net.URLLoader; import flash.system.Security; import modules.gmap.Link; @@ -38,11 +42,15 @@ import mx.controls.Alert; import mx.events.ListEvent; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; +import mx.utils.StringUtil; /*********************************************/ /* Global objects /*********************************************/ +private var map : Map; +private var key : String; + private var viewpoints : ArrayCollection; private var locations : LocationsCollection = new LocationsCollection; private var foundLocations : LocationsCollection = new LocationsCollection; @@ -62,6 +70,29 @@ private var foundLocationsView : FoundLocationsView; private function init() : void { Security.allowInsecureDomain("*"); + + var keyLoader : URLLoader = new URLLoader(); + var keyURL : URLRequest = new URLRequest("GoogleMaps.key"); + + keyLoader.addEventListener(Event.COMPLETE, function() : void { + key = StringUtil.trim(keyLoader.data); + initMap(); + }); + keyLoader.addEventListener(IOErrorEvent.IO_ERROR, function() : void { + Alert.show("Error loading GoogleMaps.key"); + }); + + keyLoader.load(keyURL); +} + +private function initMap() : void +{ + map = new Map(); + map.key = key; + map.width = mapContainer.width; + map.height = mapContainer.height; + map.addEventListener(MapEvent.MAP_READY, onMapReady); + mapContainer.addChild(map); } private function onLocationsChange(event : LocationEvent) : void diff --git a/uifx/src/modules/gmap/GMapModule.mxml b/uifx/src/modules/gmap/GMapModule.mxml index 60290d6..66e46c9 100644 --- a/uifx/src/modules/gmap/GMapModule.mxml +++ b/uifx/src/modules/gmap/GMapModule.mxml @@ -50,11 +50,7 @@ ]]> </mx:Script> <mx:Script source="GMapModule.as"/> - <maps:Map xmlns:maps="com.google.maps.*" id="map" - key="ABQIAAAAbL-l0p12tju9OYnJPNXPYBT3DJAw-5FLyP9xbJAH2x0dPCeSTRSPyzBWS-uRnuZRdDF49cYyKSpsdQ" - x="0" y="0" width="100%" height="100%" - mapevent_mapready="onMapReady(event)" - /> + <mx:UIComponent id="mapContainer" width="100%" height="100%"/> <gmap:DialogSettings id="settingsBox" logo="{settingsImage}" bottom="50" right="-10" width="310" ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
