Javascript Google.maps.event.addListener for click and dragend不';不行?
我有这样的代码:“click dragend”事件的函数()中的代码没有执行,文档中的latFld和llgFld没有更新,我该怎么办 演示和完整代码:Javascript Google.maps.event.addListener for click and dragend不';不行?,javascript,jquery,google-maps,Javascript,Jquery,Google Maps,我有这样的代码:“click dragend”事件的函数()中的代码没有执行,文档中的latFld和llgFld没有更新,我该怎么办 演示和完整代码: 首先,在小提琴中的示例代码中,autocomplete未定义,因此导致错误。据我所知,一次不能绑定多个事件,因此必须显式绑定它们 //So instead of google.maps.event.addListener(map, 'click dragend', function (event) { ... // You would wan
首先,在小提琴中的示例代码中,
autocomplete
未定义,因此导致错误。据我所知,一次不能绑定多个事件,因此必须显式绑定它们
//So instead of
google.maps.event.addListener(map, 'click dragend', function (event) { ...
// You would want to do this
google.maps.event.addListener(map, 'click', function (event) { ...
// and
google.maps.event.addListener(marker, 'dragend', function (event) { ...
还请注意,您不能从地图的dragend
获取latLng,而是从标记获取latLng,因此在dragend
侦听器中,它被绑定到标记
看看更新的小提琴,看看我的意思
//So instead of
google.maps.event.addListener(map, 'click dragend', function (event) { ...
// You would want to do this
google.maps.event.addListener(map, 'click', function (event) { ...
// and
google.maps.event.addListener(marker, 'dragend', function (event) { ...