Apache flex 如何用谷歌地图捕捉页面?
我在continer中有一个带有谷歌地图的UIComponent。 我需要捕获此容器以进行预览 我的集成如下所示:Apache flex 如何用谷歌地图捕捉页面?,apache-flex,google-maps,Apache Flex,Google Maps,我在continer中有一个带有谷歌地图的UIComponent。 我需要捕获此容器以进行预览 我的集成如下所示: <mx:UIComponent id="mapContainer" width="410" height="300" /> googleMap = new Map(); mapContainer.addChild(googleMap); An ActionScript error has occurred: Secur
<mx:UIComponent id="mapContainer"
width="410"
height="300"
/>
googleMap = new Map();
mapContainer.addChild(googleMap);
An ActionScript error has occurred:
SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: http://localhost/ cannot access http://mt1.google.com/vt/lyrs=m@121&hl=en&src=api&x=1&y=1&z=1&s=Gali. No policy files granted access.
at flash.display::BitmapData/draw()
我看到以下情况:
<mx:UIComponent id="mapContainer"
width="410"
height="300"
/>
googleMap = new Map();
mapContainer.addChild(googleMap);
An ActionScript error has occurred:
SecurityError: Error #2123: Security sandbox violation: BitmapData.draw: http://localhost/ cannot access http://mt1.google.com/vt/lyrs=m@121&hl=en&src=api&x=1&y=1&z=1&s=Gali. No policy files granted access.
at flash.display::BitmapData/draw()
现在,我可以将其添加到自定义客户端上允许的主机。但我需要在任何计算机上都有工作系统)
我试图隐藏它:
templateGoogleMapRenderer.mapContainer.setVisible(false);
templateGoogleMapRenderer.mapContainer.includeInLayout = false;
但没有成功
也许我可以重写UIComponent中的某些方法,这些方法是flex在BitmapData/draw()期间使用的
使用隐藏地图捕获对我来说是成功的结果)在尝试访问位图数据之前,您可能需要强制应用程序检查google maps的跨域策略文件。他们的跨域策略文件位于以下位置:maps.google.com/crossdomain.xml
如果您不确定如何强制它检查跨域策略文件,您可能会发现这很有用:Google Map Flash API有一个名为的方法。如果使用此方法,则不会出现沙盒错误。示例代码:
import flash.display.BitMap;
import flash.display.BitMapData;
var bitmap:Bitmap = googleMap.getPrintableBitmap();
var bitmapData:BitmapData = bitmap.bitmapData;
其中googleMap
是您的com.google.maps.Map
对象