Google Maps API v3 - infowindow中的ContextMenu

时间:2013-02-15 17:49:35

标签: google-maps contextmenu

我正在使用ContextMenu.js在右键单击地图时为几个选项创建上下文菜单。插件在这里: http://googlemapsmania.blogspot.com/2012/04/create-google-maps-context-menu.html

以下是我的部分代码:

/* Right click marker for location specific context menu */
            google.maps.event.addListener(contextMenu, 'menu_item_selected', function(latLng, eventName){
                switch(eventName){
                    case 'directions_from_click':
                        //Populate start field with the marker location
                        showDirections();
                        geocoder.geocode({latLng: latLng}, function(results, status) {
                          if (status == google.maps.GeocoderStatus.OK) {
                            if (results[0]) {
                              fAddress = results[0].formatted_address;
                              $('#start').val(fAddress);

                            }
                          }
                        });
                        $('#panelWrapper').focus();
                        break;
                    case 'directions_to_click':
                        //Populate start field with the marker location
                        showDirections();
                        geocoder.geocode({latLng: latLng}, function(results, status) {
                              if (status == google.maps.GeocoderStatus.OK) {
                                if (results[0]) {
                                  fAddress = results[0].formatted_address;
                                  $('#end').val(fAddress);
                                }
                              }
                            });
                            $('#panelWrapper').focus();
                        break;
                }
            });

但这仅适用于右键单击地图。我想采用相同的上下文菜单并将其用于我的信息窗口内的链接。例如,一个链接表示" Directions" (见图),然后点击上下文菜单。我该怎么做呢?我

enter image description here

0 个答案:

没有答案