我正在努力研究如何改变下面的代码来处理“Heading_change”而不是“Click”。有人做到这一点了吗?即使没有鼠标点击,它仍然是一个(事件)吗?
google.maps.event.addListener(map, 'click', addLatLng);
/**
* Handles click (or other) events on a map, and adds a new point to the Polyline.
* @param {MouseEvent} mouseEvent
*/
function addLatLng(event) {
var path = flightPath.getPath();
// Because path is an MVCArray, we can simply append a new coordinate
// and it will automatically appear
path.push(event.latLng);
// 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
});alert("Done");
} 发布于 2013-01-11 21:38:51
简单的改变
google.maps.event.addListener(map, 'click', addLatLng);至
google.maps.event.addListener(map, 'heading_changed', addLatLng);但是,heading_changed事件没有关联的MouseEvent,也就是说,您不能传入一个事件对象来获取事件发生位置的latLng,因为heading_changed事件没有关联的位置。所以你需要重新考虑你想让你的函数做什么。
https://stackoverflow.com/questions/14278748
复制相似问题