marker_with_info_window.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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.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. var app = angular.module('myApp', ['ngMap']);
  20. app.controller('MyController', ['$scope', function($scope) {
  21. var map, marker;
  22. var infoWindow = new google.maps.InfoWindow({
  23. content:'Hi<br/>I am an infowindow'
  24. });
  25. $scope.$on('mapInitialized', function(event, evtMap) {
  26. map = evtMap, marker = map.markers[0];
  27. });
  28. $scope.showInfoWindow = function() {
  29. infoWindow.open(map, marker);
  30. }
  31. }]);
  32. </script>
  33. </head>
  34. <body>
  35. <div ng-controller="MyController" style="height:100%">
  36. <map zoom="11" center="[40.74, -74.18]">
  37. <marker position="[40.71, -74.21]" on-click="showInfoWindow()"></marker>
  38. </map>
  39. </div>
  40. </body>
  41. </html>