Hey Jamie-
Sorry for not replying. As far as I'm aware, your workaround is the best
approximation to what you want to achieve.
- pamela
On Wed, Oct 29, 2008 at 3:59 AM, JamieJag <[EMAIL PROTECTED]> wrote:
>
> Hi Pam,
>
> Is there some shortcut to attach a menu (as opposed to a right-click
> driven context menu) on a marker? For example, I'd like to show users
> several options when they click on a marker, selecting one of which
> would open the infowindow. I have reasons to do it on a click and not
> a right-click. As of now, since the menu cannot be attached directly
> to a marker, I have this following work-around:
>
> marker.addEventListener(MapMouseEvent.CLICK,
> function(e:MapMouseEvent):void {
> currentMarker = e.target as Marker; // currentMarker
> declared above
> as "var currentMarker:Marker;"
> var pnt:Point =
> map.fromLatLngToViewport(currentMarker.getLatLng());
> showMenu(currentMarker, pnt.x + 20, pnt.y + 10);
> });
> where showMenu is defined as:
>
> private function showMenu(whichMarker:Marker, x:Number,
> y:Number):void{
> var menu:Menu = Menu.createMenu(null, MenuData, false);
> menu.labelField = "@label";
> menu.addEventListener(MenuEvent.ITEM_CLICK, handleMenuItemClick);
> menu.show(x,y);
> }
> (MenuData is my own XML)
>
> and
>
> private function handleMenuItemClick(event:MenuEvent):void
> {
> if (event.label.toLowerCase() == "show more info")
> {
> var myHTML:String = "abcd" + "\nabcd" + "\nabcd" + "\nabcd"
> +
> "\nabcd" + "\nabcd" + "\nabcd" +
> "\nabcd" + "\nabcd" + "\nabcd" + "\nabcd" ;
> var infoWindowOptions:InfoWindowOptions = new
> InfoWindowOptions({content:myHTML});
> var height:Number = Number(infoWindowOptions.height);
> currentMarker.openInfoWindow(infoWindowOptions);
> }
> }
>
> Note that I'm having to use a "global" variable called currentMarker
> since I could only attach a map's container to the menu, and not the
> marker itself. If the marker itself could be attached to the menu,
> then MenuEvent could give me the marker in event.target.
>
> I hope I have expressed myself clearly. If not :-(, please reply and
> I'll clarify further.
>
> -M
>
> On Oct 7, 10:30 am, "pamela (Google Employee)" <[EMAIL PROTECTED]>
> wrote:
> > Heya-
> >
> > I put together a demo to show this, as I know it may seem a bit tricky:
> >
> > http://code.google.com/apis/maps/documentation/flash/demogallery.html...
> >
> > - pamela
> >
> > On Tue, Oct 7, 2008 at 4:26 PM, pamela (Google Employee)
> >
> >
> >
> > <[EMAIL PROTECTED]> wrote:
> > > Hi folks-
> >
> > > It is currently possible to add to the context menu of the map by
> > > setting the contextMenu property of the map component. I'm pasting
> > > some code which just adds two items to the menu:
> > > var _Menu:ContextMenu = new ContextMenu();
> >
> > > var _MenuItem1:ContextMenuItem = new ContextMenuItem('Menu 1');;
> > > var _MenuItem2:ContextMenuItem = new ContextMenuItem('Menu 2');;
> >
> > > _Menu.customItems.push(_MenuItem1);
> > > _Menu.customItems.push(_MenuItem2);
> >
> > > this.map.contextMenu = _Menu;
> >
> > > You could assign listeners to those items to do stuff like add markers
> > > or set the view of the map.
> >
> > > Let me know what questions you still have.
> >
> > > - pamela
> >
> > > On Mon, Oct 6, 2008 at 10:20 PM, Megharaja <[EMAIL PROTECTED]>
> wrote:
> >
> > >> Hi,
> >
> > >> Even am also have the same requirement.
> >
> > >> So i have created context menu in flex then i will click on the map to
> > >> get the geocode.Finally i created marker on that place.
> >
> > >> Is it possible to create the marker by right clicking on the map.
> >
> > >> Thanks,
> > >> Megharaja S.H.
> >
> > >> On Oct 6, 5:52 pm, Jash <[EMAIL PROTECTED]> wrote:
> > >>> Hi
> >
> > >>> Is there anyway that i can get Flex context menu to be shown on right
> > >>> click on marker or Map.
> > >>> When i saw the API there seems to be no event for MouseRightClick.
> Can
> > >>> this feature be added .There are many occassions when one would like
> > >>> to have a rightclick working on marker or map.
> >
> > >>> Currently i have added 2 event listeners for markers. One for click
> > >>> event and other for Double Click.
> > >>> When i do a click i show infowindow and on double click showin a
> menu.
> > >>> But when i double click what happens is the infowindow alos gets open
> > >>> and the menu also gets open.
> >
> > >>> How do we come over this. Also the menu stays open unless i don't
> > >>> click any item inside it, What if user wants to click elsewhere on
> map
> > >>> and the menu should close.
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---