【问题标题】:Stop google map idle event listener停止谷歌地图空闲事件监听器
【发布时间】:2015-09-07 17:32:02
【问题描述】:

我正在使用 google 'idle' 事件侦听器在地图上上传标记(使用 angularjs)。我的代码是

$scope.LoadSearchPropertyOnPortFolioSales = function (PropertyName) {

 if(PropertyName == ''){
 google.maps.event.addListener(map, 'idle', function () {
            var PropertyList = PropertyService.GetSearchPropertyForPortfolio($scope.PortfolioId, $scope.PropertyName, this.center.lat(), this.center.lng(), 0.005, 0.005);
                     PropertyList.then(function (pl) {
                         DrawPropertyOnPortFolioSale(pl.data, $scope.PropertyName);
                     },
             });
 }

 else 
 {
     //Stop event listener
 }
}

我希望事件侦听器仅在传递的 PropertyName 没有值时工作。但是当 PropertyName 有一些价值时,我想停止事件监听器。我如何停止事件监听器......

【问题讨论】:

    标签: javascript angularjs google-maps


    【解决方案1】:

    还有一个函数可以同时移除所有的监听器:

    clearListeners(instance:Object, eventName:string);
    //In your case:
    google.maps.event.clearListeners(map, 'idle');
    

    Here's the Google Maps API reference 你可以在这里阅读。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2016-11-21
      • 1970-01-01
      相关资源
      最近更新 更多