AIR - Google Maps API安全沙箱违规?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AIR - Google Maps API安全沙箱违规?相关的知识,希望对你有一定的参考价值。
我刚开始使用Google Maps API for Flash(map_1_20.swc)为我正在使用Flash CS5构建的AIR 2.5应用程序。一切都加载并在ADL中显示正常,除了我收到安全沙箱违规:
*** Security Sandbox Violation ***
SecurityDomain 'http://maps.googleapis.com/mapsapi/publicapi?
file=flashapi&url=http%3A%2F%2FgMyDomainName.com&key=ABQIAAAAKlbBGDLCUgZLtxxJ6-
Hi9RQ7KOBhSjQi3kzVUu2XaSyicmBCGxQz68ixtUMxnYSMDFuMNT0cJYPwjQ&sensor=false&v=1.20&fl
pub=&flh=17e8cb187dcf0488fac63df6b16432b7592443ee&flc=at&flcl=a0g30ufvvrvvtvvbo03'
tried to access incompatible context 'app:/MapTest.swf'
//MyDomainName.com represents my domain registered with the API key
当鼠标进入或退出infoWindow时,抛出安全沙箱违规。
这是我的文档类代码
package
{
import com.google.maps.LatLng;
import com.google.maps.InfoWindowOptions;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import flash.display.Sprite;
import flash.events.Event;
public class MapTest extends Sprite
{
public function MapTest()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(evt:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
var map:Map = new Map();
map.key = "ABQIAAAAKlbBGDLCUgZLtxxJ6-Hi9RQ7KOBhSjQi3kzVUu2XaSyicmBCGxQz68ixtUMxnYSMDFuMNT0cJYPwjQ";
map.url = "http://MyDomainName.com"; //MyDomainName.com represents my domain registered with the API key
map.sensor = "false";
map.width = stage.stageWidth;
map.height = stage.stageHeight;
map.alpha = 0.0;
map.addEventListener(MapEvent.MAP_READY, mapReadyEventHandler);
map.addEventListener(MapEvent.TILES_LOADED, tilesLoadedEventHandler);
addChild(map);
}
private function mapReadyEventHandler(evt:MapEvent):void
{
trace("Map Ready");
evt.currentTarget.removeEventListener(MapEvent.MAP_READY, mapReadyEventHandler);
evt.currentTarget.setCenter(new LatLng(45.53329,-73.67638), 11, MapType.NORMAL_MAP_TYPE);
}
private function tilesLoadedEventHandler(evt:MapEvent):void
{
trace("Tiles Loaded");
evt.currentTarget.removeEventListener(MapEvent.TILES_LOADED, tilesLoadedEventHandler);
evt.currentTarget.alpha = 1.0; //Create Fade In Here (Tween)
evt.currentTarget.openInfoWindow(evt.currentTarget.getCenter(), new InfoWindowOptions({title: "Test Title", content: "Test Content."}));
}
}
}
答案
我想你可能没有跨域问题。
http://kb2.adobe.com/cps/142/tn_14213.html
以上是关于AIR - Google Maps API安全沙箱违规?的主要内容,如果未能解决你的问题,请参考以下文章
有没有办法在AIR应用程序沙箱中使用jQuery.getScript?
使用google API之前需要對input 做什麼 安全性的處理?
为啥我在使用 Google Maps API 时没有收到“同源政策”警告?
Google Maps Place API 和 Google Maps Time Zone API 之间的区别
Google Maps API DirectionsService.route 与 Google Maps Directions 不同