marker_with_ng_repeat.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <!DOCTYPE html>
  2. <html ng-app="ngMap">
  3. <head>
  4. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  5. <script src="https://maps.google.com/maps/api/js?sensor=false"></script>
  6. <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
  7. <script src="scripts/app.js"></script>
  8. <!-- build:js scripts/ng-map.min.js -->
  9. <script src="../app/scripts/app.js"></script>
  10. <script src="../app/scripts/directives/map_controller.js"></script>
  11. <script src="../app/scripts/directives/map.js"></script>
  12. <script src="../app/scripts/directives/marker.js"></script>
  13. <script src="../app/scripts/directives/shape.js"></script>
  14. <script src="../app/scripts/services/geo_coder.js"></script>
  15. <script src="../app/scripts/services/navigator_geolocation.js"></script>
  16. <script src="../app/scripts/services/attr2_options.js"></script>
  17. <!-- endbuild -->
  18. <script>
  19. function MyCtrl($scope) {
  20. $scope.positions =[ [40.71, -74.21], [40.72, -74.20], [40.73, -74.19],
  21. [40.74, -74.18], [40.75, -74.17], [40.76, -74.16], [40.77, -74.15]];
  22. $scope.positions2 =[ {pos:[40.71, -74.21]}, {pos:[40.72, -74.20]}, {pos: [40.73, -74.19]},
  23. {pos:[40.74, -74.18]}, {pos:[40.75, -74.17]}, {pos:[40.76, -74.16]}, {pos:[40.77, -74.15]}];
  24. }
  25. </script>
  26. </head>
  27. <body>
  28. <div ng-controller="MyCtrl">
  29. <map zoom="11" center="[40.74, -74.18]">
  30. <marker ng-repeat="p in positions" position="{{p}}" title="pos: {{p}}"></marker>
  31. </map>
  32. <map zoom="11" center="[40.74, -74.18]">
  33. <marker ng-repeat="p in positions2" position="{{p.pos}}" title="pos: {{p.pos}}"></marker>
  34. </map>
  35. </div>
  36. </body>
  37. </html>