Ok so over the last couple of days we have come up with a solution to grab information to do some caching. One of the things that I am doing is figuring out where i need to move to grab the next set of data. Well i wrote a little something i will post as a comment in a bit that will give the coords of Northern, Southern, Eastern and Western most portions of the zip code.
With this now i will be able to do a little math a populate a center point for my zip codes that is not listed in my feature collection. I am sure there is more that one could do as well.
//this function will get you the most nortern, southern, eastern and western lat/lng of the feature collection you pass it and will also give you the center
public function findBoundsPointsAndCenter(fc:FeatureCollection):LatLngCollection
{//get init value so we can have
var TempLLC:LatLngCollection = PolygonFeature(fc.getAt(0)).getLatLngs();
var WestLatLng:LatLng = new LatLng(0,0);
var EastLatLng:LatLng = new LatLng(0,0);
var NorthLatLng:LatLng = new LatLng(0,0);
var SouthLatLng:LatLng = new LatLng(0,0);
//going to fill them with values because they didn’t set right above for some reason??
NorthLatLng = LatLng(TempLLC.getAt(0));
SouthLatLng = LatLng(TempLLC.getAt(0));
WestLatLng = LatLng(TempLLC.getAt(0));
EastLatLng = LatLng(TempLLC.getAt(0));
//loop through each poly and find most extreme point
for(var a:int = 0;a < fc.getSize();a++)
{
var PolyLLC:LatLngCollection = PolygonFeature(fc.getAt(a)).getLatLngs();
for(var b:int = 0; b < PolyLLC.getSize();b++)
{
if(LatLng(PolyLLC.getAt(b)).lat > NorthLatLng.lat)
NorthLatLng = LatLng(PolyLLC.getAt(b));
if(LatLng(PolyLLC.getAt(b)).lat < SouthLatLng.lat)
SouthLatLng = LatLng(PolyLLC.getAt(b));
if(LatLng(PolyLLC.getAt(b)).lng > EastLatLng.lng)
EastLatLng = LatLng(PolyLLC.getAt(b));
if(LatLng(PolyLLC.getAt(b)).lng < WestLatLng.lng)
WestLatLng = LatLng(PolyLLC.getAt(b));
}
}
//get the Average Lat Lng which is the amount of variance + lat or lng
var AvgLat:Number = EastLatLng.lat + ((WestLatLng.lat – EastLatLng.lat)/2);
var AvgLng:Number = NorthLatLng.lng + ((SouthLatLng.lng – NorthLatLng.lng )/2);
var centerLatLng:LatLng = new LatLng(AvgLat,AvgLng);
var FourEdgePointsLLC:LatLngCollection = new LatLngCollection;
FourEdgePointsLLC.add(NorthLatLng);
FourEdgePointsLLC.add(SouthLatLng);
FourEdgePointsLLC.add(WestLatLng);
FourEdgePointsLLC.add(EastLatLng);
//throw the info on the screen to make sure it works
var CenterPOI:Poi = new Poi(centerLatLng);
var NorthPOI:Poi = new Poi(NorthLatLng);
var SouthPOI:Poi = new Poi(SouthLatLng);
var EastPOI:Poi = new Poi(EastLatLng);
var WestPOI:Poi = new Poi(WestLatLng);
NorthPOI.setLabel(‘North’);
SouthPOI.setLabel(‘South’);
EastPOI.setLabel(‘East’);
WestPOI.setLabel(‘West’);
myMap.addPoi(NorthPOI);
myMap.addPoi(SouthPOI);
myMap.addPoi(EastPOI);
myMap.addPoi(WestPOI);
myMap.addPoi(CenterPOI);
return FourEdgePointsLLC;
}