Google maps 未触发多个鼠标事件

Google maps 未触发多个鼠标事件,google-maps,events,mouse,Google Maps,Events,Mouse,我正在使用谷歌地图api。我想一次触发两个鼠标事件。下面是一个代码狙击手 function initialize() { var myLatlng = new google.maps.LatLng(37.4419, -122.1419); var myOptions = { zoom: 13, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.

我正在使用谷歌地图api。我想一次触发两个鼠标事件。下面是一个代码狙击手

function initialize() {
var myLatlng = new google.maps.LatLng(37.4419, -122.1419);
var myOptions = {
  zoom: 13,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var polyOptions = {
        strokeColor: '#000000',
        strokeOpacity: 1.0,
        strokeWeight: 3  }
    poly = new google.maps.Polyline(polyOptions);
    poly.setMap(map);
    // Add a listener for the click event
    google.maps.event.addListener(map, 'click', addLatLng);
}

function addLatLng(event) {
var path = poly.getPath();

if(!draw)
{
    path.push(event.latLng);
    path.push(event.latLng);
    draw = true;
// Add a new marker at the new plotted point on the polyline.

    var marker = new google.maps.Marker({
            position: event.latLng,
            title: '#' + path.getLength(),
            map: map  });
    google.maps.event.addListener(map, 'mousemove', moveTrackLine);
}
else
{
        path.push(event.latLng);
        var marker = new google.maps.Marker({
                                                    position: event.latLng,
                                                    title: '#' + path.getLength(),
                                                    map: map  });
        draw = false;
}
}

function moveTrackLine(event) {

var path = poly.getPath();
// replace the old point with a new one to update the track
path.pop();
path.push(event.latLng);
}
当我第一次看到地图上放置的标记时,单击地图。然后,当鼠标移动时,我会看到多段线更新并正确跟随光标。下一步,如果我点击地图,我不会看到地图上放置的标记,也不会进入addLatLng功能。提前感谢您的帮助和时间。
-tim将多段线的
可点击
-选项设置为false

问题:一旦mousemove事件应用于地图,您将无法再单击地图,因为鼠标光标下方始终是多段线

将多段线的“可单击”选项设置为false时,多段线不会响应鼠标事件,单击事件将传递到地图