I am having a problem loading kml file which is on remote server on
google map:
here is a code i have written:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<maps:Map xmlns:maps="com.google.maps.*"
id="map" width="100%" height="100%"
key="ABQIAAAAmhf97bxAvnvAElwf2oBgThTeqI0CJ5Ez1bnkcqDQSoGi9AoZ8RSuzoarjBEkZVxW5z7Dg19H4DUZWA"
layoutDirection="ltr"
mapevent_mapready="onMapReady(event)"
sensor="true"/>
<mx:Script>
<![CDATA[
import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapMouseEvent;
import com.google.maps.MapType;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.controls.ZoomControl;
import com.google.maps.overlays.GroundOverlay;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.overlays.Polyline;
import com.google.maps.overlays.PolylineOptions;
import com.google.maps.styles.FillStyle;
import com.google.maps.styles.StrokeStyle;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.TextArea;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.xml.SimpleXMLDecoder;
import mx.utils.ObjectUtil;
import mx.utils.XMLUtil;
private var loader:URLLoader;
private var urlRequest:URLRequest;
private function onMapReady(event:Event):void {
map.setCenter(new
LatLng(36.07954952145647,-112.2550785337791),
12, MapType.NORMAL_MAP_TYPE);
map.addControl(new ZoomControl());
map.addControl(new MapTypeControl());
map.enableScrollWheelZoom();
loader = new URLLoader();
urlRequest = new URLRequest();
urlRequest.url =
"http://165.230.77.82/RIJAN_1/upload/
kmlforgoogle.kml";
loader.load(urlRequest);
var bytes:ByteArray = loader.data as ByteArray;
htp.send();
//Alert.show("Show data: " + bytes.length);
}
private function myresult(event:ResultEvent):void
{
var retxml:XML = XML(event.result);
var retDoc:XMLDocument = new
XMLDocument(retxml);
var decoder:SimpleXMLDecoder = new
SimpleXMLDecoder();
var resultObj:Object =
decoder.decodeXML(retDoc);
var resltTag:String =
resultObj.kml.Document.Placemark.LineString.coordinates;
//Alert.show("Hi" + resltTag);
var Strsource:Array = new Array();
Strsource = resltTag.split(" ");
//Alert.show("Hi" + Strsource[0]);
var subsource:String = "";
var strSubArray:Array = new Array();
var finalarray:Array = new Array();
var i:int;
for (i=0; i<Strsource.length; i++)
{
subsource = null;
strSubArray = null;
subsource = Strsource[i];
strSubArray = subsource.split(",");
if (strSubArray.length == 3)
{
//Alert.show("lat" +
strSubArray[0] + " lon: " +
strSubArray[1]);
finalarray.push(new
LatLng(strSubArray[0],strSubArray[1]));
//Alert.show("Final" +
finalarray );
}
}
//-------------
//var polyline:Polyline = new
Polyline(finalarray, new
PolylineOptions({ strokeStyle: new StrokeStyle({
//color: 0xFF0000,
//thickness: 4,
//alpha: 0.7})
//}));
//map.addOverlay(polyline);
//--------------------
Alert.show("Final" + finalarray);
var Polyopt:PolylineOptions = new
PolylineOptions ({strokeStyle:
new StrokeStyle({color: 0x987654}),
fillStyle: new FillStyle({color:
0x223344, alpha: 0.8}),
radius: 12, hasShadow: true})
var PolyA:Polyline = new
Polyline(finalarray,Polyopt);
Alert.show("Hello" + PolyA);
map.addOverlay(PolyA);
}
]]>
</mx:Script>
<mx:HTTPService id = "htp"
resultFormat="e4x"
url="http://165.230.77.82/RIJAN_1/upload/kmlforgoogle.kml"
result="myresult(event)" />
</mx:Application>
Please let me know where am i going wrong.
Your help will be appreciated.
--
You received this message because you are subscribed to the Google Groups
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api-for-flash?hl=en.