1

我正在使用 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;
                }
            });

但这仅适用于右键单击地图。我想采用相同的上下文菜单并将其用于我的信息窗口内的链接。例如,显示“方向”的链接(见图),然后单击时会出现上下文菜单。我该怎么做呢?我

在此处输入图像描述

4

0 回答 0