rectangle-event.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!DOCTYPE html>
  2. <html ng-app="myApp">
  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.25/angular.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/directives/info-window.js"></script>
  15. <script src="../app/scripts/services/geo_coder.js"></script>
  16. <script src="../app/scripts/services/navigator_geolocation.js"></script>
  17. <script src="../app/scripts/services/attr2_options.js"></script>
  18. <!-- endbuild -->
  19. <script>
  20. var app = angular.module('myApp', ['ngMap']);
  21. app.controller("RectangleEventCtrl", function($scope, $compile) {
  22. $scope.ne, $scope.sw;
  23. $scope.boundsChanged = function(event) {
  24. $scope.ne = this.getBounds().getNorthEast();
  25. $scope.sw = this.getBounds().getSouthWest();
  26. console.log('$scope', $scope);
  27. $scope.showInfoWindow(event, 'foo', $scope.ne);
  28. };
  29. });
  30. </script>
  31. </head>
  32. <body>
  33. Rectangle Event<br/>
  34. This example adds a user-editable rectangle to the map.
  35. When the user changes the bounds of the rectangle,
  36. an info window pops up displaying the new bounds.
  37. <div ng-controller="RectangleEventCtrl">
  38. <map zoom="9" center="44.5452, -78.5389">
  39. <shape name="rectangle"
  40. editable="true"
  41. draggable="true"
  42. bounds="[[44.490,-78.649],[44.599,-78.443]]"
  43. on-bounds_changed="boundsChanged()">
  44. </shape>
  45. <info-window id="foo">
  46. <div ng-non-bindable>
  47. <b>Rectangle moved.</b><br/>
  48. New north-east corner: {{ne.lat()}}, {{ne.lng()}}<br/>
  49. New south-west corner: {{sw.lat()}}, {{sw.lng()}}
  50. </div>
  51. </info-window>
  52. </map>
  53. <b>Rectangle moved.</b><br/>
  54. New north-east corner: {{ne.lat()}}, {{ne.lng()}}<br/>
  55. New south-west corner: {{sw.lat()}}, {{sw.lng()}}
  56. </div>
  57. </body>
  58. </html>