I am basically populating a map with polygons, I am using the flex sdk. The problem I am having is that each time it adds a parish it keep adding to the previous polygons and treating it as one. HELP!!
<?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" mapevent_mapready="onMapReady(event)" width="100%" height="100%" key="ABQIAAAAGe0Fqwt-nY7G2oB81ZIicRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRcFmaI_t1gtsS5UN6mWQkH9kIw6Q"/>
<mx:Script>
<![CDATA[
import com.google.maps.Color;
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.controls.ZoomControl;
import com.google.maps.overlays.Polygon;
import com.google.maps.overlays.PolygonOptions;
import com.google.maps.styles.FillStyle;
import com.google.maps.styles.StrokeStyle;
import mx.controls.Alert;
import mx.utils.ColorUtil;
import mx.utils.object_proxy;
private var polys:Array = new Array();
private var labels:Array = new Array();
// private var pts:Array = new Array();
// private var poly:Polygon;
// private var map:Map;
private function onMapReady(event:Event):void {
map.setCenter(new LatLng(18.070146,-77.225647), 9, MapType.NORMAL_MAP_TYPE);
map.addControl(new ZoomControl());
map.enableScrollWheelZoom();
map.enableContinuousZoom();
getXml();
}
public function getXml():void {
var xmlString:URLRequest = new URLRequest("parish.xml");
var xmlLoader:URLLoader = new URLLoader(xmlString);
xmlLoader.addEventListener("complete", readXml);
}
private function readXml(event:Event):void {
var markersXML:XML = new XML(event.target.data);
var markers:XMLList = markersXML..parish;
//var markersCount:int = markers.length();
var i:Number;
var t:Number;
for(i=0; i < markers.length(); i++) {
var marker:XML = markers[i];
var name:String = marker.@name;
var colour:String = marker.@colour;
// Alert.show("");
var the_p:XMLList = markers..point;
var pts:Array = [];
for(t=0; t < the_p.length(); t++) {
var theparish:XML = the_p[t];
pts[t] = new LatLng(theparish.@lat,theparish.@lng);
// Alert.show("working" + theparish.@lat);
// var pts.push(new LatLng(theparish.@lat,theparish.@lng));
}
var poly:Polygon = new Polygon(pts,
new PolygonOptions({
strokyStyle: new StrokeStyle({
color: colour,
thickness: 1,
alpha: 0.2}),
fillStyle: new FillStyle({
color: colour,
alpha: 0.2})
}));
//polys.push(poly);
//labels.push(name);
Alert.show("this");
pts = []
map.addOverlay(poly);
}
}
/* public function createMarker(latlng:LatLng, name:String, address:String, type:String): Marker {
var marker:Marker = new Marker(latlng, new MarkerOptions({icon: new customIcons[type], iconOffset: new Point(-16, -32)}));
var html:String = "<b>" + name + "</b> <br/>" + address;
marker.addEventListener(MapMouseEvent.CLICK, function(e:MapMouseEvent):void {
marker.openInfoWindow(new InfoWindowOptions({contentHTML:html}));
});
return marker;
}
*/
]]>
</mx:Script>
</mx:Application>