Flex:Google飞过去
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flex:Google飞过去相关的知识,希望对你有一定的参考价值。
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:maps="com.google.maps.*" layout="absolute"> <mx:Script> <![CDATA[ import com.google.maps.MapMouseEvent; import com.google.maps.InfoWindowOptions; import com.google.maps.overlays.Marker; import mx.messaging.messages.IMessage; import com.google.maps.controls.NavigationControl; import com.google.maps.controls.MapTypeControl; import com.google.maps.geom.Attitude; import com.google.maps.View; import com.google.maps.MapType; import com.google.maps.LatLng; import com.google.maps.MapOptions; import com.google.maps.MapEvent; import mx.controls.Alert; import mx.messaging.events.MessageEvent; private static const GOOGLE_MAP_API:String = "GOOGLE_MAPS_KEY"; private var infoWindowFlag:Boolean; private var initZoom:Number = 3.5; private var initLat:Number = 25; private var initLng:Number = 10; private var initAttitude:Attitude = new Attitude( 0, 0, 0 ); private var flyToFlag:Boolean = false;; private var flyToZoom:Number = 3.5; private var flightSpeed:Number = 3; private var flyToAttitude:Attitude = new Attitude( 20, 30, 0 ); private function messageHandler( message:IMessage ):void { //trace( "messageHandler: " + message ); var latlng:LatLng = new LatLng( message.body.latitude, message.body.longitude ); if( latlng != null ){ var marker:Marker = new Marker( latlng ); marker.addEventListener( MapMouseEvent.CLICK, function(e:MapMouseEvent) { openTheInfoWindow( message, latlng ) }, false, 0, true ); if( flyToFlag ) map.flyTo( latlng, flyToZoom, flyToAttitude, flightSpeed ); openTheInfoWindow( message, latlng ); map.addOverlay( marker ); } } private function openTheInfoWindow( message:IMessage, latlng:LatLng ):void { if( infoWindowCheckBox.selected ){ var infoWindowOptions:InfoWindowOptions = new InfoWindowOptions( ); infoWindowOptions.title = message.body.city; infoWindowOptions.content = "Sample ID: " + message.body.sampleId + " viewed"; infoWindowOptions.pointOffset = new Point(0, -20); map.openInfoWindow( latlng, infoWindowOptions ); } } private function onMapPreInit( e:MapEvent ):void { var mapOptions:MapOptions = new MapOptions(); mapOptions.zoom = initZoom; mapOptions.center = new LatLng( initLat, initLng ); mapOptions.mapType = MapType.PHYSICAL_MAP_TYPE; mapOptions.viewMode = View.VIEWMODE_PERSPECTIVE; mapOptions.attitude = initAttitude; map.setInitOptions( mapOptions ); } private function onMapReady( e:MapEvent ):void { map.addControl( new MapTypeControl() ); map.addControl( new NavigationControl() ); //The Map is constructed, let's subscribe to the message consumer.subscribe(); } private function toggleFlyTo():void { if( flyToFlag ){ map.cancelFlyTo(); map.flyTo( new LatLng( initLat, initLng ), initZoom, initAttitude, 5 ); } flyToFlag = flyToCheckBox.selected; } private function toggleInfoWindow():void { infoWindowFlag = infoWindowCheckBox.selected; } ]]> </mx:Script> <mx:ChannelSet id="channelSet"> <!-- Long Polling Channel --> <mx:AMFChannel url="http://tourdeflex.adobe.com:8080/lcds-samples/messagebroker/amflongpolling" /> <mx:AMFChannel url="http://tourdeflex.adobe.com:8080/lcds-samples/messagebroker/amfpolling" /> </mx:ChannelSet> <mx:Consumer id="consumer" channelSet="{channelSet}" destination="tdf.sampleviewingfeed" subtopic="flex" message="messageHandler(event.message)" fault="Alert.show(event.faultString)" /> <maps:Map3D id="map" mapevent_mappreinitialize="onMapPreInit(event)" mapevent_mapready="onMapReady(event)" width="100%" height="100%" key="{GOOGLE_MAP_API}" /> <mx:VBox x="100" y="5"> <mx:Label fontSize="18" fontWeight="bold" text="Tour De Flex Live Traffic" right="60" /> <mx:CheckBox id="flyToCheckBox" fontWeight="bold" label="FlyTo (animated 3D flight)" click="toggleFlyTo()" /> <mx:CheckBox id="infoWindowCheckBox" fontWeight="bold" selected="true" label="Info Window" click="toggleInfoWindow()" /> </mx:VBox> </mx:Application>
以上是关于Flex:Google飞过去的主要内容,如果未能解决你的问题,请参考以下文章
AI大事件 | 李飞飞接受访谈, TensorFlow: 发布 1.4.0,深度强化学习Bootcamp-视频讲座&实验
Demo家预告| SteamOne手持挂烫机 摩飞厨房相关用具