当你在flex中显示自己发部的地图时
你可以这样写
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx=" http://www.adobe.com/2006/mxml"
xmlns:esri=" http://www.esri.com/2008/ags"
pageTitle="Example - ArcGIS API for Flex connecting to a dynamic AGS service">
<esri:Map>
<esri:ArcGISDynamicMapServiceLayer
url=" http://localhost/arcgis/rest/services/ahtl/MapServer"/>
</esri:Map>
</mx:Application>
<mx:Application
xmlns:mx=" http://www.adobe.com/2006/mxml"
xmlns:esri=" http://www.esri.com/2008/ags"
pageTitle="Example - ArcGIS API for Flex connecting to a dynamic AGS service">
<esri:Map>
<esri:ArcGISDynamicMapServiceLayer
url=" http://localhost/arcgis/rest/services/ahtl/MapServer"/>
</esri:Map>
</mx:Application>
但你发现你发布的地图无法显示 有时还有安全沙箱的问题,网上说关于安全沙箱的问题可以这样解决
写一个crossdomain.xml放在网站的根目录下,它的内容是
<?xml version="1.0" ?>
- <cross-domain-policy>
<allow-access-from domain="*" />
<site-control permitted-cross-domain-policies="all" />
<allow-http-request-headers-from domain="*" headers="*" />
</cross-domain-policy>
- <cross-domain-policy>
<allow-access-from domain="*" />
<site-control permitted-cross-domain-policies="all" />
<allow-http-request-headers-from domain="*" headers="*" />
</cross-domain-policy>
但我发现这样还是不能解决问题,还是不能显示 地图,在我的努力下,我终于找到方法,在arcserver的manager中把enable secutity关掉,这样就可以显示 地图了,但这样关掉就不安全了;
另外还可能遇到安全沙箱的问题,可以到网上抄一个crossdomain.xml
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*" secure="false" />
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
</cross-domain-policy>
crossdomain.xml放在要用资源的根目录下
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*" secure="false" />
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
</cross-domain-policy>
crossdomain.xml放在要用资源的根目录下
Flex代码中添加:
Security.loadPolicyFile("http://domain/crossdomain.xml");
Security.loadPolicyFile("http://domain/crossdomain.xml");