2010-10-31 93 views
1

我正在创建一个小地图应用程序,为您提供有关大学不同校区的信息,视频和图像。谷歌地图Flash API自定义内容问题

我使用customContent方法将视频播放器对象插入到infoWindow中,但是当我这样做时,它将摆脱我的文本内容并成为用户唯一可见的东西。

如何解决此问题,并在infoWindow中同时显示文本和视频?

Demo link

public function createMarker(latlng:LatLng, name:String, address:String, video:String):Marker 
     { 
      var marker:Marker=new Marker(latlng); 

      marker.addEventListener(MapMouseEvent.CLICK, function(e:MapMouseEvent):void 
      { 
       //marker.openInfoWindow(new InfoWindowOptions({contentHTML:html + moulVid})); 
       var infoWindow:InfoWindowOptions = new InfoWindowOptions(); 

       infoWindow.title = name; 
       var videoPlayer:VideoPlayer = new VideoPlayer(); 
       videoPlayer.source = '../assets/video/' + video.toLocaleLowerCase(); 
       videoPlayer.autoPlay = false; 
       videoPlayer.alpha = 0.8; 

       titleFormat = new TextFormat(); 
       titleFormat.font = "Arial"; 
       titleFormat.size = 14; 
       titleFormat.bold = true; 

       contentFormat = new TextFormat(); 
       contentFormat.font = "Arial"; 
       contentFormat.size = 12; 

       infoWindow.drawDefaultFrame = true; 
       infoWindow.titleFormat = titleFormat; 

       if (video != "") { 
        infoWindow.customContent = videoPlayer; 
        infoWindow.height = 300; 
       } 

       infoWindow.width = 380; 

       infoWindow.content = address; 
       infoWindow.contentFormat = contentFormat; 

       infoWindow.padding = 10; 

       marker.openInfoWindow(infoWindow); 
      }); 

回答

2

您需要创建一个新的对象,称它像是VideoAndTextInfoWindow,使其扩展的DisplayObject。现在在该组件的构造函数中创建并添加一个VideoPlayer和一个TextField。这个组件可能只公开暴露一个videoSource和一个文本属性。为这些属性创建setter,以便在VideoPlayer和TextField实例上设置正确的属性。现在将infoWindow.customContent设置为VideoAndTextInfoWindow组件的新实例。

+0

非常感谢。这解决了我的问题 – XGreen 2010-11-05 13:58:17