栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在ngMap中将ng-repeat与标记一起使用

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在ngMap中将ng-repeat与标记一起使用

答案在这里

http://plnkr.co/edit/Widr0o?p=预览

请记住,ngMap不会替代Google Maps V3 API。

如果您还有其他问题,请告诉我。

以下是控制器的代码块。

// $scope.map .. this exists after the map is initializedvar markers = [];for (var i=0; i<8 ; i++) {  markers[i] = new google.maps.Marker({    title: "Hi marker " + i  })}$scope.GenerateMapMarkers = function() {  $scope.date = Date(); // Just to show that we are updating  var numMarkers = Math.floor(Math.random() * 4) + 4;  // betwween 4 & 8 of them  for (i = 0; i < numMarkers; i++) {    var lat =   1.280095 + (Math.random()/100);    var lng = 103.850949 + (Math.random()/100);    // You need to set markers according to google api instruction    // you don't need to learn ngMap, but you need to learn google map api v3    // https://developers.google.com/maps/documentation/javascript/marker    var latlng = new google.maps.LatLng(lat, lng);    markers[i].setPosition(latlng);    markers[i].setMap($scope.map)  }  $timeout(function() {    $scope.GenerateMapMarkers();   }, 2000);  // update every 2 seconds};$scope.GenerateMapMarkers();


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/649615.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号