Module: nagvis Branch: master Commit: 2de0245e34b1fce4fe9c0851fba5fcab64d61f4e URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/commit/?id=2de0245e34b1fce4fe9c0851fba5fcab64d61f4e
Author: Andriy Skuratov <[email protected]> Date: Fri Aug 14 18:13:36 2009 +0300 gmap: Changed the way the current location is displayed. --- .../modules/gmap/view/controls/GMapControl.mxml | 10 ++++- .../gmap/view/controls/GMapLocationControl.as | 43 +++++++++++-------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/uifx/src/modules/gmap/view/controls/GMapControl.mxml b/uifx/src/modules/gmap/view/controls/GMapControl.mxml index 3e5a87b..0ae022d 100644 --- a/uifx/src/modules/gmap/view/controls/GMapControl.mxml +++ b/uifx/src/modules/gmap/view/controls/GMapControl.mxml @@ -8,6 +8,8 @@ > <mx:Script> <![CDATA[ + import modules.gmap.events.LocationEvent; + import com.google.maps.MapMouseEvent; import mx.utils.StringUtil; import com.google.maps.Map; import mx.controls.Alert; @@ -34,6 +36,7 @@ map.setStyle("right", 0); map.setStyle("bottom", 0); map.addEventListener(MapEvent.MAP_READY, onMapReady); + map.addEventListener(MapMouseEvent.CLICK, onClick); this.addChild(map); } @@ -46,7 +49,12 @@ locationControl.map = map; locationsControl.map = map; locationsExtControl.map = map; - } + } + + private function onClick(event:MapMouseEvent):void + { + dispatchEvent(new LocationEvent(LocationEvent.SELECTED)); + } ]]> </mx:Script> <controls:GMapLocationControl id="locationControl"/> diff --git a/uifx/src/modules/gmap/view/controls/GMapLocationControl.as b/uifx/src/modules/gmap/view/controls/GMapLocationControl.as index f274f83..54ce0ff 100644 --- a/uifx/src/modules/gmap/view/controls/GMapLocationControl.as +++ b/uifx/src/modules/gmap/view/controls/GMapLocationControl.as @@ -1,10 +1,15 @@ package modules.gmap.view.controls { + import com.google.maps.InfoWindowOptions; import com.google.maps.LatLng; import com.google.maps.Map; + import com.google.maps.interfaces.IInfoWindow; import com.google.maps.overlays.Marker; import com.google.maps.overlays.MarkerOptions; + import flash.geom.Point; + import flash.text.TextFormat; + import modules.gmap.domain.Location; import mx.core.UIComponent; @@ -16,7 +21,7 @@ package modules.gmap.view.controls private var _location : Location; private var _map : Map; - private var _marker : Marker; + private var _info : IInfoWindow; public function GMapLocationControl() { @@ -36,7 +41,7 @@ package modules.gmap.view.controls { _map = value; - reinitMarker(); + reinitInfo(); } } @@ -48,31 +53,33 @@ package modules.gmap.view.controls public function set location(value:Location):void { if(_location !== value) - { _location = value; - - reinitMarker(); - } + + reinitInfo(); } - protected function reinitMarker():void + protected function reinitInfo():void { if(_map) { - if(_marker) - _map.removeOverlay(_marker); - if(_location) - { - var mo:MarkerOptions = new MarkerOptions(); - mo.icon = new _icon(); - mo.iconAlignment = MarkerOptions.ALIGN_RIGHT | MarkerOptions.ALIGN_BOTTOM; + { + var title:TextFormat = new TextFormat; + title.bold = true; + title.underline = true - _marker = new Marker( - LatLng.fromUrlValue(_location.point), mo - ); + var io:InfoWindowOptions = new InfoWindowOptions; + io.title = _location.label; + io.titleFormat = title; + io.content = _location.description; + io.hasCloseButton = false; + io.pointOffset = new Point(-3, -5); - _map.addOverlay(_marker); + _map.openInfoWindow(LatLng.fromUrlValue(_location.point), io); + } + else + { + _map.closeInfoWindow(); } } } ------------------------------------------------------------------------------ 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
