shape_with_ng_repeat.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.allShapes = [
  21. {name: "polyline", path: [[40.74,-74.18],[40.64,-74.10],[40.54,-74.05],[40.44,-74]]},
  22. {name: "polygon", paths: [[40.74,-74.18],[40.64,-74.18],[40.84,-74.08],[40.74,-74.18]]},
  23. {name: "rectangle", bounds: [[40.74,-74.18], [40.78,-74.14]]},
  24. {name: "circle", center:[40.70,-74.14], radius:4000}
  25. ];
  26. console.log($scope);
  27. }
  28. </script>
  29. </head>
  30. <body>
  31. <div ng-controller="MyCtrl">
  32. <map zoom="11" center="[40.74, -74.18]">
  33. <shape ng-repeat="shape in allShapes"
  34. name="{{shape.name}}"
  35. stroke-color="#FF0000"
  36. stroke-opacity="0.8"
  37. path="{{shape.path}}"
  38. paths="{{shape.paths}}"
  39. bounds="{{shape.bounds}}"
  40. center="{{shape.center}}"
  41. radius="{{shape.radius}}"
  42. stroke-weight="2"></shape>
  43. </map>
  44. </div>
  45. </body>
  46. </html>