Hi there
Thank you so much for the reply :)
Thank you for the answer and yes it does work as I got that running just
before you replied lol but now my second problem is that each block should
retrieve diffident information... I can use an if statement to cycle trough
my database based on the block but I need to know which block I clicked. So
I need to be able to identify the block.
Now I have created an array to store and label each block but doesnt help as
I dont know how to get each block's unique instance name. Any idea on this?
code is as follows
private var gridBlocks:ArrayCollection = new ArrayCollection();
private var blockIndex:Number;
private var topLeftLat:Number;
private var topLeftLong:Number;
private var bottomLeftLat:Number;
private var bottomLeftLong:Number;
private var bottomRightLat:Number;
private var bottomRightLong:Number;
private var topRightLat:Number;
private var topRightLong:Number;
public function createGrid():void
{
for(var i:int = 0; i < 23; i++)
{
blockIndex = i;
var label:String = 'Block ' + gridBlocks.length;
topLeftLat = Niger5.getItemAt(i).LeftTopLat;
topLeftLong = Niger5.getItemAt(i).LeftTopLong;
bottomLeftLat = Niger5.getItemAt(i).LeftBottomLat;
bottomLeftLong = Niger5.getItemAt(i).LeftBottomLong;
bottomRightLat = Niger5.getItemAt(i).RightBottomLat;
bottomRightLong = Niger5.getItemAt(i).RightBottomLong;
topRightLat = Niger5.getItemAt(i).RightTopLat;
topRightLong = Niger5.getItemAt(i).RightTopLong;
gridBlocks.addItem({label: label,gridBlock: gridBlock});
var gridBlock:Polygon = new Polygon([
new LatLng(topLeftLat, topLeftLong),
new LatLng(bottomLeftLat, bottomLeftLong),
new LatLng(bottomRightLat, bottomRightLong),
new LatLng(topRightLat, topRightLong)
],
new PolygonOptions({
strokeStyle: new StrokeStyle({
color: 0x00FFFF,
thickness: 1,
alpha: 1}),
fillStyle: new FillStyle({
color: 0x666666,
alpha: 0.7})
}));
map.addOverlay(gridBlock);
gridBlock.addEventListener(MapMouseEvent.CLICK, function(e:Event):void
{
check1.text = "Yes";
});
}
}
On Thu, Aug 4, 2011 at 1:26 PM, Thiago Cordeiro <[email protected]>wrote:
> Hi,
>
> Your eventListner is a MouseEvent?
>
> if so, you can get the currentTarget to know what block was clicked...
>
> for example:
>
> block.addEventListner(MouseEvent.CLICK, doSomething);
>
> private function doSomething(e:MouseEvent) {
> var clickedBlock = e.currentTarget as Overlay;
> }
>
> Look, you can extend your Overlay to have any object that you need.
> for example:
>
> private function doSomething(e:MouseEvent) {
> var clickedBlock = e.currentTarget as CustomOverlay;
> var obj:Object = clickedBlock.anyCustomObject;
> }
>
> Best Regards,
> Thiago
>
>
> i don't know if it's the solution.
>
>
> 2011/8/4 Martin Roberts <[email protected]>
>
>> Hi guys
>>
>> Hope someone can steer me in the right direction here.
>>
>> Basically I want to create a dynamic grid with polygon overlays. I add
>> the overlays to the map with a for loop and cascading them based on lat
>> longs im pulling from an xml sheet. So far so good no hassles,
>>
>> My problem is that each grid block must have an event listener and I am
>> creating up to 300 grid blocks at a time. Now all these blocks needs an
>> eventhandeler and short of manually coding all the event handlers I cant
>> come up with a solution. There must be a better way of doing this.
>>
>> Im fairly new to programming and is in the deep end here. Im using Flash
>> Builder 4 and using the google flash API.
>>
>> Please please if any one can help with this or have a code snippet of
>> something close to what I need I would be very great-full...
>>
>> Thank you
>> Martin
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Maps API For Flash" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/google-maps-api-for-flash/-/SIxjexmZYDcJ.
>> 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.
>>
>
> --
> 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.
>
--
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.