I tried posting a reply to this yesterday but it hasn't shown up.
Sorry if I double-post.

I've got a grid drawn on my map, now. It's made up of an array of
polygons. It looks great, and allows me to go from pixel to LatLong
and back. Only problem is it makes everything very slow. Here's the
code:

private function createGrid():void {
        var polygon:Polygon;
        var evenWindowDivision:Number = windowWidth/multiplier;
        var pixel:Point;
        var getLatLng:LatLng;
        var getLatLngWH:LatLng;
        var tileWidth:Number;
        var tileHeight:Number;
        var nwLat:Number;
        var nwLng:Number;
        var seLat:Number;
        var seLng:Number;
        var tileArray:Array = [];               //This array holds the points 
(on-screen
pixel coordinates) that are the top-left corner of each tile
        var polyTileArray:Array = [];   //This array holds the actual polygons
that are displayed on screen

        for(var row:Number = 0; row < evenWindowDivision; row++){
                for(var col:Number = 0; col < evenWindowDivision; col++){
                        pixel = new Point(col*multiplier, row*multiplier);
                        //getLatLng = this.map.fromViewportToLatLng(pixel);
                        //tileArray.push(getLatLng);
                        tileArray.push(pixel);
                }
        }

        for(var i:Number = 0; i < tileArray.length; i++){
                //trace("Tile #"+i+" coordinates: "+tileArray[i]);
                tileWidth = tileArray[i].x + multiplier;
                tileHeight = tileArray[i].y + multiplier;
                getLatLng = this.map.fromViewportToLatLng(tileArray[i]);
                getLatLngWH = this.map.fromViewportToLatLng(new Point(tileWidth,
tileHeight));
                nwLat = getLatLng.lat();
                nwLng = getLatLng.lng();
                seLat = getLatLngWH.lat();
                seLng = getLatLngWH.lng();

                polygon = new Polygon([
                        new LatLng(nwLat, nwLng),
                        new LatLng(nwLat, seLng),
                        new LatLng(seLat, seLng),
                        new LatLng(seLat, nwLng),
                        new LatLng(nwLat, nwLng)
                ],
                new PolygonOptions({
                        strokeStyle: new StrokeStyle({
                                color: 0x000000,
                                thickness: 1,
                                alpha: 1.0}),
                        fillStyle: new FillStyle({
                                color: 0xFFFFFF,
                                alpha: 0.0})
                }));

                polyTileArray.push(polygon);
                this.map.addOverlay(polygon);
        }
        polyTileArray[36].setOptions(new PolygonOptions({fillStyle: new
FillStyle({color: 0xFF6600, alpha: 0.5})}));
}


I'm looking to optimize this code by drawing the grid directly on the
viewport. However, I'm unable to access the viewport, and I'm not sure
it's even possible if I can. Does anyone know how to interact with the
viewport? Or know of a better method of creating the grid?

-- 
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.

Reply via email to