Thursday, 23 June 2011

Create Polygon


package utils
{
import com.google.maps.Map3D;
import com.google.maps.overlays.Polygon;
import com.google.maps.overlays.PolygonOptions;
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 mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.ComboBox;


public class CreatePolyUtil
{
public function CreatePolyUtil()
{

}

/**
* This method creates the polygon in th map
*/
public function displayPoly(mapRef:Map3D, coordinateDataProviderRef:ArrayCollection, comboBoxRef:ComboBox):void
{
var index:Number=1;

for (var i:uint=0 ; i <coordinateDataProviderRef.length ; i++)
{
if(coordinateDataProviderRef[i] is Array)
{
if(comboBoxRef.selectedLabel == "Polygon")
{
var polygon:Polygon = new Polygon(coordinateDataProviderRef[i] as Array, new PolygonOptions
({ 
StrokeStyle: new StrokeStyle({color: 0x0000ff,thickness: 10,alpha: 0.7}), 
FillStyle: new FillStyle({color: 0x0000ff,alpha: 0.7}),  tooltip: ("Region: " + index )
}));

mapRef.addOverlay(polygon); 
}
else if(comboBoxRef.selectedLabel =="Polyline")
{
var polyline:Polyline = new Polyline(coordinateDataProviderRef[i] as Array, new PolylineOptions({ strokeStyle: new StrokeStyle({
color: 0xFF0000,
thickness: 4,
alpha: 0.7})
}));

mapRef.addOverlay(polyline);
}
else
{
Alert.show("Please Select 'Polyline' or 'Polygon' to draw a region");
break;
}
index++;
}
}
}
}
}

No comments:

Post a Comment