source : map.js

  1. /**
  2. * @ngdoc directive
  3. * @memberof ngMap
  4. * @name ng-map
  5. * @param Attr2Options {service}
  6. * convert html attribute to Google map api options
  7. * @description
  8. * Implementation of {@link __MapController}
  9. * Initialize a Google map within a `<div>` tag
  10. * with given options and register events
  11. *
  12. * @attr {Expression} map-initialized
  13. * callback function when map is initialized
  14. * e.g., map-initialized="mycallback(map)"
  15. * @attr {Expression} geo-callback if center is an address or current location,
  16. * the expression is will be executed when geo-lookup is successful.
  17. * e.g., geo-callback="showMyStoreInfo()"
  18. * @attr {Array} geo-fallback-center
  19. * The center of map incase geolocation failed. i.e. [0,0]
  20. * @attr {Object} geo-location-options
  21. * The navigator geolocation options.
  22. * e.g., { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }.
  23. * If none specified, { timeout: 5000 }.
  24. * If timeout not specified, timeout: 5000 added
  25. * @attr {Boolean} zoom-to-include-markers
  26. * When true, map boundary will be changed automatially
  27. * to include all markers when initialized
  28. * @attr {Boolean} default-style
  29. * When false, the default styling,
  30. * `display:block;height:300px`, will be ignored.
  31. * @attr {String} <MapOption> Any Google map options,
  32. * https://developers.google.com/maps/documentation/javascript/reference?csw=1#MapOptions
  33. * @attr {String} <MapEvent> Any Google map events,
  34. * https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/map_events.html
  35. * @attr {Boolean} single-info-window
  36. * When true the map will only display one info window at the time,
  37. * if not set or false,
  38. * everytime an info window is open it will be displayed with the othe one.
  39. * @attr {Boolean} trigger-resize
  40. * Default to false. Set to true to trigger resize of the map. Needs to be done anytime you resize the map
  41. * @example
  42. * Usage:
  43. * <map MAP_OPTIONS_OR_MAP_EVENTS ..>
  44. * ... Any children directives
  45. * </map>
  46. *
  47. * Example:
  48. * <map center="[40.74, -74.18]" on-click="doThat()">
  49. * </map>
  50. *
  51. * <map geo-fallback-center="[40.74, -74.18]" zoom-to-inlude-markers="true">
  52. * </map>
  53. */
  54. (function () {
  55. 'use strict';
  56. var mapDirective = function () {
  57. return {
  58. restrict: 'AE',
  59. controller: '__MapController',
  60. controllerAs: 'ngmap'
  61. };
  62. };
  63. angular.module('ngMap').directive('map', [mapDirective]);
  64. angular.module('ngMap').directive('ngMap', [mapDirective]);
  65. })();