Wednesday, January 6, 2010

Moving a polygon

So, one of the big things that I am hoping to have in my system is some way of displaying view rectangles on a custom overview map. Since people will change their views often it would be troublesome if I had to reset the entire map in order to move one of the view rectangles. I will be posting more about the custom overview map when it is finalized since from what i can tell nobody else in the google maps flex community has done it...

Here is an example of how this moving can be done...
public function setCenter(latLng : LatLngBounds) : void
{
// this funciton is only for testing, it will be replaced,
// polygons stored in the team member vo will store a polygon
// that can be changed when they change their view!
map.setCenter(latLng.getCenter());

if (polygon == null)
{
polygon = new Polygon([
latLng.getNorthWest(),
latLng.getSouthWest(),
latLng.getSouthEast(),
latLng.getNorthEast(),
latLng.getNorthWest()],
new PolygonOptions({
strokeStyle: new StrokeStyle({
color: 0x0000ff,
thickness: 4,
alpha: 0.7}),
fillStyle: new FillStyle({
color: 0x0000ff,
alpha: 0.5})
}));

map.addOverlay(polygon);
}
else
{
polygon.setPolyline(0,
[
latLng.getNorthWest(),
latLng.getSouthWest(),
latLng.getSouthEast(),
latLng.getNorthEast(),
latLng.getNorthWest()]);
}

}


You need to remember to store the polygon somewhere (it doesn't have to be in the class with the map)...

No comments:

Post a Comment