Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to add a crossdomain.xml to the server side (in root folder) to allow the application to access your KML file. For example, if you want to allow access to your server to all IPs and domain names just use a simple wild card as below in your crossdomain.xml file:</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;cross-domain-policy&gt; &lt;allow-access-from domain="*" /&gt; &lt;/cross-domain-policy&gt; </code></pre> <p>For more information about using crossdomain file see: <a href="http://www.flashvalley.com/fv_tutorials/transfering_data_across_domains_using_crossdomain.xml/" rel="nofollow">Transfering Data Accross Domains Using crossdomain.xml</a></p> <p>If you don't have access to the server or if this solution doesn't work for you, you have to modify the KML.as class in openscales (found in org.openscales.core.layer package).</p> <p>Change line 19 </p> <pre><code>private var _request: XMLRequest = null; </code></pre> <p>to </p> <pre><code>private var _request :URLLoader = null; </code></pre> <p>Here is the entire modified KML class:</p> <pre><code>package org.openscales.core.layer { import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLRequestMethod; import org.openscales.core.Trace; import org.openscales.core.feature.Feature; import org.openscales.core.format.KMLFormat; import org.openscales.core.request.XMLRequest; import org.openscales.geometry.basetypes.Bounds; public class KML extends FeatureLayer { private var _url :String = ""; private var _request :URLLoader = null; private var _kmlFormat :KMLFormat = null; private var _xml :XML = null; public function KML ( name :String, url :String, bounds :Bounds = null ) { this._url = url; this.maxExtent = bounds; super( name ); this._kmlFormat = new KMLFormat(); } override public function destroy () :void { if ( this._request ) this._request = null; this.loading = false; super.destroy(); } override public function redraw ( fullRedraw :Boolean = true ) :void { if ( !displayed ) { this.clear(); return; } if ( !this._request ) { this.loading = true; this._request = new URLLoader(); this._request.addEventListener( Event.COMPLETE, onSuccess ); this._request.addEventListener( IOErrorEvent.IO_ERROR, onFailure ); this._request.load( new URLRequest( url )); } else { this.clear(); this.draw(); } } public function onSuccess ( event :Event ) :void { this.loading = false; var loader :URLLoader = event.target as URLLoader; // To avoid errors if the server is dead try { this._xml = new XML( loader.data ); if ( this.map.baseLayer.projection != null &amp;&amp; this.projection != null &amp;&amp; this.projection.srsCode != this.map.baseLayer.projection.srsCode ) { this._kmlFormat.externalProj = this.projection; this._kmlFormat.internalProj = this.map.baseLayer.projection; } this._kmlFormat.proxy = this.proxy; var features :Vector.&lt;Feature&gt; = this._kmlFormat.read( this._xml ) as Vector.&lt;Feature&gt;; this.addFeatures( features ); this.clear(); this.draw(); } catch ( error :Error ) { Trace.error( error.message ); } } protected function onFailure ( event :Event ) :void { this.loading = false; Trace.error( "Error when loading kml " + this._url ); } public function get url () :String { return this._url; } public function set url ( value :String ) :void { this._url = value; } override public function getURL ( bounds :Bounds ) :String { return this._url; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload