2013-10-16 79 views
3

我使用angular-google-maps directive,我遇到了一個問題,當我嘗試刪除綁定到控制器的標記。我已經嘗試過各種版本的Angular,並且嘗試過使用angular-google-maps的master和r1-dev分支。過濾谷歌地圖標記與angularjs

我不知道爲什麼,但它似乎陷入了$摘要函數,並且當我篩選出列表項時,這種情況不會發生。拋出的異常是這樣的:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! 

在這裏可以看到一個演示,我的代碼從JavaScript的第550行開始。上面的代碼是angular-google-maps指令。

http://jsfiddle.net/ADukg/4127/

+0

您是否設法弄清楚爲什麼會發生這種情況? –

回答

6

這裏是我工作,這是從角谷歌,地圖模塊問題隊列閱讀其他一些相關的錯誤。

jist是您需要在手錶內創建一個變量並使用它傳遞給模型參數。

基本JS:

controller('MainCtrl', function ($scope, $filter) { 

    $scope.$watch("breweryFilter", function(breweryFilter){ 
     $scope.filteredMarkers = $filter("filter")($scope.breweries, breweryFilter); 
     if (!$scope.filteredMarkers){ 
     return; 
     } 
    }); 
}); 

濾波器輸入:

<input name="brewery-filter" class="form-control" type="search" ng-model="breweryFilter" placeholder="filter locations" /> 

地圖指示標記包含指令:

<google-map 
     center="map.center" 
     zoom="map.zoom" 
     draggable="true" 
     control="map.control"> 

     <window 
      show="breweryInfoWindow.showWindow" 
      coords="breweryInfoWindow.coords" 
      isIconVisibleOnClick="true" 
      options="breweryInfoWindow.options" 
      templateUrl="breweryInfoWindow.templateUrl" 
      templateParameter="breweryInfoWindow.templateParams" 
      data-ng-cloak> 
     _ 
     </window> 

     <markers 
      models="filteredMarkers" 
      idKey="'nid'" 
      coords="'self'" 
      icon="'icon'" 
      doRebuildAll="true" 
      fit='true' 
      doCluster='true' 
      control="map.markersControl" 
      click="'onMarkerClicked'"> 
     </markers> 

    </google-map> 

希望這是對你有幫助。

+0

你在哪裏添加標記指令? '

'? – Squirrl

+1

已更新答案以在地圖指令的上下文中顯示標記指令 –