map_controller.js.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: directives/map_controller.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: directives/map_controller.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>/**
  20. * @ngdoc directive
  21. * @name MapController
  22. * @requires $scope
  23. * @property {Hash} controls collection of Controls initiated within `map` directive
  24. * @property {Hash} markersi collection of Markers initiated within `map` directive
  25. * @property {Hash} shapes collection of shapes initiated within `map` directive
  26. * @property {MarkerClusterer} markerClusterer MarkerClusterer initiated within `map` directive
  27. */
  28. /*jshint -W089*/
  29. ngMap.MapController = function() {
  30. this.map = null;
  31. this._objects = [];
  32. /**
  33. * Add a marker to map and $scope.markers
  34. * @memberof MapController
  35. * @name addMarker
  36. * @param {Marker} marker google map marker
  37. */
  38. this.addMarker = function(marker) {
  39. /**
  40. * marker and shape are initialized before map is initialized
  41. * so, collect _objects then will init. those when map is initialized
  42. * However the case as in ng-repeat, we can directly add to map
  43. */
  44. if (this.map) {
  45. this.map.markers = this.map.markers || {};
  46. marker.setMap(this.map);
  47. if (marker.centered) {
  48. this.map.setCenter(marker.position);
  49. }
  50. var len = Object.keys(this.map.markers).length;
  51. this.map.markers[marker.id || len] = marker;
  52. } else {
  53. this._objects.push(marker);
  54. }
  55. };
  56. /**
  57. * Add a shape to map and $scope.shapes
  58. * @memberof MapController
  59. * @name addShape
  60. * @param {Shape} shape google map shape
  61. */
  62. this.addShape = function(shape) {
  63. if (this.map) {
  64. this.map.shapes = this.map.shapes || {};
  65. shape.setMap(this.map);
  66. var len = Object.keys(this.map.shapes).length;
  67. this.map.shapes[shape.id || len] = shape;
  68. } else {
  69. this._objects.push(shape);
  70. }
  71. };
  72. this.addObject = function(groupName, obj) {
  73. if (this.map) {
  74. this.map[groupName] = this.map[groupName] || {};
  75. var len = Object.keys(this.map[groupName]).length;
  76. this.map[groupName][obj.id || len] = obj;
  77. if (groupName != "infoWindows" &amp;&amp; obj.setMap) { //infoWindow.setMap works like infoWindow.open
  78. obj.setMap(this.map);
  79. }
  80. } else {
  81. obj.groupName = groupName;
  82. this._objects.push(obj);
  83. }
  84. }
  85. /**
  86. * Add a shape to map and $scope.shapes
  87. * @memberof MapController
  88. * @name addShape
  89. * @param {Shape} shape google map shape
  90. */
  91. this.addObjects = function(objects) {
  92. for (var i=0; i&lt;objects.length; i++) {
  93. var obj=objects[i];
  94. if (obj instanceof google.maps.Marker) {
  95. this.addMarker(obj);
  96. } else if (obj instanceof google.maps.Circle ||
  97. obj instanceof google.maps.Polygon ||
  98. obj instanceof google.maps.Polyline ||
  99. obj instanceof google.maps.Rectangle ||
  100. obj instanceof google.maps.GroundOverlay) {
  101. this.addShape(obj);
  102. } else {
  103. this.addObject(obj.groupName, obj);
  104. }
  105. }
  106. };
  107. };
  108. </code></pre>
  109. </article>
  110. </section>
  111. </div>
  112. <nav>
  113. <h2><a href="index.html">Index</a></h2><h3>service</h3><ul><li><a href="Attr2Options.html">Attr2Options</a></li><li><a href="GeoCoder.html">GeoCoder</a></li><li><a href="NavigatorGeolocation.html">NavigatorGeolocation</a></li><li><a href="StreetView.html">StreetView</a></li></ul><h3>directive</h3><ul><li><a href="bicycling-layer.html">bicycling-layer</a></li><li><a href="cloud-layer.html">cloud-layer</a></li><li><a href="custom-control.html">custom-control</a></li><li><a href="drawing-manager.html">drawing-manager</a></li><li><a href="dynamic-maps-engine-layer.html">dynamic-maps-engine-layer</a></li><li><a href="fusion-tables-layer.html">fusion-tables-layer</a></li><li><a href="heatmap-layer.html">heatmap-layer</a></li><li><a href="info-window.html">info-window</a></li><li><a href="kml-layer.html">kml-layer</a></li><li><a href="lazy-load.html">lazy-load</a></li><li><a href="map.html">map</a></li><li><a href="map-data.html">map-data</a></li><li><a href="map-type.html">map-type</a></li><li><a href="MapController.html">MapController</a></li><li><a href="maps-engine-layer.html">maps-engine-layer</a></li><li><a href="marker.html">marker</a></li><li><a href="overlay-map-type.html">overlay-map-type</a></li><li><a href="shape.html">shape</a></li><li><a href="traffic-layer.html">traffic-layer</a></li><li><a href="transit-layer.html">transit-layer</a></li><li><a href="weather-layer.html">weather-layer</a></li></ul>
  114. </nav>
  115. <br clear="both">
  116. <footer>
  117. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
  118. and <a href="https://github.com/allenhwkim/angular-jsdoc">angular-jsdoc</a>
  119. </footer>
  120. <script> prettyPrint(); </script>
  121. <script src="scripts/linenumber.js"> </script>
  122. <script>
  123. var href=window.location.href.match(/\/([^\/]+$)/)[1];
  124. document.querySelector("nav a[href='"+href+"']").scrollIntoView(true);
  125. if (window.location.hash == "")
  126. document.querySelector("body").scrollIntoView(true);
  127. </script>
  128. </body>
  129. </html>