首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在MVCArray上使用'Heading_changed‘

在MVCArray上使用'Heading_changed‘
EN

Stack Overflow用户
提问于 2013-01-11 21:00:52
回答 1查看 142关注 0票数 0

我正在努力研究如何改变下面的代码来处理“Heading_change”而不是“Click”。有人做到这一点了吗?即使没有鼠标点击,它仍然是一个(事件)吗?

代码语言:javascript
复制
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");
    } 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-11 21:38:51

简单的改变

代码语言:javascript
复制
google.maps.event.addListener(map, 'click', addLatLng);

代码语言:javascript
复制
google.maps.event.addListener(map, 'heading_changed', addLatLng);

但是,heading_changed事件没有关联的MouseEvent,也就是说,您不能传入一个事件对象来获取事件发生位置的latLng,因为heading_changed事件没有关联的位置。所以你需要重新考虑你想让你的函数做什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14278748

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档