infowindow_compile.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!doctype html>
  2. <html ng-app="myapp">
  3. <head>
  4. <script src="https://code.angularjs.org/1.2.25/angular.js"></script>
  5. <script src="http://maps.google.com/maps/api/js"></script>
  6. <!-- build:js scripts/ng-map.min.js -->
  7. <script src="../app/scripts/app.js"></script>
  8. <script src="../app/scripts/directives/map_controller.js"></script>
  9. <script src="../app/scripts/directives/map.js"></script>
  10. <script src="../app/scripts/directives/marker.js"></script>
  11. <script src="../app/scripts/directives/shape.js"></script>
  12. <script src="../app/scripts/directives/info-window.js"></script>
  13. <script src="../app/scripts/directives/map-lazy-load.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 = app || angular.module('myapp', ['ngMap']);
  20. app.controller('MyCtrl', function($scope, $compile) {
  21. $scope.stores = {
  22. foo: { position:[41, -87], items: [1,2,3,4]},
  23. bar:{ position:[41, -83], items: [5,6,7,8]}
  24. };
  25. $scope.showStore = function(evt, id) {
  26. $scope.store = $scope.stores[id];
  27. $scope.showInfoWindow.apply(this, [evt, 'foo']);
  28. };
  29. });
  30. </script>
  31. </head>
  32. <body>
  33. <div ng-controller="MyCtrl">
  34. <map center="41,-87" zoom="3">
  35. <info-window id="foo">
  36. <div ng-non-bindable="">
  37. Lat/Lng: {{this.getPosition()}}<br/>
  38. <ul>
  39. <li ng-repeat='item in store.items'>{{item}}</li>
  40. </ul>
  41. </div>
  42. </info-window>
  43. <marker ng-repeat="(id, store) in stores" id="{{id}}"
  44. position="{{store.position}}"
  45. on-click="showStore(event, id)"
  46. ></marker>
  47. <info-window id="bar">
  48. <div ng-non-bindable="">
  49. Lat: {{this.getPosition().lat()}}<br/>
  50. Lng: {{this.getPosition().lng()}}<br/>
  51. </div>
  52. </info-window>
  53. <marker position="41, -79" on-click="showInfoWindow('bar')" />
  54. </map>
  55. </div>
  56. </body>
  57. </html>