Hi Marc:

sorry for the later reply but I think you should look into the
following:

- maybe you should listen for MapMouseEvents from the Polygon then
have the ContextMenu appear on the map

- not sure you can actually set a contextMenu on the polygon maybe try
the map? I added a contextMenu to the map based on whether or not an
Overlay was in "selected state"

sample code I wrote:
==================
private function addContextMenus():void{

        cmiSaveEdit = new ContextMenuItem("Save Current Edit",false,false);
        cmiClearEdit = new ContextMenuItem("Remove Current
Edit",false,false);
        //cmiStartEdit = new ContextMenuItem("Add " +
(this.currentDataLayer) ?
        //                              this.currentDataLayer.name + " Feature" 
: "new
Feature"        ,false, false);

 
cmiSaveEdit.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
cmiSaveEdit_Select);
 
cmiClearEdit.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
cmiClearEdit_Select);

        this.contextMenuMap = new ContextMenu();
        contextMenuMap.hideBuiltInItems();
        contextMenuMap.customItems = [cmiSaveEdit,cmiClearEdit];
        contextMenuMap.addEventListener(ContextMenuEvent.MENU_SELECT,
contextMenu_menuSelect);
        this.map.contextMenu = contextMenuMap;

        }

==================

hth

Hugely

On Jul 3, 8:22 am, Marc <[email protected]> wrote:
> I'm trying to add a custom context menu, but only for certain overlays
> on a map (mostly polygons). Is there a way to do this? My code is not
> working:
>
> userRecalledPolygonData.forEach(addPolyline);
>
> function addPolyline(element:*, index:int, arr:Array):void {
>         if(element) {
>                 var encodedSets:Array = new Array();
>
>                 var encodedLevels:String = "B??B";
>                 var encoded:EncodedPolylineData = new 
> EncodedPolylineData(element[0],
> 32,encodedLevels,4);
>
>                 encodedSets.push(encoded);
>
>                 var myPolygon:Polygon = Polygon.fromEncoded(encodedSets, new
> PolygonOptions({tooltip: element[1]}));
>                 map.addOverlay(myPolygon);
>
>                 var my_menu:ContextMenu = new ContextMenu();
>                 my_menu.hideBuiltInItems();
>
>                 var my_remove = new ContextMenuItem("Remove from display");
>                 var my_edit = new ContextMenuItem("Edit polygon");
>
>                 my_menu.customItems.push(my_remove, my_edit);
>
>                 myPolygon.contextMenu = my_menu;
>
>                 my_remove.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
> function (e:ContextMenuEvent):void { trace("Remove: " +
> element[1]); });
>                 my_edit.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, 
> function
> (e:ContextMenuEvent):void { trace("Edit: " + element[1]); });
>         }
>
> }
>
> Error 1119: Access of possibly undefined property contextMenu through
> a reference with static type com.google.maps.overlays:Polygon

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