簡體   English   中英

結合使用angular-google-maps指令 <markers> 異步加載不起作用

[英]Using angular-google-maps directive with <markers> loaded asynchronously not working

我正在使用angular-google-maps( http://angular-google-maps.org/ )在AngularJS應用程序中創建地圖。 <google-map>元素中,我有一個<markers>元素,並將models屬性設置為一個數組,該數組是$ http.get請求的結果。 但是由於某些原因,標記永遠不會加載。

為了知道數據的存在,我在映射旁邊設置了一個帶有ng-repeat的簡單列表,以在返回結果時輸出數組中每個元素的ID,並且確實填充了列表,所以我沒有確定為什么使用<markers>指令時不填充<markers> 是因為它們是從$ http.get中加載的,我需要做一些其他的事情嗎?

我現在正在做的就是從服務器獲取數據。 卡車是具有查找器功能的服務。

Trucks
  .findAll()
  .then(function(success) {
    $scope.trucks = success.data;
  }, function(error) {
    console.debug(error);
  });

我的HTML看起來像這樣。

編輯-我閱讀了一些文檔,發現我需要添加coords屬性='self',因為經度和緯度是模型本身的一部分,但是標記仍然沒有出現

<div class="row row-fluid">
    <div class="google-map col-xs-9" center="map.center" zoom="map.zoom">
        <markers models="trucks" do-rebuild-all="true" do-cluster="true" coords="'self'"></markers>
    </div>
    <div class="col-xs-3">
        <ul>
            <li ng-repeat="truck in trucks">{{truck.id}}</li>
        </ul>
    </div>
</div>

謝謝。

我知道這似乎很奇怪,它可能無法解決您的問題,但是do-cluster屬性實際上應該是doCluster。 由於這些指令的構建方式,您實際上為此做了Camel案例。 您可以舉一個您要獲取的數據示例嗎? 另外,我相信do-rebuild-all也將是doRebuildAll

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM