JavaScript谷歌地图绘画事件 [英] Javascript google maps drawing events

查看:166
本文介绍了JavaScript谷歌地图绘画事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在google maps api提供的事件侦听器中遇到问题。事情是,有些事件运行,有些不是。我有一个setListeners函数,用于在多边形叠加完成后设置侦听器。我想要挂钩的事件是:set_at,insert_at,remove_at并单击。现在,点击事件正确运行,但其他人没有。我能做什么错?这里是代码:

  self.setListeners = function(){
//这个点击事件正确运行
google.maps.event.addListener(self.map,'click',function(e){
self.clearSelection();
})

console.log (self.drost);
if(typeof self.drost!='undefined'){
self.drost.addListener('set_at',function(e){
console.log(e.overlay);
});
self.drost.addListener('insert_at',function(e){
console.log(e.overlay);
});
self.drost.addListener('remove_at',function(e){
console.log(e.overlay);
});
//此点击也正确运行
self.drost.addListener('click',function(e){
self.setSelection(self.drost);
})$




$ b $ p
$ p
事件 set_at insert_at remove_at 需要添加到多边形的路径中,而不是多边形本身。



相关问题:


I'm having a problem with the event listeners provided by google maps api. The thing is, that some events run, some not. I have a setListeners function which sets the listeners after the polygon overlay is complete. The events I would like to hook are: set_at, insert_at, remove_at and click. Now the click events run correctly, but the others not. What could I do wrong? Here is the code:

self.setListeners = function () {
        //this click event runs correctly
        google.maps.event.addListener(self.map, 'click', function (e) {
            self.clearSelection();
        })

        console.log(self.drost);
        if (typeof self.drost != 'undefined') {
            self.drost.addListener('set_at', function (e) {
                console.log(e.overlay);
            });
            self.drost.addListener('insert_at', function (e) {
                console.log(e.overlay);
            });
            self.drost.addListener('remove_at', function (e) {
                console.log(e.overlay);
            });
            //this click also runs correctly
            self.drost.addListener('click', function(e){
                self.setSelection(self.drost);
            })
        }
}

Thanks in advance!

解决方案

The events set_at, insert_at, remove_at need to be added to the path of the polygon, not the polygon itself.

related questions:

这篇关于JavaScript谷歌地图绘画事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆