PageRenderTime 105ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 1ms

/dist/angular-google-maps.js

https://github.com/Avallach160/angular-google-maps
JavaScript | 8179 lines | 5587 code | 912 blank | 1680 comment | 1246 complexity | 5b46c9cd9301c7325406bca0244ddf29 MD5 | raw file
  1. /*! angular-google-maps 1.1.3 2014-06-18
  2. * AngularJS directives for Google Maps
  3. * git: https://github.com/nlaplante/angular-google-maps.git
  4. */
  5. /*
  6. !
  7. The MIT License
  8. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to deal
  11. in the Software without restriction, including without limitation the rights
  12. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. copies of the Software, and to permit persons to whom the Software is
  14. furnished to do so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. THE SOFTWARE.
  24. angular-google-maps
  25. https://github.com/nlaplante/angular-google-maps
  26. @authors
  27. Nicolas Laplante - https://plus.google.com/108189012221374960701
  28. Nicholas McCready - https://twitter.com/nmccready
  29. */
  30. (function() {
  31. angular.module("google-maps.directives.api.utils", []);
  32. angular.module("google-maps.directives.api.managers", []);
  33. angular.module("google-maps.directives.api.models.child", ["google-maps.directives.api.utils"]);
  34. angular.module("google-maps.directives.api.models.parent", ["google-maps.directives.api.managers", "google-maps.directives.api.models.child"]);
  35. angular.module("google-maps.directives.api", ["google-maps.directives.api.models.parent"]);
  36. angular.module("google-maps", ["google-maps.directives.api"]).factory("debounce", [
  37. "$timeout", function($timeout) {
  38. return function(fn) {
  39. var nthCall;
  40. nthCall = 0;
  41. return function() {
  42. var argz, later, that;
  43. that = this;
  44. argz = arguments;
  45. nthCall++;
  46. later = (function(version) {
  47. return function() {
  48. if (version === nthCall) {
  49. return fn.apply(that, argz);
  50. }
  51. };
  52. })(nthCall);
  53. return $timeout(later, 0, true);
  54. };
  55. };
  56. }
  57. ]);
  58. }).call(this);
  59. (function() {
  60. angular.element(document).ready(function() {
  61. if (!(google || (typeof google !== "undefined" && google !== null ? google.maps : void 0) || (google.maps.InfoWindow != null))) {
  62. return;
  63. }
  64. google.maps.InfoWindow.prototype._open = google.maps.InfoWindow.prototype.open;
  65. google.maps.InfoWindow.prototype._close = google.maps.InfoWindow.prototype.close;
  66. google.maps.InfoWindow.prototype._isOpen = false;
  67. google.maps.InfoWindow.prototype.open = function(map, anchor) {
  68. this._isOpen = true;
  69. this._open(map, anchor);
  70. };
  71. google.maps.InfoWindow.prototype.close = function() {
  72. this._isOpen = false;
  73. this._close();
  74. };
  75. google.maps.InfoWindow.prototype.isOpen = function(val) {
  76. if (val == null) {
  77. val = void 0;
  78. }
  79. if (val == null) {
  80. return this._isOpen;
  81. } else {
  82. return this._isOpen = val;
  83. }
  84. };
  85. /*
  86. Do the same for InfoBox
  87. TODO: Clean this up so the logic is defined once, wait until develop becomes master as this will be easier
  88. */
  89. if (!window.InfoBox) {
  90. return;
  91. }
  92. window.InfoBox.prototype._open = window.InfoBox.prototype.open;
  93. window.InfoBox.prototype._close = window.InfoBox.prototype.close;
  94. window.InfoBox.prototype._isOpen = false;
  95. window.InfoBox.prototype.open = function(map, anchor) {
  96. this._isOpen = true;
  97. this._open(map, anchor);
  98. };
  99. window.InfoBox.prototype.close = function() {
  100. this._isOpen = false;
  101. this._close();
  102. };
  103. return window.InfoBox.prototype.isOpen = function(val) {
  104. if (val == null) {
  105. val = void 0;
  106. }
  107. if (val == null) {
  108. return this._isOpen;
  109. } else {
  110. return this._isOpen = val;
  111. }
  112. };
  113. });
  114. }).call(this);
  115. /*
  116. Author Nick McCready
  117. Intersection of Objects if the arrays have something in common each intersecting object will be returned
  118. in an new array.
  119. */
  120. (function() {
  121. _.intersectionObjects = function(array1, array2, comparison) {
  122. var res,
  123. _this = this;
  124. if (comparison == null) {
  125. comparison = void 0;
  126. }
  127. res = _.map(array1, function(obj1) {
  128. return _.find(array2, function(obj2) {
  129. if (comparison != null) {
  130. return comparison(obj1, obj2);
  131. } else {
  132. return _.isEqual(obj1, obj2);
  133. }
  134. });
  135. });
  136. return _.filter(res, function(o) {
  137. return o != null;
  138. });
  139. };
  140. _.containsObject = _.includeObject = function(obj, target, comparison) {
  141. var _this = this;
  142. if (comparison == null) {
  143. comparison = void 0;
  144. }
  145. if (obj === null) {
  146. return false;
  147. }
  148. return _.any(obj, function(value) {
  149. if (comparison != null) {
  150. return comparison(value, target);
  151. } else {
  152. return _.isEqual(value, target);
  153. }
  154. });
  155. };
  156. _.differenceObjects = function(array1, array2, comparison) {
  157. if (comparison == null) {
  158. comparison = void 0;
  159. }
  160. return _.filter(array1, function(value) {
  161. return !_.containsObject(array2, value);
  162. });
  163. };
  164. _.withoutObjects = function(array, array2) {
  165. return _.differenceObjects(array, array2);
  166. };
  167. _.indexOfObject = function(array, item, comparison, isSorted) {
  168. var i, length;
  169. if (array == null) {
  170. return -1;
  171. }
  172. i = 0;
  173. length = array.length;
  174. if (isSorted) {
  175. if (typeof isSorted === "number") {
  176. i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted);
  177. } else {
  178. i = _.sortedIndex(array, item);
  179. return (array[i] === item ? i : -1);
  180. }
  181. }
  182. while (i < length) {
  183. if (comparison != null) {
  184. if (comparison(array[i], item)) {
  185. return i;
  186. }
  187. } else {
  188. if (_.isEqual(array[i], item)) {
  189. return i;
  190. }
  191. }
  192. i++;
  193. }
  194. return -1;
  195. };
  196. _["extends"] = function(arrayOfObjectsToCombine) {
  197. return _.reduce(arrayOfObjectsToCombine, function(combined, toAdd) {
  198. return _.extend(combined, toAdd);
  199. }, {});
  200. };
  201. }).call(this);
  202. /*
  203. Author: Nicholas McCready & jfriend00
  204. _async handles things asynchronous-like :), to allow the UI to be free'd to do other things
  205. Code taken from http://stackoverflow.com/questions/10344498/best-way-to-iterate-over-an-array-without-blocking-the-ui
  206. The design of any funcitonality of _async is to be like lodash/underscore and replicate it but call things
  207. asynchronously underneath. Each should be sufficient for most things to be derrived from.
  208. TODO: Handle Object iteration like underscore and lodash as well.. not that important right now
  209. */
  210. (function() {
  211. var async;
  212. async = {
  213. each: function(array, callback, doneCallBack, pausedCallBack, chunk, index, pause) {
  214. var doChunk;
  215. if (chunk == null) {
  216. chunk = 20;
  217. }
  218. if (index == null) {
  219. index = 0;
  220. }
  221. if (pause == null) {
  222. pause = 1;
  223. }
  224. if (!pause) {
  225. throw "pause (delay) must be set from _async!";
  226. return;
  227. }
  228. if (array === void 0 || (array != null ? array.length : void 0) <= 0) {
  229. doneCallBack();
  230. return;
  231. }
  232. doChunk = function() {
  233. var cnt, i;
  234. cnt = chunk;
  235. i = index;
  236. while (cnt-- && i < (array ? array.length : i + 1)) {
  237. callback(array[i], i);
  238. ++i;
  239. }
  240. if (array) {
  241. if (i < array.length) {
  242. index = i;
  243. if (pausedCallBack != null) {
  244. pausedCallBack();
  245. }
  246. return setTimeout(doChunk, pause);
  247. } else {
  248. if (doneCallBack) {
  249. return doneCallBack();
  250. }
  251. }
  252. }
  253. };
  254. return doChunk();
  255. },
  256. map: function(objs, iterator, doneCallBack, pausedCallBack, chunk) {
  257. var results;
  258. results = [];
  259. if (objs == null) {
  260. return results;
  261. }
  262. return _async.each(objs, function(o) {
  263. return results.push(iterator(o));
  264. }, function() {
  265. return doneCallBack(results);
  266. }, pausedCallBack, chunk);
  267. }
  268. };
  269. window._async = async;
  270. angular.module("google-maps.directives.api.utils").factory("async", function() {
  271. return window._async;
  272. });
  273. }).call(this);
  274. (function() {
  275. var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  276. angular.module("google-maps.directives.api.utils").factory("BaseObject", function() {
  277. var BaseObject, baseObjectKeywords;
  278. baseObjectKeywords = ['extended', 'included'];
  279. BaseObject = (function() {
  280. function BaseObject() {}
  281. BaseObject.extend = function(obj) {
  282. var key, value, _ref;
  283. for (key in obj) {
  284. value = obj[key];
  285. if (__indexOf.call(baseObjectKeywords, key) < 0) {
  286. this[key] = value;
  287. }
  288. }
  289. if ((_ref = obj.extended) != null) {
  290. _ref.apply(this);
  291. }
  292. return this;
  293. };
  294. BaseObject.include = function(obj) {
  295. var key, value, _ref;
  296. for (key in obj) {
  297. value = obj[key];
  298. if (__indexOf.call(baseObjectKeywords, key) < 0) {
  299. this.prototype[key] = value;
  300. }
  301. }
  302. if ((_ref = obj.included) != null) {
  303. _ref.apply(this);
  304. }
  305. return this;
  306. };
  307. return BaseObject;
  308. })();
  309. return BaseObject;
  310. });
  311. }).call(this);
  312. /*
  313. Useful function callbacks that should be defined at later time.
  314. Mainly to be used for specs to verify creation / linking.
  315. This is to lead a common design in notifying child stuff.
  316. */
  317. (function() {
  318. angular.module("google-maps.directives.api.utils").factory("ChildEvents", function() {
  319. return {
  320. onChildCreation: function(child) {}
  321. };
  322. });
  323. }).call(this);
  324. (function() {
  325. angular.module("google-maps.directives.api.utils").service("EventsHelper", [
  326. "Logger", function($log) {
  327. return {
  328. setEvents: function(marker, scope, model) {
  329. if (angular.isDefined(scope.events) && (scope.events != null) && angular.isObject(scope.events)) {
  330. return _.compact(_.map(scope.events, function(eventHandler, eventName) {
  331. if (scope.events.hasOwnProperty(eventName) && angular.isFunction(scope.events[eventName])) {
  332. return google.maps.event.addListener(marker, eventName, function() {
  333. return eventHandler.apply(scope, [marker, eventName, model, arguments]);
  334. });
  335. } else {
  336. return $log.info("MarkerEventHelper: invalid event listener " + eventName);
  337. }
  338. }));
  339. }
  340. }
  341. };
  342. }
  343. ]);
  344. }).call(this);
  345. (function() {
  346. var __hasProp = {}.hasOwnProperty,
  347. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  348. angular.module("google-maps.directives.api.utils").factory("FitHelper", [
  349. "BaseObject", "Logger", function(BaseObject, $log) {
  350. var FitHelper, _ref;
  351. return FitHelper = (function(_super) {
  352. __extends(FitHelper, _super);
  353. function FitHelper() {
  354. _ref = FitHelper.__super__.constructor.apply(this, arguments);
  355. return _ref;
  356. }
  357. FitHelper.prototype.fit = function(gMarkers, gMap) {
  358. var bounds, everSet,
  359. _this = this;
  360. if (gMap && gMarkers && gMarkers.length > 0) {
  361. bounds = new google.maps.LatLngBounds();
  362. everSet = false;
  363. return _async.each(gMarkers, function(gMarker) {
  364. if (gMarker) {
  365. if (!everSet) {
  366. everSet = true;
  367. }
  368. return bounds.extend(gMarker.getPosition());
  369. }
  370. }, function() {
  371. if (everSet) {
  372. return gMap.fitBounds(bounds);
  373. }
  374. });
  375. }
  376. };
  377. return FitHelper;
  378. })(BaseObject);
  379. }
  380. ]);
  381. }).call(this);
  382. (function() {
  383. angular.module("google-maps.directives.api.utils").service("GmapUtil", [
  384. "Logger", "$compile", function(Logger, $compile) {
  385. var getCoords, validateCoords;
  386. getCoords = function(value) {
  387. if (Array.isArray(value) && value.length === 2) {
  388. return new google.maps.LatLng(value[1], value[0]);
  389. } else if (angular.isDefined(value.type) && value.type === "Point") {
  390. return new google.maps.LatLng(value.coordinates[1], value.coordinates[0]);
  391. } else {
  392. return new google.maps.LatLng(value.latitude, value.longitude);
  393. }
  394. };
  395. validateCoords = function(coords) {
  396. if (angular.isUndefined(coords)) {
  397. return false;
  398. }
  399. if (_.isArray(coords)) {
  400. if (coords.length === 2) {
  401. return true;
  402. }
  403. } else if ((coords != null) && (coords != null ? coords.type : void 0)) {
  404. if (coords.type === "Point" && _.isArray(coords.coordinates) && coords.coordinates.length === 2) {
  405. return true;
  406. }
  407. }
  408. if (coords && angular.isDefined((coords != null ? coords.latitude : void 0) && angular.isDefined(coords != null ? coords.longitude : void 0))) {
  409. return true;
  410. }
  411. return false;
  412. };
  413. return {
  414. getLabelPositionPoint: function(anchor) {
  415. var xPos, yPos;
  416. if (anchor === void 0) {
  417. return void 0;
  418. }
  419. anchor = /^([-\d\.]+)\s([-\d\.]+)$/.exec(anchor);
  420. xPos = parseFloat(anchor[1]);
  421. yPos = parseFloat(anchor[2]);
  422. if ((xPos != null) && (yPos != null)) {
  423. return new google.maps.Point(xPos, yPos);
  424. }
  425. },
  426. createMarkerOptions: function(coords, icon, defaults, map) {
  427. var opts;
  428. if (map == null) {
  429. map = void 0;
  430. }
  431. if (defaults == null) {
  432. defaults = {};
  433. }
  434. opts = angular.extend({}, defaults, {
  435. position: defaults.position != null ? defaults.position : getCoords(coords),
  436. icon: defaults.icon != null ? defaults.icon : icon,
  437. visible: defaults.visible != null ? defaults.visible : validateCoords(coords)
  438. });
  439. if (map != null) {
  440. opts.map = map;
  441. }
  442. return opts;
  443. },
  444. createWindowOptions: function(gMarker, scope, content, defaults) {
  445. if ((content != null) && (defaults != null) && ($compile != null)) {
  446. return angular.extend({}, defaults, {
  447. content: this.buildContent(scope, defaults, content),
  448. position: defaults.position != null ? defaults.position : angular.isObject(gMarker) ? gMarker.getPosition() : getCoords(scope.coords)
  449. });
  450. } else {
  451. if (!defaults) {
  452. Logger.error("infoWindow defaults not defined");
  453. if (!content) {
  454. return Logger.error("infoWindow content not defined");
  455. }
  456. } else {
  457. return defaults;
  458. }
  459. }
  460. },
  461. buildContent: function(scope, defaults, content) {
  462. var parsed, ret;
  463. if (defaults.content != null) {
  464. ret = defaults.content;
  465. } else {
  466. if ($compile != null) {
  467. parsed = $compile(content)(scope);
  468. if (parsed.length > 0) {
  469. ret = parsed[0];
  470. }
  471. } else {
  472. ret = content;
  473. }
  474. }
  475. return ret;
  476. },
  477. defaultDelay: 50,
  478. isTrue: function(val) {
  479. return angular.isDefined(val) && val !== null && val === true || val === "1" || val === "y" || val === "true";
  480. },
  481. isFalse: function(value) {
  482. return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) !== -1;
  483. },
  484. getCoords: getCoords,
  485. validateCoords: validateCoords,
  486. validatePath: function(path) {
  487. var array, i, polygon, trackMaxVertices;
  488. i = 0;
  489. if (angular.isUndefined(path.type)) {
  490. if (!Array.isArray(path) || path.length < 2) {
  491. return false;
  492. }
  493. while (i < path.length) {
  494. if (!((angular.isDefined(path[i].latitude) && angular.isDefined(path[i].longitude)) || (typeof path[i].lat === "function" && typeof path[i].lng === "function"))) {
  495. return false;
  496. }
  497. i++;
  498. }
  499. return true;
  500. } else {
  501. if (angular.isUndefined(path.coordinates)) {
  502. return false;
  503. }
  504. if (path.type === "Polygon") {
  505. if (path.coordinates[0].length < 4) {
  506. return false;
  507. }
  508. array = path.coordinates[0];
  509. } else if (path.type === "MultiPolygon") {
  510. trackMaxVertices = {
  511. max: 0,
  512. index: 0
  513. };
  514. _.forEach(path.coordinates, function(polygon, index) {
  515. if (polygon[0].length > this.max) {
  516. this.max = polygon[0].length;
  517. return this.index = index;
  518. }
  519. }, trackMaxVertices);
  520. polygon = path.coordinates[trackMaxVertices.index];
  521. array = polygon[0];
  522. if (array.length < 4) {
  523. return false;
  524. }
  525. } else if (path.type === "LineString") {
  526. if (path.coordinates.length < 2) {
  527. return false;
  528. }
  529. array = path.coordinates;
  530. } else {
  531. return false;
  532. }
  533. while (i < array.length) {
  534. if (array[i].length !== 2) {
  535. return false;
  536. }
  537. i++;
  538. }
  539. return true;
  540. }
  541. },
  542. convertPathPoints: function(path) {
  543. var array, i, latlng, result, trackMaxVertices;
  544. i = 0;
  545. result = new google.maps.MVCArray();
  546. if (angular.isUndefined(path.type)) {
  547. while (i < path.length) {
  548. latlng;
  549. if (angular.isDefined(path[i].latitude) && angular.isDefined(path[i].longitude)) {
  550. latlng = new google.maps.LatLng(path[i].latitude, path[i].longitude);
  551. } else if (typeof path[i].lat === "function" && typeof path[i].lng === "function") {
  552. latlng = path[i];
  553. }
  554. result.push(latlng);
  555. i++;
  556. }
  557. } else {
  558. array;
  559. if (path.type === "Polygon") {
  560. array = path.coordinates[0];
  561. } else if (path.type === "MultiPolygon") {
  562. trackMaxVertices = {
  563. max: 0,
  564. index: 0
  565. };
  566. _.forEach(path.coordinates, function(polygon, index) {
  567. if (polygon[0].length > this.max) {
  568. this.max = polygon[0].length;
  569. return this.index = index;
  570. }
  571. }, trackMaxVertices);
  572. array = path.coordinates[trackMaxVertices.index][0];
  573. } else if (path.type === "LineString") {
  574. array = path.coordinates;
  575. }
  576. while (i < array.length) {
  577. result.push(new google.maps.LatLng(array[i][1], array[i][0]));
  578. i++;
  579. }
  580. }
  581. return result;
  582. },
  583. extendMapBounds: function(map, points) {
  584. var bounds, i;
  585. bounds = new google.maps.LatLngBounds();
  586. i = 0;
  587. while (i < points.length) {
  588. bounds.extend(points.getAt(i));
  589. i++;
  590. }
  591. return map.fitBounds(bounds);
  592. }
  593. };
  594. }
  595. ]);
  596. }).call(this);
  597. (function() {
  598. var __hasProp = {}.hasOwnProperty,
  599. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  600. angular.module("google-maps.directives.api.utils").factory("Linked", [
  601. "BaseObject", function(BaseObject) {
  602. var Linked;
  603. Linked = (function(_super) {
  604. __extends(Linked, _super);
  605. function Linked(scope, element, attrs, ctrls) {
  606. this.scope = scope;
  607. this.element = element;
  608. this.attrs = attrs;
  609. this.ctrls = ctrls;
  610. }
  611. return Linked;
  612. })(BaseObject);
  613. return Linked;
  614. }
  615. ]);
  616. }).call(this);
  617. (function() {
  618. angular.module("google-maps.directives.api.utils").service("Logger", [
  619. "$log", function($log) {
  620. return {
  621. logger: $log,
  622. doLog: false,
  623. info: function(msg) {
  624. if (this.doLog) {
  625. if (this.logger != null) {
  626. return this.logger.info(msg);
  627. } else {
  628. return console.info(msg);
  629. }
  630. }
  631. },
  632. error: function(msg) {
  633. if (this.doLog) {
  634. if (this.logger != null) {
  635. return this.logger.error(msg);
  636. } else {
  637. return console.error(msg);
  638. }
  639. }
  640. },
  641. warn: function(msg) {
  642. if (this.doLog) {
  643. if (this.logger != null) {
  644. return this.logger.warn(msg);
  645. } else {
  646. return console.warn(msg);
  647. }
  648. }
  649. }
  650. };
  651. }
  652. ]);
  653. }).call(this);
  654. (function() {
  655. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  656. __hasProp = {}.hasOwnProperty,
  657. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  658. angular.module("google-maps.directives.api.utils").factory("ModelKey", [
  659. "BaseObject", function(BaseObject) {
  660. var ModelKey;
  661. return ModelKey = (function(_super) {
  662. __extends(ModelKey, _super);
  663. function ModelKey(scope) {
  664. this.scope = scope;
  665. this.setIdKey = __bind(this.setIdKey, this);
  666. this.modelKeyComparison = __bind(this.modelKeyComparison, this);
  667. ModelKey.__super__.constructor.call(this);
  668. this.defaultIdKey = "id";
  669. this.idKey = void 0;
  670. }
  671. ModelKey.prototype.evalModelHandle = function(model, modelKey) {
  672. if (model === void 0) {
  673. return void 0;
  674. }
  675. if (modelKey === 'self') {
  676. return model;
  677. } else {
  678. return model[modelKey];
  679. }
  680. };
  681. ModelKey.prototype.modelKeyComparison = function(model1, model2) {
  682. var scope;
  683. scope = this.scope.coords != null ? this.scope : this.parentScope;
  684. if (scope == null) {
  685. throw "No scope or parentScope set!";
  686. }
  687. return this.evalModelHandle(model1, scope.coords).latitude === this.evalModelHandle(model2, scope.coords).latitude && this.evalModelHandle(model1, scope.coords).longitude === this.evalModelHandle(model2, scope.coords).longitude;
  688. };
  689. ModelKey.prototype.setIdKey = function(scope) {
  690. return this.idKey = scope.idKey != null ? scope.idKey : this.defaultIdKey;
  691. };
  692. return ModelKey;
  693. })(BaseObject);
  694. }
  695. ]);
  696. }).call(this);
  697. (function() {
  698. angular.module("google-maps.directives.api.utils").factory("ModelsWatcher", [
  699. "Logger", function(Logger) {
  700. return {
  701. figureOutState: function(idKey, scope, childObjects, comparison, callBack) {
  702. var adds, mappedScopeModelIds, removals,
  703. _this = this;
  704. adds = [];
  705. mappedScopeModelIds = {};
  706. removals = [];
  707. return _async.each(scope.models, function(m) {
  708. var child;
  709. if (m[idKey] != null) {
  710. mappedScopeModelIds[m[idKey]] = {};
  711. if (childObjects[m[idKey]] == null) {
  712. return adds.push(m);
  713. } else {
  714. child = childObjects[m[idKey]];
  715. if (!comparison(m, child.model)) {
  716. adds.push(m);
  717. return removals.push(child.model);
  718. }
  719. }
  720. } else {
  721. return Logger.error("id missing for model " + (m.toString()) + ", can not use do comparison/insertion");
  722. }
  723. }, function() {
  724. return _async.each(childObjects.values(), function(c) {
  725. var id;
  726. if (c == null) {
  727. Logger.error("child undefined in ModelsWatcher.");
  728. return;
  729. }
  730. if (c.model == null) {
  731. Logger.error("child.model undefined in ModelsWatcher.");
  732. return;
  733. }
  734. id = c.model[idKey];
  735. if (mappedScopeModelIds[id] == null) {
  736. return removals.push(c.model[idKey]);
  737. }
  738. }, function() {
  739. return callBack({
  740. adds: adds,
  741. removals: removals
  742. });
  743. });
  744. });
  745. }
  746. };
  747. }
  748. ]);
  749. }).call(this);
  750. /*
  751. Simple Object Map with a lenght property to make it easy to track length/size
  752. */
  753. (function() {
  754. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  755. angular.module("google-maps.directives.api.utils").factory("PropMap", function() {
  756. var PropMap, propsToPop;
  757. propsToPop = ['get', 'put', 'remove', 'values', 'keys', 'length'];
  758. PropMap = (function() {
  759. function PropMap() {
  760. this.keys = __bind(this.keys, this);
  761. this.values = __bind(this.values, this);
  762. this.remove = __bind(this.remove, this);
  763. this.put = __bind(this.put, this);
  764. this.get = __bind(this.get, this);
  765. this.length = 0;
  766. }
  767. PropMap.prototype.get = function(key) {
  768. return this[key];
  769. };
  770. PropMap.prototype.put = function(key, value) {
  771. if (this[key] == null) {
  772. this.length++;
  773. }
  774. return this[key] = value;
  775. };
  776. PropMap.prototype.remove = function(key) {
  777. delete this[key];
  778. return this.length--;
  779. };
  780. PropMap.prototype.values = function() {
  781. var all, keys,
  782. _this = this;
  783. all = [];
  784. keys = _.keys(this);
  785. _.each(keys, function(value) {
  786. if (_.indexOf(propsToPop, value) === -1) {
  787. return all.push(_this[value]);
  788. }
  789. });
  790. return all;
  791. };
  792. PropMap.prototype.keys = function() {
  793. var all, keys,
  794. _this = this;
  795. keys = _.keys(this);
  796. all = [];
  797. _.each(keys, function(prop) {
  798. if (_.indexOf(propsToPop, prop) === -1) {
  799. return all.push(prop);
  800. }
  801. });
  802. return all;
  803. };
  804. return PropMap;
  805. })();
  806. return PropMap;
  807. });
  808. }).call(this);
  809. (function() {
  810. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  811. __hasProp = {}.hasOwnProperty,
  812. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  813. angular.module("google-maps.directives.api.managers").factory("ClustererMarkerManager", [
  814. "Logger", "FitHelper", function($log, FitHelper) {
  815. var ClustererMarkerManager;
  816. ClustererMarkerManager = (function(_super) {
  817. __extends(ClustererMarkerManager, _super);
  818. function ClustererMarkerManager(gMap, opt_markers, opt_options, opt_events) {
  819. var self;
  820. this.opt_events = opt_events;
  821. this.fit = __bind(this.fit, this);
  822. this.destroy = __bind(this.destroy, this);
  823. this.clear = __bind(this.clear, this);
  824. this.draw = __bind(this.draw, this);
  825. this.removeMany = __bind(this.removeMany, this);
  826. this.remove = __bind(this.remove, this);
  827. this.addMany = __bind(this.addMany, this);
  828. this.add = __bind(this.add, this);
  829. ClustererMarkerManager.__super__.constructor.call(this);
  830. self = this;
  831. this.opt_options = opt_options;
  832. if ((opt_options != null) && opt_markers === void 0) {
  833. this.clusterer = new MarkerClusterer(gMap, void 0, opt_options);
  834. } else if ((opt_options != null) && (opt_markers != null)) {
  835. this.clusterer = new MarkerClusterer(gMap, opt_markers, opt_options);
  836. } else {
  837. this.clusterer = new MarkerClusterer(gMap);
  838. }
  839. this.attachEvents(this.opt_events, "opt_events");
  840. this.clusterer.setIgnoreHidden(true);
  841. this.noDrawOnSingleAddRemoves = true;
  842. $log.info(this);
  843. }
  844. ClustererMarkerManager.prototype.add = function(gMarker) {
  845. return this.clusterer.addMarker(gMarker, this.noDrawOnSingleAddRemoves);
  846. };
  847. ClustererMarkerManager.prototype.addMany = function(gMarkers) {
  848. return this.clusterer.addMarkers(gMarkers);
  849. };
  850. ClustererMarkerManager.prototype.remove = function(gMarker) {
  851. return this.clusterer.removeMarker(gMarker, this.noDrawOnSingleAddRemoves);
  852. };
  853. ClustererMarkerManager.prototype.removeMany = function(gMarkers) {
  854. return this.clusterer.addMarkers(gMarkers);
  855. };
  856. ClustererMarkerManager.prototype.draw = function() {
  857. return this.clusterer.repaint();
  858. };
  859. ClustererMarkerManager.prototype.clear = function() {
  860. this.clusterer.clearMarkers();
  861. return this.clusterer.repaint();
  862. };
  863. ClustererMarkerManager.prototype.attachEvents = function(options, optionsName) {
  864. var eventHandler, eventName, _results;
  865. if (angular.isDefined(options) && (options != null) && angular.isObject(options)) {
  866. _results = [];
  867. for (eventName in options) {
  868. eventHandler = options[eventName];
  869. if (options.hasOwnProperty(eventName) && angular.isFunction(options[eventName])) {
  870. $log.info("" + optionsName + ": Attaching event: " + eventName + " to clusterer");
  871. _results.push(google.maps.event.addListener(this.clusterer, eventName, options[eventName]));
  872. } else {
  873. _results.push(void 0);
  874. }
  875. }
  876. return _results;
  877. }
  878. };
  879. ClustererMarkerManager.prototype.clearEvents = function(options) {
  880. var eventHandler, eventName, _results;
  881. if (angular.isDefined(options) && (options != null) && angular.isObject(options)) {
  882. _results = [];
  883. for (eventName in options) {
  884. eventHandler = options[eventName];
  885. if (options.hasOwnProperty(eventName) && angular.isFunction(options[eventName])) {
  886. $log.info("" + optionsName + ": Clearing event: " + eventName + " to clusterer");
  887. _results.push(google.maps.event.clearListeners(this.clusterer, eventName));
  888. } else {
  889. _results.push(void 0);
  890. }
  891. }
  892. return _results;
  893. }
  894. };
  895. ClustererMarkerManager.prototype.destroy = function() {
  896. this.clearEvents(this.opt_events);
  897. this.clearEvents(this.opt_internal_events);
  898. return this.clear();
  899. };
  900. ClustererMarkerManager.prototype.fit = function() {
  901. return ClustererMarkerManager.__super__.fit.call(this, this.clusterer.getMarkers(), this.clusterer.getMap());
  902. };
  903. return ClustererMarkerManager;
  904. })(FitHelper);
  905. return ClustererMarkerManager;
  906. }
  907. ]);
  908. }).call(this);
  909. (function() {
  910. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  911. __hasProp = {}.hasOwnProperty,
  912. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  913. angular.module("google-maps.directives.api.managers").factory("MarkerManager", [
  914. "Logger", "FitHelper", function(Logger, FitHelper) {
  915. var MarkerManager;
  916. MarkerManager = (function(_super) {
  917. __extends(MarkerManager, _super);
  918. MarkerManager.include(FitHelper);
  919. function MarkerManager(gMap, opt_markers, opt_options) {
  920. this.fit = __bind(this.fit, this);
  921. this.handleOptDraw = __bind(this.handleOptDraw, this);
  922. this.clear = __bind(this.clear, this);
  923. this.draw = __bind(this.draw, this);
  924. this.removeMany = __bind(this.removeMany, this);
  925. this.remove = __bind(this.remove, this);
  926. this.addMany = __bind(this.addMany, this);
  927. this.add = __bind(this.add, this);
  928. var self;
  929. MarkerManager.__super__.constructor.call(this);
  930. self = this;
  931. this.gMap = gMap;
  932. this.gMarkers = [];
  933. this.$log = Logger;
  934. this.$log.info(this);
  935. }
  936. MarkerManager.prototype.add = function(gMarker, optDraw) {
  937. this.handleOptDraw(gMarker, optDraw, true);
  938. return this.gMarkers.push(gMarker);
  939. };
  940. MarkerManager.prototype.addMany = function(gMarkers) {
  941. var gMarker, _i, _len, _results;
  942. _results = [];
  943. for (_i = 0, _len = gMarkers.length; _i < _len; _i++) {
  944. gMarker = gMarkers[_i];
  945. _results.push(this.add(gMarker));
  946. }
  947. return _results;
  948. };
  949. MarkerManager.prototype.remove = function(gMarker, optDraw) {
  950. var index, tempIndex;
  951. this.handleOptDraw(gMarker, optDraw, false);
  952. if (!optDraw) {
  953. return;
  954. }
  955. index = void 0;
  956. if (this.gMarkers.indexOf != null) {
  957. index = this.gMarkers.indexOf(gMarker);
  958. } else {
  959. tempIndex = 0;
  960. _.find(this.gMarkers, function(marker) {
  961. tempIndex += 1;
  962. if (marker === gMarker) {
  963. index = tempIndex;
  964. }
  965. });
  966. }
  967. if (index != null) {
  968. return this.gMarkers.splice(index, 1);
  969. }
  970. };
  971. MarkerManager.prototype.removeMany = function(gMarkers) {
  972. var _this = this;
  973. return this.gMarkers.forEach(function(marker) {
  974. return _this.remove(marker);
  975. });
  976. };
  977. MarkerManager.prototype.draw = function() {
  978. var deletes,
  979. _this = this;
  980. deletes = [];
  981. this.gMarkers.forEach(function(gMarker) {
  982. if (!gMarker.isDrawn) {
  983. if (gMarker.doAdd) {
  984. return gMarker.setMap(_this.gMap);
  985. } else {
  986. return deletes.push(gMarker);
  987. }
  988. }
  989. });
  990. return deletes.forEach(function(gMarker) {
  991. return _this.remove(gMarker, true);
  992. });
  993. };
  994. MarkerManager.prototype.clear = function() {
  995. var gMarker, _i, _len, _ref;
  996. _ref = this.gMarkers;
  997. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  998. gMarker = _ref[_i];
  999. gMarker.setMap(null);
  1000. }
  1001. delete this.gMarkers;
  1002. return this.gMarkers = [];
  1003. };
  1004. MarkerManager.prototype.handleOptDraw = function(gMarker, optDraw, doAdd) {
  1005. if (optDraw === true) {
  1006. if (doAdd) {
  1007. gMarker.setMap(this.gMap);
  1008. } else {
  1009. gMarker.setMap(null);
  1010. }
  1011. return gMarker.isDrawn = true;
  1012. } else {
  1013. gMarker.isDrawn = false;
  1014. return gMarker.doAdd = doAdd;
  1015. }
  1016. };
  1017. MarkerManager.prototype.fit = function() {
  1018. return MarkerManager.__super__.fit.call(this, this.gMarkers, this.gMap);
  1019. };
  1020. return MarkerManager;
  1021. })(FitHelper);
  1022. return MarkerManager;
  1023. }
  1024. ]);
  1025. }).call(this);
  1026. (function() {
  1027. angular.module("google-maps").factory("array-sync", [
  1028. "add-events", function(mapEvents) {
  1029. return function(mapArray, scope, pathEval, pathChangedFn) {
  1030. var geojsonArray, geojsonHandlers, geojsonWatcher, isSetFromScope, legacyHandlers, legacyWatcher, mapArrayListener, scopePath, watchListener;
  1031. isSetFromScope = false;
  1032. scopePath = scope.$eval(pathEval);
  1033. if (!scope["static"]) {
  1034. legacyHandlers = {
  1035. set_at: function(index) {
  1036. var value;
  1037. if (isSetFromScope) {
  1038. return;
  1039. }
  1040. value = mapArray.getAt(index);
  1041. if (!value) {
  1042. return;
  1043. }
  1044. if (!value.lng || !value.lat) {
  1045. return scopePath[index] = value;
  1046. } else {
  1047. scopePath[index].latitude = value.lat();
  1048. return scopePath[index].longitude = value.lng();
  1049. }
  1050. },
  1051. insert_at: function(index) {
  1052. var value;
  1053. if (isSetFromScope) {
  1054. return;
  1055. }
  1056. value = mapArray.getAt(index);
  1057. if (!value) {
  1058. return;
  1059. }
  1060. if (!value.lng || !value.lat) {
  1061. return scopePath.splice(index, 0, value);
  1062. } else {
  1063. return scopePath.splice(index, 0, {
  1064. latitude: value.lat(),
  1065. longitude: value.lng()
  1066. });
  1067. }
  1068. },
  1069. remove_at: function(index) {
  1070. if (isSetFromScope) {
  1071. return;
  1072. }
  1073. return scopePath.splice(index, 1);
  1074. }
  1075. };
  1076. geojsonArray;
  1077. if (scopePath.type === "Polygon") {
  1078. geojsonArray = scopePath.coordinates[0];
  1079. } else if (scopePath.type === "LineString") {
  1080. geojsonArray = scopePath.coordinates;
  1081. }
  1082. geojsonHandlers = {
  1083. set_at: function(index) {
  1084. var value;
  1085. if (isSetFromScope) {
  1086. return;
  1087. }
  1088. value = mapArray.getAt(index);
  1089. if (!value) {
  1090. return;
  1091. }
  1092. if (!value.lng || !value.lat) {
  1093. return;
  1094. }
  1095. geojsonArray[index][1] = value.lat();
  1096. return geojsonArray[index][0] = value.lng();
  1097. },
  1098. insert_at: function(index) {
  1099. var value;
  1100. if (isSetFromScope) {
  1101. return;
  1102. }
  1103. value = mapArray.getAt(index);
  1104. if (!value) {
  1105. return;
  1106. }
  1107. if (!value.lng || !value.lat) {
  1108. return;
  1109. }
  1110. return geojsonArray.splice(index, 0, [value.lng(), value.lat()]);
  1111. },
  1112. remove_at: function(index) {
  1113. if (isSetFromScope) {
  1114. return;
  1115. }
  1116. return geojsonArray.splice(index, 1);
  1117. }
  1118. };
  1119. mapArrayListener = mapEvents(mapArray, angular.isUndefined(scopePath.type) ? legacyHandlers : geojsonHandlers);
  1120. }
  1121. legacyWatcher = function(newPath) {
  1122. var i, l, newLength, newValue, oldArray, oldLength, oldValue;
  1123. isSetFromScope = true;
  1124. oldArray = mapArray;
  1125. if (newPath) {
  1126. i = 0;
  1127. oldLength = oldArray.getLength();
  1128. newLength = newPath.length;
  1129. l = Math.min(oldLength, newLength);
  1130. newValue = void 0;
  1131. while (i < l) {
  1132. oldValue = oldArray.getAt(i);
  1133. newValue = newPath[i];
  1134. if (typeof newValue.equals === "function") {
  1135. if (!newValue.equals(oldValue)) {
  1136. oldArray.setAt(i, newValue);
  1137. }
  1138. } else {
  1139. if ((oldValue.lat() !== newValue.latitude) || (oldValue.lng() !== newValue.longitude)) {
  1140. oldArray.setAt(i, new google.maps.LatLng(newValue.latitude, newValue.longitude));
  1141. }
  1142. }
  1143. i++;
  1144. }
  1145. while (i < newLength) {
  1146. newValue = newPath[i];
  1147. if (typeof newValue.lat === "function" && typeof newValue.lng === "function") {
  1148. oldArray.push(newValue);
  1149. } else {
  1150. oldArray.push(new google.maps.LatLng(newValue.latitude, newValue.longitude));
  1151. }
  1152. i++;
  1153. }
  1154. while (i < oldLength) {
  1155. oldArray.pop();
  1156. i++;
  1157. }
  1158. }
  1159. return isSetFromScope = false;
  1160. };
  1161. geojsonWatcher = function(newPath) {
  1162. var array, i, l, newLength, newValue, oldArray, oldLength, oldValue;
  1163. isSetFromScope = true;
  1164. oldArray = mapArray;
  1165. if (newPath) {
  1166. array;
  1167. if (scopePath.type === "Polygon") {
  1168. array = newPath.coordinates[0];
  1169. } else if (scopePath.type === "LineString") {
  1170. array = newPath.coordinates;
  1171. }
  1172. i = 0;
  1173. oldLength = oldArray.getLength();
  1174. newLength = array.length;
  1175. l = Math.min(oldLength, newLength);
  1176. newValue = void 0;
  1177. while (i < l) {
  1178. oldValue = oldArray.getAt(i);
  1179. newValue = array[i];
  1180. if ((oldValue.lat() !== newValue[1]) || (oldValue.lng() !== newValue[0])) {
  1181. oldArray.setAt(i, new google.maps.LatLng(newValue[1], newValue[0]));
  1182. }
  1183. i++;
  1184. }
  1185. while (i < newLength) {
  1186. newValue = array[i];
  1187. oldArray.push(new google.maps.LatLng(newValue[1], newValue[0]));
  1188. i++;
  1189. }
  1190. while (i < oldLength) {
  1191. oldArray.pop();
  1192. i++;
  1193. }
  1194. }
  1195. return isSetFromScope = false;
  1196. };
  1197. watchListener;
  1198. if (!scope["static"]) {
  1199. if (angular.isUndefined(scopePath.type)) {
  1200. watchListener = scope.$watchCollection(pathEval, legacyWatcher);
  1201. } else {
  1202. watchListener = scope.$watch(pathEval, geojsonWatcher, true);
  1203. }
  1204. }
  1205. return function() {
  1206. if (mapArrayListener) {
  1207. mapArrayListener();
  1208. mapArrayListener = null;
  1209. }
  1210. if (watchListener) {
  1211. watchListener();
  1212. return watchListener = null;
  1213. }
  1214. };
  1215. };
  1216. }
  1217. ]);
  1218. }).call(this);
  1219. (function() {
  1220. angular.module("google-maps").factory("add-events", [
  1221. "$timeout", function($timeout) {
  1222. var addEvent, addEvents;
  1223. addEvent = function(target, eventName, handler) {
  1224. return google.maps.event.addListener(target, eventName, function() {
  1225. handler.apply(this, arguments);
  1226. return $timeout((function() {}), true);
  1227. });
  1228. };
  1229. addEvents = function(target, eventName, handler) {
  1230. var remove;
  1231. if (handler) {
  1232. return addEvent(target, eventName, handler);
  1233. }
  1234. remove = [];
  1235. angular.forEach(eventName, function(_handler, key) {
  1236. return remove.push(addEvent(target, key, _handler));
  1237. });
  1238. return function() {
  1239. angular.forEach(remove, function(listener) {
  1240. return google.maps.event.removeListener(listener);
  1241. });
  1242. return remove = null;
  1243. };
  1244. };
  1245. return addEvents;
  1246. }
  1247. ]);
  1248. }).call(this);
  1249. (function() {
  1250. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  1251. __hasProp = {}.hasOwnProperty,
  1252. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  1253. angular.module("google-maps.directives.api.models.child").factory("MarkerLabelChildModel", [
  1254. "BaseObject", "GmapUtil", function(BaseObject, GmapUtil) {
  1255. var MarkerLabelChildModel;
  1256. MarkerLabelChildModel = (function(_super) {
  1257. __extends(MarkerLabelChildModel, _super);
  1258. MarkerLabelChildModel.include(GmapUtil);
  1259. function MarkerLabelChildModel(gMarker, opt_options) {
  1260. this.destroy = __bind(this.destroy, this);
  1261. this.draw = __bind(this.draw, this);
  1262. this.setPosition = __bind(this.setPosition, this);
  1263. this.setZIndex = __bind(this.setZIndex, this);
  1264. this.setVisible = __bind(this.setVisible, this);
  1265. this.setAnchor = __bind(this.setAnchor, this);
  1266. this.setMandatoryStyles = __bind(this.setMandatoryStyles, this);
  1267. this.setStyles = __bind(this.setStyles, this);
  1268. this.setContent = __bind(this.setContent, this);
  1269. this.setTitle = __bind(this.setTitle, this);
  1270. this.getSharedCross = __bind(this.getSharedCross, this);
  1271. var self, _ref, _ref1;
  1272. MarkerLabelChildModel.__super__.constructor.call(this);
  1273. self = this;
  1274. this.marker = gMarker;
  1275. this.marker.set("labelContent", opt_options.labelContent);
  1276. this.marker.set("labelAnchor", this.getLabelPositionPoint(opt_options.labelAnchor));
  1277. this.marker.set("labelClass", opt_options.labelClass || 'labels');
  1278. this.marker.set("labelStyle", opt_options.labelStyle || {
  1279. opacity: 100
  1280. });
  1281. this.marker.set("labelInBackground", opt_options.labelInBackground || false);
  1282. if (!opt_options.labelVisible) {
  1283. this.marker.set("labelVisible", true);
  1284. }
  1285. if (!opt_options.raiseOnDrag) {
  1286. this.marker.set("raiseOnDrag", true);
  1287. }
  1288. if (!opt_options.clickable) {
  1289. this.marker.set("clickable", true);
  1290. }
  1291. if (!opt_options.draggable) {
  1292. this.marker.set("draggable", false);
  1293. }
  1294. if (!opt_options.optimized) {
  1295. this.marker.set("optimized", false);
  1296. }
  1297. opt_options.crossImage = (_ref = opt_options.crossImage) != null ? _ref : document.location.protocol + "//maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png";
  1298. opt_options.handCursor = (_ref1 = opt_options.handCursor) != null ? _ref1 : document.location.protocol + "//maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur";
  1299. this.markerLabel = new MarkerLabel_(this.marker, opt_options.crossImage, opt_options.handCursor);
  1300. this.marker.set("setMap", function(theMap) {
  1301. google.maps.Marker.prototype.setMap.apply(this, arguments);
  1302. return self.markerLabel.setMap(theMap);
  1303. });
  1304. this.marker.setMap(this.marker.getMap());
  1305. }
  1306. MarkerLabelChildModel.prototype.getSharedCross = function(crossUrl) {
  1307. return this.markerLabel.getSharedCross(crossUrl);
  1308. };
  1309. MarkerLabelChildModel.prototype.setTitle = function() {
  1310. return this.markerLabel.setTitle();
  1311. };
  1312. MarkerLabelChildModel.prototype.setContent = function() {
  1313. return this.markerLabel.setContent();
  1314. };
  1315. MarkerLabelChildModel.prototype.setStyles = function() {
  1316. return this.markerLabel.setStyles();
  1317. };
  1318. MarkerLabelChildModel.prototype.setMandatoryStyles = function() {
  1319. return this.markerLabel.setMandatoryStyles();
  1320. };
  1321. MarkerLabelChildModel.prototype.setAnchor = function() {
  1322. return this.markerLabel.setAnchor();
  1323. };
  1324. MarkerLabelChildModel.prototype.setVisible = function() {
  1325. return this.markerLabel.setVisible();
  1326. };
  1327. MarkerLabelChildModel.prototype.setZIndex = function() {
  1328. return this.markerLabel.setZIndex();
  1329. };
  1330. MarkerLabelChildModel.prototype.setPosition = function() {
  1331. return this.markerLabel.setPosition();
  1332. };
  1333. MarkerLabelChildModel.prototype.draw = function() {
  1334. return this.markerLabel.draw();
  1335. };
  1336. MarkerLabelChildModel.prototype.destroy = function() {
  1337. if ((this.markerLabel.labelDiv_.parentNode != null) && (this.markerLabel.eventDiv_.parentNode != null)) {
  1338. return this.markerLabel.onRemove();
  1339. }
  1340. };
  1341. return MarkerLabelChildModel;
  1342. })(BaseObject);
  1343. return MarkerLabelChildModel;
  1344. }
  1345. ]);
  1346. }).call(this);
  1347. (function() {
  1348. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  1349. __hasProp = {}.hasOwnProperty,
  1350. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  1351. angular.module("google-maps.directives.api.models.child").factory("MarkerChildModel", [
  1352. "ModelKey", "GmapUtil", "Logger", "$injector", "EventsHelper", function(ModelKey, GmapUtil, Logger, $injector, EventsHelper) {
  1353. var MarkerChildModel;
  1354. MarkerChildModel = (function(_super) {
  1355. __extends(MarkerChildModel, _super);
  1356. MarkerChildModel.include(GmapUtil);
  1357. MarkerChildModel.include(EventsHelper);
  1358. function MarkerChildModel(model, parentScope, gMap, $timeout, defaults, doClick, gMarkerManager, idKey) {
  1359. var self,
  1360. _this = this;
  1361. this.model = model;
  1362. this.parentScope = parentScope;
  1363. this.gMap = gMap;
  1364. this.$timeout = $timeout;
  1365. this.defaults = defaults;
  1366. this.doClick = doClick;
  1367. this.gMarkerManager = gMarkerManager;
  1368. this.idKey = idKey;
  1369. this.watchDestroy = __bind(this.watchDestroy, this);
  1370. this.setLabelOptions = __bind(this.setLabelOptions, this);
  1371. this.isLabelDefined = __bind(this.isLabelDefined, this);
  1372. this.setOptions = __bind(this.setOptions, this);
  1373. this.setIcon = __bind(this.setIcon, this);
  1374. this.setCoords = __bind(this.setCoords, this);
  1375. this.destroy = __bind(this.destroy, this);
  1376. this.maybeSetScopeValue = __bind(this.maybeSetScopeValue, this);
  1377. this.createMarker = __bind(this.createMarker, this);
  1378. this.setMyScope = __bind(this.setMyScope, this);
  1379. self = this;
  1380. if (this.model[this.idKey]) {
  1381. this.id = this.model[this.idKey];
  1382. }
  1383. this.iconKey = this.parentScope.icon;
  1384. this.coordsKey = this.parentScope.coords;
  1385. this.clickKey = this.parentScope.click();
  1386. this.labelContentKey = this.parentScope.labelContent;
  1387. this.optionsKey = this.parentScope.options;
  1388. this.labelOptionsKey = this.parentScope.labelOptions;
  1389. MarkerChildModel.__super__.constructor.call(this, this.parentScope.$new(false));
  1390. this.scope.model = this.model;
  1391. this.setMyScope(this.model, void 0, true);
  1392. this.createMarker(this.model);
  1393. this.scope.$watch('model', function(newValue, oldValue) {
  1394. if (newValue !== oldValue) {
  1395. return _this.setMyScope(newValue, oldValue);
  1396. }
  1397. }, true);
  1398. this.$log = Logger;
  1399. this.$log.info(self);
  1400. this.watchDestroy(this.scope);
  1401. }
  1402. MarkerChildModel.prototype.setMyScope = function(model, oldModel, isInit) {
  1403. var _this = this;
  1404. if (oldModel == null) {
  1405. oldModel = void 0;
  1406. }
  1407. if (isInit == null) {
  1408. isInit = false;
  1409. }
  1410. this.maybeSetScopeValue('icon', model, oldModel, this.iconKey, this.evalModelHandle, isInit, this.setIcon);
  1411. this.maybeSetScopeValue('coords', model, oldModel, this.coordsKey, this.evalModelHandle, isInit, this.setCoords);
  1412. this.maybeSetScopeValue('labelContent', model, oldModel, this.labelContentKey, this.evalModelHandle, isInit);
  1413. if (_.isFunction(this.clickKey) && $injector) {
  1414. return this.scope.click = function() {
  1415. return $injector.invoke(_this.clickKey, void 0, {
  1416. "$markerModel": model
  1417. });
  1418. };
  1419. } else {
  1420. this.maybeSetScopeValue('click', model, oldModel, this.clickKey, this.evalModelHandle, isInit);
  1421. return this.createMarker(model, oldModel, isInit);
  1422. }
  1423. };
  1424. MarkerChildModel.prototype.createMarker = function(model, oldModel, isInit) {
  1425. var _this = this;
  1426. if (oldModel == null) {
  1427. oldModel = void 0;
  1428. }
  1429. if (isInit == null) {
  1430. isInit = false;
  1431. }
  1432. return this.maybeSetScopeValue('options', model, oldModel, this.optionsKey, function(lModel, lModelKey) {
  1433. var value;
  1434. if (lModel === void 0) {
  1435. return void 0;
  1436. }
  1437. value = lModelKey === 'self' ? lModel : lModel[lModelKey];
  1438. if (value === void 0) {
  1439. return value = lModelKey === void 0 ? _this.defaults : _this.scope.options;
  1440. } else {
  1441. return value;
  1442. }
  1443. }, isInit, this.setOptions);
  1444. };
  1445. MarkerChildModel.prototype.maybeSetScopeValue = function(scopePropName, model, oldModel, modelKey, evaluate, isInit, gSetter) {
  1446. var newValue, oldVal;
  1447. if (gSetter == null) {
  1448. gSetter = void 0;
  1449. }
  1450. if (oldModel === void 0) {
  1451. this.scope[scopePropName] = evaluate(model, modelKey);
  1452. if (!isInit) {
  1453. if (gSetter != null) {
  1454. gSetter(this.scope);
  1455. }
  1456. }
  1457. return;
  1458. }
  1459. oldVal = evaluate(oldModel, modelKey);
  1460. newValue = evaluate(model, modelKey);
  1461. if (newValue !== oldVal && this.scope[scopePropName] !== newValue) {
  1462. this.scope[scopePropName] = newValue;
  1463. if (!isInit) {
  1464. if (gSetter != null) {
  1465. gSetter(this.scope);
  1466. }
  1467. return this.gMarkerManager.draw();
  1468. }
  1469. }
  1470. };
  1471. MarkerChildModel.prototype.destroy = function() {
  1472. return this.scope.$destroy();
  1473. };
  1474. MarkerChildModel.prototype.setCoords = function(scope) {
  1475. if (scope.$id !== this.scope.$id || this.gMarker === void 0) {
  1476. return;
  1477. }
  1478. if ((scope.coords != null)) {
  1479. if (!this.validateCoords(this.scope.coords)) {
  1480. this.$log.error("MarkerChildMarker cannot render marker as scope.coords as no position on marker: " + (JSON.stringify(this.model)));
  1481. return;
  1482. }
  1483. this.gMarker.setPosition(this.getCoords(scope.coords));
  1484. this.gMarker.setVisible(this.validateCoords(scope.coords));
  1485. this.gMarkerManager.remove(this.gMarker);
  1486. return this.gMarkerManager.add(this.gMarker);
  1487. } else {
  1488. return this.gMarkerManager.remove(this.gMarker);
  1489. }
  1490. };
  1491. MarkerChildModel.prototype.setIcon = function(scope) {
  1492. if (scope.$id !== this.scope.$id || this.gMarker === void 0) {
  1493. return;
  1494. }
  1495. this.gMarkerManager.remove(this.gMarker);
  1496. this.gMarker.setIcon(scope.icon);
  1497. this.gMarkerManager.add(this.gMarker);
  1498. this.gMarker.setPosition(this.getCoords(scope.coords));
  1499. return this.gMarker.setVisible(this.validateCoords(scope.coords));
  1500. };
  1501. MarkerChildModel.prototype.setOptions = function(scope) {
  1502. var _ref,
  1503. _this = this;
  1504. if (scope.$id !== this.scope.$id) {
  1505. return;
  1506. }
  1507. if (this.gMarker != null) {
  1508. this.gMarkerManager.remove(this.gMarker);
  1509. delete this.gMarker;
  1510. }
  1511. if (!((_ref = scope.coords) != null ? _ref : typeof scope.icon === "function" ? scope.icon(scope.options != null) : void 0)) {
  1512. return;
  1513. }
  1514. this.opts = this.createMarkerOptions(scope.coords, scope.icon, scope.options);
  1515. delete this.gMarker;
  1516. if (this.isLabelDefined(scope)) {
  1517. this.gMarker = new MarkerWithLabel(this.setLabelOptions(this.opts, scope));
  1518. } else {
  1519. this.gMarker = new google.maps.Marker(this.opts);
  1520. }
  1521. this.setEvents(this.gMarker, this.parentScope, this.model);
  1522. if (this.id) {
  1523. this.gMarker.key = this.id;
  1524. }
  1525. this.gMarkerManager.add(this.gMarker);
  1526. return google.maps.event.addListener(this.gMarker, 'click', function() {
  1527. if (_this.doClick && (_this.scope.click != null)) {
  1528. return _this.scope.click();
  1529. }
  1530. });
  1531. };
  1532. MarkerChildModel.prototype.isLabelDefined = function(scope) {
  1533. return scope.labelContent != null;
  1534. };
  1535. MarkerChildModel.prototype.setLabelOptions = function(opts, scope) {
  1536. opts.labelAnchor = this.getLabelPositionPoint(scope.labelAnchor);
  1537. opts.labelClass = scope.labelClass;
  1538. opts.labelContent = scope.labelContent;
  1539. return opts;
  1540. };
  1541. MarkerChildModel.prototype.watchDestroy = function(scope) {
  1542. var _this = this;
  1543. return scope.$on("$destroy", function() {
  1544. var self, _ref;
  1545. if (_this.gMarker != null) {
  1546. google.maps.event.clearListeners(_this.gMarker, 'click');
  1547. if (((_ref = _this.parentScope) != null ? _ref.events : void 0) && _.isArray(_this.parentScope.events)) {
  1548. _this.parentScope.events.forEach(function(event, eventName) {
  1549. return google.maps.event.clearListeners(this.gMarker, eventName);
  1550. });
  1551. }
  1552. _this.gMarkerManager.remove(_this.gMarker, true);
  1553. delete _this.gMarker;
  1554. }
  1555. return self = void 0;
  1556. });
  1557. };
  1558. return MarkerChildModel;
  1559. })(ModelKey);
  1560. return MarkerChildModel;
  1561. }
  1562. ]);
  1563. }).call(this);
  1564. (function() {
  1565. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  1566. __hasProp = {}.hasOwnProperty,
  1567. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  1568. angular.module("google-maps.directives.api").factory("PolylineChildModel", [
  1569. "BaseObject", "Logger", "$timeout", "array-sync", "GmapUtil", function(BaseObject, Logger, $timeout, arraySync, GmapUtil) {
  1570. var $log, PolylineChildModel;
  1571. $log = Logger;
  1572. return PolylineChildModel = (function(_super) {
  1573. __extends(PolylineChildModel, _super);
  1574. PolylineChildModel.include(GmapUtil);
  1575. function PolylineChildModel(scope, attrs, map, defaults, model) {
  1576. var arraySyncer, pathPoints,
  1577. _this = this;
  1578. this.scope = scope;
  1579. this.attrs = attrs;
  1580. this.map = map;
  1581. this.defaults = defaults;
  1582. this.model = model;
  1583. this.buildOpts = __bind(this.buildOpts, this);
  1584. pathPoints = this.convertPathPoints(scope.path);
  1585. this.polyline = new google.maps.Polyline(this.buildOpts(pathPoints));
  1586. if (scope.fit) {
  1587. GmapUtil.extendMapBounds(map, pathPoints);
  1588. }
  1589. if (!scope["static"] && angular.isDefined(scope.editable)) {
  1590. scope.$watch("editable", function(newValue, oldValue) {
  1591. if (newValue !== oldValue) {
  1592. return _this.polyline.setEditable(newValue);
  1593. }
  1594. });
  1595. }
  1596. if (angular.isDefined(scope.draggable)) {
  1597. scope.$watch("draggable", function(newValue, oldValue) {
  1598. if (newValue !== oldValue) {
  1599. return _this.polyline.setDraggable(newValue);
  1600. }
  1601. });
  1602. }
  1603. if (angular.isDefined(scope.visible)) {
  1604. scope.$watch("visible", function(newValue, oldValue) {
  1605. if (newValue !== oldValue) {
  1606. return _this.polyline.setVisible(newValue);
  1607. }
  1608. });
  1609. }
  1610. if (angular.isDefined(scope.geodesic)) {
  1611. scope.$watch("geodesic", function(newValue, oldValue) {
  1612. if (newValue !== oldValue) {
  1613. return _this.polyline.setOptions(_this.buildOpts(_this.polyline.getPath()));
  1614. }
  1615. });
  1616. }
  1617. if (angular.isDefined(scope.stroke) && angular.isDefined(scope.stroke.weight)) {
  1618. scope.$watch("stroke.weight", function(newValue, oldValue) {
  1619. if (newValue !== oldValue) {
  1620. return _this.polyline.setOptions(_this.buildOpts(_this.polyline.getPath()));
  1621. }
  1622. });
  1623. }
  1624. if (angular.isDefined(scope.stroke) && angular.isDefined(scope.stroke.color)) {
  1625. scope.$watch("stroke.color", function(newValue, oldValue) {
  1626. if (newValue !== oldValue) {
  1627. return _this.polyline.setOptions(_this.buildOpts(_this.polyline.getPath()));
  1628. }
  1629. });
  1630. }
  1631. if (angular.isDefined(scope.stroke) && angular.isDefined(scope.stroke.opacity)) {
  1632. scope.$watch("stroke.opacity", function(newValue, oldValue) {
  1633. if (newValue !== oldValue) {
  1634. return _this.polyline.setOptions(_this.buildOpts(_this.polyline.getPath()));
  1635. }
  1636. });
  1637. }
  1638. if (angular.isDefined(scope.icons)) {
  1639. scope.$watch("icons", function(newValue, oldValue) {
  1640. if (newValue !== oldValue) {
  1641. return _this.polyline.setOptions(_this.buildOpts(_this.polyline.getPath()));
  1642. }
  1643. });
  1644. }
  1645. arraySyncer = arraySync(this.polyline.getPath(), scope, "path", function(pathPoints) {
  1646. if (scope.fit) {
  1647. return GmapUtil.extendMapBounds(map, pathPoints);
  1648. }
  1649. });
  1650. scope.$on("$destroy", function() {
  1651. _this.polyline.setMap(null);
  1652. _this.polyline = null;
  1653. _this.scope = null;
  1654. if (arraySyncer) {
  1655. arraySyncer();
  1656. return arraySyncer = null;
  1657. }
  1658. });
  1659. $log.info(this);
  1660. }
  1661. PolylineChildModel.prototype.buildOpts = function(pathPoints) {
  1662. var opts,
  1663. _this = this;
  1664. opts = angular.extend({}, this.defaults, {
  1665. map: this.map,
  1666. path: pathPoints,
  1667. icons: this.scope.icons,
  1668. strokeColor: this.scope.stroke && this.scope.stroke.color,
  1669. strokeOpacity: this.scope.stroke && this.scope.stroke.opacity,
  1670. strokeWeight: this.scope.stroke && this.scope.stroke.weight
  1671. });
  1672. angular.forEach({
  1673. clickable: true,
  1674. draggable: false,
  1675. editable: false,
  1676. geodesic: false,
  1677. visible: true,
  1678. "static": false,
  1679. fit: false
  1680. }, function(defaultValue, key) {
  1681. if (angular.isUndefined(_this.scope[key]) || _this.scope[key] === null) {
  1682. return opts[key] = defaultValue;
  1683. } else {
  1684. return opts[key] = _this.scope[key];
  1685. }
  1686. });
  1687. if (opts["static"]) {
  1688. opts.editable = false;
  1689. }
  1690. return opts;
  1691. };
  1692. PolylineChildModel.prototype.destroy = function() {
  1693. return this.scope.$destroy();
  1694. };
  1695. return PolylineChildModel;
  1696. })(BaseObject);
  1697. }
  1698. ]);
  1699. }).call(this);
  1700. (function() {
  1701. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  1702. __hasProp = {}.hasOwnProperty,
  1703. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  1704. angular.module("google-maps.directives.api.models.child").factory("WindowChildModel", [
  1705. "BaseObject", "GmapUtil", "Logger", "$compile", "$http", "$templateCache", function(BaseObject, GmapUtil, Logger, $compile, $http, $templateCache) {
  1706. var WindowChildModel;
  1707. WindowChildModel = (function(_super) {
  1708. __extends(WindowChildModel, _super);
  1709. WindowChildModel.include(GmapUtil);
  1710. function WindowChildModel(model, scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, element, needToManualDestroy, markerIsVisibleAfterWindowClose) {
  1711. this.model = model;
  1712. this.scope = scope;
  1713. this.opts = opts;
  1714. this.isIconVisibleOnClick = isIconVisibleOnClick;
  1715. this.mapCtrl = mapCtrl;
  1716. this.markerCtrl = markerCtrl;
  1717. this.element = element;
  1718. this.needToManualDestroy = needToManualDestroy != null ? needToManualDestroy : false;
  1719. this.markerIsVisibleAfterWindowClose = markerIsVisibleAfterWindowClose != null ? markerIsVisibleAfterWindowClose : true;
  1720. this.destroy = __bind(this.destroy, this);
  1721. this.remove = __bind(this.remove, this);
  1722. this.hideWindow = __bind(this.hideWindow, this);
  1723. this.getLatestPosition = __bind(this.getLatestPosition, this);
  1724. this.showWindow = __bind(this.showWindow, this);
  1725. this.handleClick = __bind(this.handleClick, this);
  1726. this.watchCoords = __bind(this.watchCoords, this);
  1727. this.watchShow = __bind(this.watchShow, this);
  1728. this.createGWin = __bind(this.createGWin, this);
  1729. this.watchElement = __bind(this.watchElement, this);
  1730. this.googleMapsHandles = [];
  1731. this.$log = Logger;
  1732. this.createGWin();
  1733. if (this.markerCtrl != null) {
  1734. this.markerCtrl.setClickable(true);
  1735. }
  1736. this.handleClick();
  1737. this.watchElement();
  1738. this.watchShow();
  1739. this.watchCoords();
  1740. this.$log.info(this);
  1741. }
  1742. WindowChildModel.prototype.watchElement = function() {
  1743. var _this = this;
  1744. return this.scope.$watch(function() {
  1745. var _ref;
  1746. if (!_this.element || !_this.html) {
  1747. return;
  1748. }
  1749. if (_this.html !== _this.element.html()) {
  1750. if (_this.gWin) {
  1751. if ((_ref = _this.opts) != null) {
  1752. _ref.content = void 0;
  1753. }
  1754. _this.remove();
  1755. _this.createGWin();
  1756. return _this.showHide();
  1757. }
  1758. }
  1759. });
  1760. };
  1761. WindowChildModel.prototype.createGWin = function() {
  1762. var defaults,
  1763. _this = this;
  1764. if (this.gWin == null) {
  1765. defaults = {};
  1766. if (this.opts != null) {
  1767. if (this.scope.coords) {
  1768. this.opts.position = this.getCoords(this.scope.coords);
  1769. }
  1770. defaults = this.opts;
  1771. }
  1772. if (this.element) {
  1773. this.html = _.isObject(this.element) ? this.element.html() : this.element;
  1774. }
  1775. this.opts = this.createWindowOptions(this.markerCtrl, this.scope, this.html, defaults);
  1776. }
  1777. if ((this.opts != null) && !this.gWin) {
  1778. if (this.opts.boxClass && (window.InfoBox && typeof window.InfoBox === 'function')) {
  1779. this.gWin = new window.InfoBox(this.opts);
  1780. } else {
  1781. this.gWin = new google.maps.InfoWindow(this.opts);
  1782. }
  1783. return this.googleMapsHandles.push(google.maps.event.addListener(this.gWin, 'closeclick', function() {
  1784. var _ref;
  1785. if ((_ref = _this.markerCtrl) != null) {
  1786. _ref.setVisible(_this.markerIsVisibleAfterWindowClose);
  1787. }
  1788. _this.gWin.isOpen(false);
  1789. if (_this.scope.closeClick != null) {
  1790. return _this.scope.closeClick();
  1791. }
  1792. }));
  1793. }
  1794. };
  1795. WindowChildModel.prototype.watchShow = function() {
  1796. var _this = this;
  1797. return this.scope.$watch('show', function(newValue, oldValue) {
  1798. if (newValue !== oldValue) {
  1799. if (newValue) {
  1800. return _this.showWindow();
  1801. } else {
  1802. return _this.hideWindow();
  1803. }
  1804. } else {
  1805. if (_this.gWin != null) {
  1806. if (newValue && !_this.gWin.getMap()) {
  1807. return _this.showWindow();
  1808. }
  1809. }
  1810. }
  1811. }, true);
  1812. };
  1813. WindowChildModel.prototype.watchCoords = function() {
  1814. var scope,
  1815. _this = this;
  1816. scope = this.markerCtrl != null ? this.scope.$parent : this.scope;
  1817. return scope.$watch('coords', function(newValue, oldValue) {
  1818. var pos;
  1819. if (newValue !== oldValue) {
  1820. if (newValue == null) {
  1821. return _this.hideWindow();
  1822. } else {
  1823. if (!_this.validateCoords(newValue)) {
  1824. _this.$log.error("WindowChildMarker cannot render marker as scope.coords as no position on marker: " + (JSON.stringify(_this.model)));
  1825. return;
  1826. }
  1827. pos = _this.getCoords(newValue);
  1828. _this.gWin.setPosition(pos);
  1829. if (_this.opts) {
  1830. return _this.opts.position = pos;
  1831. }
  1832. }
  1833. }
  1834. }, true);
  1835. };
  1836. WindowChildModel.prototype.handleClick = function() {
  1837. var _this = this;
  1838. if (this.markerCtrl != null) {
  1839. return this.googleMapsHandles.push(google.maps.event.addListener(this.markerCtrl, 'click', function() {
  1840. var pos;
  1841. if (_this.gWin == null) {
  1842. _this.createGWin();
  1843. }
  1844. pos = _this.markerCtrl.getPosition();
  1845. if (_this.gWin != null) {
  1846. _this.gWin.setPosition(pos);
  1847. if (_this.opts) {
  1848. _this.opts.position = pos;
  1849. }
  1850. _this.showWindow();
  1851. }
  1852. _this.initialMarkerVisibility = _this.markerCtrl.getVisible();
  1853. return _this.markerCtrl.setVisible(_this.isIconVisibleOnClick);
  1854. }));
  1855. }
  1856. };
  1857. WindowChildModel.prototype.showWindow = function() {
  1858. var show,
  1859. _this = this;
  1860. show = function() {
  1861. if (_this.gWin) {
  1862. if ((_this.scope.show || (_this.scope.show == null)) && !_this.gWin.isOpen()) {
  1863. return _this.gWin.open(_this.mapCtrl);
  1864. }
  1865. }
  1866. };
  1867. if (this.scope.templateUrl) {
  1868. if (this.gWin) {
  1869. $http.get(this.scope.templateUrl, {
  1870. cache: $templateCache
  1871. }).then(function(content) {
  1872. var compiled, templateScope;
  1873. templateScope = _this.scope.$new();
  1874. if (angular.isDefined(_this.scope.templateParameter)) {
  1875. templateScope.parameter = _this.scope.templateParameter;
  1876. }
  1877. compiled = $compile(content.data)(templateScope);
  1878. return _this.gWin.setContent(compiled[0]);
  1879. });
  1880. }
  1881. return show();
  1882. } else {
  1883. return show();
  1884. }
  1885. };
  1886. WindowChildModel.prototype.showHide = function() {
  1887. if (this.scope.show) {
  1888. return this.showWindow();
  1889. } else {
  1890. return this.hideWindow();
  1891. }
  1892. };
  1893. WindowChildModel.prototype.getLatestPosition = function() {
  1894. if ((this.gWin != null) && (this.markerCtrl != null)) {
  1895. return this.gWin.setPosition(this.markerCtrl.getPosition());
  1896. }
  1897. };
  1898. WindowChildModel.prototype.hideWindow = function() {
  1899. if ((this.gWin != null) && this.gWin.isOpen()) {
  1900. return this.gWin.close();
  1901. }
  1902. };
  1903. WindowChildModel.prototype.remove = function() {
  1904. this.hideWindow();
  1905. _.each(this.googleMapsHandles, function(h) {
  1906. return google.maps.event.removeListener(h);
  1907. });
  1908. this.googleMapsHandles.length = 0;
  1909. return delete this.gWin;
  1910. };
  1911. WindowChildModel.prototype.destroy = function(manualOverride) {
  1912. var self;
  1913. if (manualOverride == null) {
  1914. manualOverride = false;
  1915. }
  1916. this.remove();
  1917. if ((this.scope != null) && (this.needToManualDestroy || manualOverride)) {
  1918. this.scope.$destroy();
  1919. }
  1920. return self = void 0;
  1921. };
  1922. return WindowChildModel;
  1923. })(BaseObject);
  1924. return WindowChildModel;
  1925. }
  1926. ]);
  1927. }).call(this);
  1928. /*
  1929. - interface for all markers to derrive from
  1930. - to enforce a minimum set of requirements
  1931. - attributes
  1932. - coords
  1933. - icon
  1934. - implementation needed on watches
  1935. */
  1936. (function() {
  1937. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  1938. __hasProp = {}.hasOwnProperty,
  1939. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  1940. angular.module("google-maps.directives.api.models.parent").factory("IMarkerParentModel", [
  1941. "ModelKey", "Logger", function(ModelKey, Logger) {
  1942. var IMarkerParentModel;
  1943. IMarkerParentModel = (function(_super) {
  1944. __extends(IMarkerParentModel, _super);
  1945. IMarkerParentModel.prototype.DEFAULTS = {};
  1946. function IMarkerParentModel(scope, element, attrs, mapCtrl, $timeout) {
  1947. var self,
  1948. _this = this;
  1949. this.scope = scope;
  1950. this.element = element;
  1951. this.attrs = attrs;
  1952. this.mapCtrl = mapCtrl;
  1953. this.$timeout = $timeout;
  1954. this.linkInit = __bind(this.linkInit, this);
  1955. this.onDestroy = __bind(this.onDestroy, this);
  1956. this.onWatch = __bind(this.onWatch, this);
  1957. this.watch = __bind(this.watch, this);
  1958. this.validateScope = __bind(this.validateScope, this);
  1959. this.onTimeOut = __bind(this.onTimeOut, this);
  1960. IMarkerParentModel.__super__.constructor.call(this, this.scope);
  1961. self = this;
  1962. this.$log = Logger;
  1963. if (!this.validateScope(scope)) {
  1964. throw new String("Unable to construct IMarkerParentModel due to invalid scope");
  1965. }
  1966. this.doClick = angular.isDefined(attrs.click);
  1967. if (scope.options != null) {
  1968. this.DEFAULTS = scope.options;
  1969. }
  1970. this.$timeout(function() {
  1971. _this.onTimeOut(scope);
  1972. _this.watch('coords', _this.scope);
  1973. _this.watch('icon', _this.scope);
  1974. _this.watch('options', _this.scope);
  1975. return scope.$on("$destroy", function() {
  1976. return _this.onDestroy(scope);
  1977. });
  1978. });
  1979. }
  1980. IMarkerParentModel.prototype.onTimeOut = function(scope) {};
  1981. IMarkerParentModel.prototype.validateScope = function(scope) {
  1982. var ret;
  1983. if (scope == null) {
  1984. this.$log.error(this.constructor.name + ": invalid scope used");
  1985. return false;
  1986. }
  1987. ret = scope.coords != null;
  1988. if (!ret) {
  1989. this.$log.error(this.constructor.name + ": no valid coords attribute found");
  1990. return false;
  1991. }
  1992. return ret;
  1993. };
  1994. IMarkerParentModel.prototype.watch = function(propNameToWatch, scope) {
  1995. var watchFunc,
  1996. _this = this;
  1997. watchFunc = function(newValue, oldValue) {
  1998. if (newValue !== oldValue) {
  1999. return _this.onWatch(propNameToWatch, scope, newValue, oldValue);
  2000. }
  2001. };
  2002. return scope.$watch(propNameToWatch, watchFunc, true);
  2003. };
  2004. IMarkerParentModel.prototype.onWatch = function(propNameToWatch, scope, newValue, oldValue) {
  2005. throw new String("OnWatch Not Implemented!!");
  2006. };
  2007. IMarkerParentModel.prototype.onDestroy = function(scope) {
  2008. throw new String("OnDestroy Not Implemented!!");
  2009. };
  2010. IMarkerParentModel.prototype.linkInit = function(element, mapCtrl, scope, animate) {
  2011. throw new String("LinkInit Not Implemented!!");
  2012. };
  2013. return IMarkerParentModel;
  2014. })(ModelKey);
  2015. return IMarkerParentModel;
  2016. }
  2017. ]);
  2018. }).call(this);
  2019. /*
  2020. - interface directive for all window(s) to derrive from
  2021. */
  2022. (function() {
  2023. var __hasProp = {}.hasOwnProperty,
  2024. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2025. angular.module("google-maps.directives.api.models.parent").factory("IWindowParentModel", [
  2026. "ModelKey", "GmapUtil", "Logger", function(ModelKey, GmapUtil, Logger) {
  2027. var IWindowParentModel;
  2028. IWindowParentModel = (function(_super) {
  2029. __extends(IWindowParentModel, _super);
  2030. IWindowParentModel.include(GmapUtil);
  2031. IWindowParentModel.prototype.DEFAULTS = {};
  2032. function IWindowParentModel(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache) {
  2033. var self;
  2034. IWindowParentModel.__super__.constructor.call(this, scope);
  2035. self = this;
  2036. this.$log = Logger;
  2037. this.$timeout = $timeout;
  2038. this.$compile = $compile;
  2039. this.$http = $http;
  2040. this.$templateCache = $templateCache;
  2041. if (scope.options != null) {
  2042. this.DEFAULTS = scope.options;
  2043. }
  2044. }
  2045. return IWindowParentModel;
  2046. })(ModelKey);
  2047. return IWindowParentModel;
  2048. }
  2049. ]);
  2050. }).call(this);
  2051. (function() {
  2052. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2053. __hasProp = {}.hasOwnProperty,
  2054. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2055. angular.module("google-maps.directives.api.models.parent").factory("LayerParentModel", [
  2056. "BaseObject", "Logger", function(BaseObject, Logger) {
  2057. var LayerParentModel;
  2058. LayerParentModel = (function(_super) {
  2059. __extends(LayerParentModel, _super);
  2060. function LayerParentModel(scope, element, attrs, mapCtrl, $timeout, onLayerCreated, $log) {
  2061. var _this = this;
  2062. this.scope = scope;
  2063. this.element = element;
  2064. this.attrs = attrs;
  2065. this.mapCtrl = mapCtrl;
  2066. this.$timeout = $timeout;
  2067. this.onLayerCreated = onLayerCreated != null ? onLayerCreated : void 0;
  2068. this.$log = $log != null ? $log : Logger;
  2069. this.createGoogleLayer = __bind(this.createGoogleLayer, this);
  2070. if (this.attrs.type == null) {
  2071. this.$log.info("type attribute for the layer directive is mandatory. Layer creation aborted!!");
  2072. return;
  2073. }
  2074. this.createGoogleLayer();
  2075. this.gMap = void 0;
  2076. this.doShow = true;
  2077. this.$timeout(function() {
  2078. _this.gMap = mapCtrl.getMap();
  2079. if (angular.isDefined(_this.attrs.show)) {
  2080. _this.doShow = _this.scope.show;
  2081. }
  2082. if (_this.doShow && (_this.gMap != null)) {
  2083. _this.layer.setMap(_this.gMap);
  2084. }
  2085. _this.scope.$watch("show", function(newValue, oldValue) {
  2086. if (newValue !== oldValue) {
  2087. _this.doShow = newValue;
  2088. if (newValue) {
  2089. return _this.layer.setMap(_this.gMap);
  2090. } else {
  2091. return _this.layer.setMap(null);
  2092. }
  2093. }
  2094. }, true);
  2095. _this.scope.$watch("options", function(newValue, oldValue) {
  2096. if (newValue !== oldValue) {
  2097. _this.layer.setMap(null);
  2098. _this.layer = null;
  2099. return _this.createGoogleLayer();
  2100. }
  2101. }, true);
  2102. return _this.scope.$on("$destroy", function() {
  2103. return _this.layer.setMap(null);
  2104. });
  2105. });
  2106. }
  2107. LayerParentModel.prototype.createGoogleLayer = function() {
  2108. var _this = this;
  2109. if (this.attrs.options == null) {
  2110. this.layer = this.attrs.namespace === void 0 ? new google.maps[this.attrs.type]() : new google.maps[this.attrs.namespace][this.attrs.type]();
  2111. } else {
  2112. this.layer = this.attrs.namespace === void 0 ? new google.maps[this.attrs.type](this.scope.options) : new google.maps[this.attrs.namespace][this.attrs.type](this.scope.options);
  2113. }
  2114. return this.$timeout(function() {
  2115. var fn;
  2116. if ((_this.layer != null) && (_this.onLayerCreated != null)) {
  2117. fn = _this.onLayerCreated(_this.scope, _this.layer);
  2118. if (fn) {
  2119. return fn(_this.layer);
  2120. }
  2121. }
  2122. });
  2123. };
  2124. return LayerParentModel;
  2125. })(BaseObject);
  2126. return LayerParentModel;
  2127. }
  2128. ]);
  2129. }).call(this);
  2130. /*
  2131. Basic Directive api for a marker. Basic in the sense that this directive contains 1:1 on scope and model.
  2132. Thus there will be one html element per marker within the directive.
  2133. */
  2134. (function() {
  2135. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2136. __hasProp = {}.hasOwnProperty,
  2137. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2138. angular.module("google-maps.directives.api.models.parent").factory("MarkerParentModel", [
  2139. "IMarkerParentModel", "GmapUtil", "EventsHelper", function(IMarkerParentModel, GmapUtil, EventsHelper) {
  2140. var MarkerParentModel;
  2141. MarkerParentModel = (function(_super) {
  2142. __extends(MarkerParentModel, _super);
  2143. MarkerParentModel.include(GmapUtil);
  2144. MarkerParentModel.include(EventsHelper);
  2145. function MarkerParentModel(scope, element, attrs, mapCtrl, $timeout, gMarkerManager, doFit) {
  2146. var self;
  2147. this.gMarkerManager = gMarkerManager;
  2148. this.doFit = doFit;
  2149. this.onDestroy = __bind(this.onDestroy, this);
  2150. this.setGMarker = __bind(this.setGMarker, this);
  2151. this.onWatch = __bind(this.onWatch, this);
  2152. this.onTimeOut = __bind(this.onTimeOut, this);
  2153. MarkerParentModel.__super__.constructor.call(this, scope, element, attrs, mapCtrl, $timeout);
  2154. self = this;
  2155. }
  2156. MarkerParentModel.prototype.onTimeOut = function(scope) {
  2157. var opts,
  2158. _this = this;
  2159. opts = this.createMarkerOptions(scope.coords, scope.icon, scope.options, this.mapCtrl.getMap());
  2160. this.setGMarker(new google.maps.Marker(opts));
  2161. google.maps.event.addListener(this.scope.gMarker, 'click', function() {
  2162. if (_this.doClick && (scope.click != null)) {
  2163. return _this.$timeout(function() {
  2164. return _this.scope.click();
  2165. });
  2166. }
  2167. });
  2168. this.setEvents(this.scope.gMarker, scope, scope);
  2169. return this.$log.info(this);
  2170. };
  2171. MarkerParentModel.prototype.onWatch = function(propNameToWatch, scope) {
  2172. switch (propNameToWatch) {
  2173. case 'coords':
  2174. if (this.validateCoords(scope.coords) && (this.scope.gMarker != null)) {
  2175. this.scope.gMarker.setMap(this.mapCtrl.getMap());
  2176. this.scope.gMarker.setPosition(this.getCoords(scope.coords));
  2177. this.scope.gMarker.setVisible(this.validateCoords(scope.coords));
  2178. return this.scope.gMarker.setOptions(scope.options);
  2179. } else {
  2180. return this.scope.gMarker.setMap(null);
  2181. }
  2182. break;
  2183. case 'icon':
  2184. if ((scope.icon != null) && this.validateCoords(scope.coords) && (this.scope.gMarker != null)) {
  2185. this.scope.gMarker.setOptions(scope.options);
  2186. this.scope.gMarker.setIcon(scope.icon);
  2187. this.scope.gMarker.setMap(null);
  2188. this.scope.gMarker.setMap(this.mapCtrl.getMap());
  2189. this.scope.gMarker.setPosition(this.getCoords(scope.coords));
  2190. return this.scope.gMarker.setVisible(this.validateCoords(scope.coords));
  2191. }
  2192. break;
  2193. case 'options':
  2194. if (this.validateCoords(scope.coords) && (scope.icon != null) && scope.options) {
  2195. if (this.scope.gMarker != null) {
  2196. this.scope.gMarker.setMap(null);
  2197. }
  2198. return this.setGMarker(new google.maps.Marker(this.createMarkerOptions(scope.coords, scope.icon, scope.options, this.mapCtrl.getMap())));
  2199. }
  2200. }
  2201. };
  2202. MarkerParentModel.prototype.setGMarker = function(gMarker) {
  2203. if (this.scope.gMarker) {
  2204. delete this.scope.gMarker;
  2205. this.gMarkerManager.remove(this.scope.gMarker, false);
  2206. }
  2207. this.scope.gMarker = gMarker;
  2208. if (this.scope.gMarker) {
  2209. this.gMarkerManager.add(this.scope.gMarker, false);
  2210. if (this.doFit) {
  2211. return this.gMarkerManager.fit();
  2212. }
  2213. }
  2214. };
  2215. MarkerParentModel.prototype.onDestroy = function(scope) {
  2216. var self;
  2217. if (!this.scope.gMarker) {
  2218. self = void 0;
  2219. return;
  2220. }
  2221. this.scope.gMarker.setMap(null);
  2222. this.gMarkerManager.remove(this.scope.gMarker, false);
  2223. delete this.scope.gMarker;
  2224. return self = void 0;
  2225. };
  2226. return MarkerParentModel;
  2227. })(IMarkerParentModel);
  2228. return MarkerParentModel;
  2229. }
  2230. ]);
  2231. }).call(this);
  2232. (function() {
  2233. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2234. __hasProp = {}.hasOwnProperty,
  2235. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2236. angular.module("google-maps.directives.api.models.parent").factory("MarkersParentModel", [
  2237. "IMarkerParentModel", "ModelsWatcher", "PropMap", "MarkerChildModel", "ClustererMarkerManager", "MarkerManager", function(IMarkerParentModel, ModelsWatcher, PropMap, MarkerChildModel, ClustererMarkerManager, MarkerManager) {
  2238. var MarkersParentModel;
  2239. MarkersParentModel = (function(_super) {
  2240. __extends(MarkersParentModel, _super);
  2241. MarkersParentModel.include(ModelsWatcher);
  2242. function MarkersParentModel(scope, element, attrs, mapCtrl, $timeout) {
  2243. this.onDestroy = __bind(this.onDestroy, this);
  2244. this.newChildMarker = __bind(this.newChildMarker, this);
  2245. this.pieceMealMarkers = __bind(this.pieceMealMarkers, this);
  2246. this.reBuildMarkers = __bind(this.reBuildMarkers, this);
  2247. this.createMarkersFromScratch = __bind(this.createMarkersFromScratch, this);
  2248. this.validateScope = __bind(this.validateScope, this);
  2249. this.onWatch = __bind(this.onWatch, this);
  2250. this.onTimeOut = __bind(this.onTimeOut, this);
  2251. var self,
  2252. _this = this;
  2253. MarkersParentModel.__super__.constructor.call(this, scope, element, attrs, mapCtrl, $timeout);
  2254. self = this;
  2255. this.scope.markerModels = new PropMap();
  2256. this.$timeout = $timeout;
  2257. this.$log.info(this);
  2258. this.doRebuildAll = this.scope.doRebuildAll != null ? this.scope.doRebuildAll : true;
  2259. this.setIdKey(scope);
  2260. this.scope.$watch('doRebuildAll', function(newValue, oldValue) {
  2261. if (newValue !== oldValue) {
  2262. return _this.doRebuildAll = newValue;
  2263. }
  2264. });
  2265. }
  2266. MarkersParentModel.prototype.onTimeOut = function(scope) {
  2267. this.watch('models', scope);
  2268. this.watch('doCluster', scope);
  2269. this.watch('clusterOptions', scope);
  2270. this.watch('clusterEvents', scope);
  2271. this.watch('fit', scope);
  2272. this.watch('idKey', scope);
  2273. this.gMarkerManager = void 0;
  2274. return this.createMarkersFromScratch(scope);
  2275. };
  2276. MarkersParentModel.prototype.onWatch = function(propNameToWatch, scope, newValue, oldValue) {
  2277. if (propNameToWatch === "idKey" && newValue !== oldValue) {
  2278. this.idKey = newValue;
  2279. }
  2280. if (this.doRebuildAll) {
  2281. return this.reBuildMarkers(scope);
  2282. } else {
  2283. return this.pieceMealMarkers(scope);
  2284. }
  2285. };
  2286. MarkersParentModel.prototype.validateScope = function(scope) {
  2287. var modelsNotDefined;
  2288. modelsNotDefined = angular.isUndefined(scope.models) || scope.models === void 0;
  2289. if (modelsNotDefined) {
  2290. this.$log.error(this.constructor.name + ": no valid models attribute found");
  2291. }
  2292. return MarkersParentModel.__super__.validateScope.call(this, scope) || modelsNotDefined;
  2293. };
  2294. MarkersParentModel.prototype.createMarkersFromScratch = function(scope) {
  2295. var _this = this;
  2296. if (scope.doCluster) {
  2297. if (scope.clusterEvents) {
  2298. this.clusterInternalOptions = _.once(function() {
  2299. var self, _ref, _ref1, _ref2;
  2300. self = _this;
  2301. if (!_this.origClusterEvents) {
  2302. _this.origClusterEvents = {
  2303. click: (_ref = scope.clusterEvents) != null ? _ref.click : void 0,
  2304. mouseout: (_ref1 = scope.clusterEvents) != null ? _ref1.mouseout : void 0,
  2305. mouseover: (_ref2 = scope.clusterEvents) != null ? _ref2.mouseover : void 0
  2306. };
  2307. return _.extend(scope.clusterEvents, {
  2308. click: function(cluster) {
  2309. return self.maybeExecMappedEvent(cluster, "click");
  2310. },
  2311. mouseout: function(cluster) {
  2312. return self.maybeExecMappedEvent(cluster, "mouseout");
  2313. },
  2314. mouseover: function(cluster) {
  2315. return self.maybeExecMappedEvent(cluster, "mouseover");
  2316. }
  2317. });
  2318. }
  2319. })();
  2320. }
  2321. if (scope.clusterOptions || scope.clusterEvents) {
  2322. if (this.gMarkerManager === void 0) {
  2323. this.gMarkerManager = new ClustererMarkerManager(this.mapCtrl.getMap(), void 0, scope.clusterOptions, this.clusterInternalOptions);
  2324. } else {
  2325. if (this.gMarkerManager.opt_options !== scope.clusterOptions) {
  2326. this.gMarkerManager = new ClustererMarkerManager(this.mapCtrl.getMap(), void 0, scope.clusterOptions, this.clusterInternalOptions);
  2327. }
  2328. }
  2329. } else {
  2330. this.gMarkerManager = new ClustererMarkerManager(this.mapCtrl.getMap());
  2331. }
  2332. } else {
  2333. this.gMarkerManager = new MarkerManager(this.mapCtrl.getMap());
  2334. }
  2335. return _async.each(scope.models, function(model) {
  2336. return _this.newChildMarker(model, scope);
  2337. }, function() {
  2338. _this.gMarkerManager.draw();
  2339. if (scope.fit) {
  2340. return _this.gMarkerManager.fit();
  2341. }
  2342. });
  2343. };
  2344. MarkersParentModel.prototype.reBuildMarkers = function(scope) {
  2345. if (!scope.doRebuild && scope.doRebuild !== void 0) {
  2346. return;
  2347. }
  2348. this.onDestroy(scope);
  2349. return this.createMarkersFromScratch(scope);
  2350. };
  2351. MarkersParentModel.prototype.pieceMealMarkers = function(scope) {
  2352. var _this = this;
  2353. if ((this.scope.models != null) && this.scope.models.length > 0 && this.scope.markerModels.length > 0) {
  2354. return this.figureOutState(this.idKey, scope, this.scope.markerModels, this.modelKeyComparison, function(state) {
  2355. var payload;
  2356. payload = state;
  2357. return _async.each(payload.removals, function(child) {
  2358. if (child != null) {
  2359. child.destroy();
  2360. return _this.scope.markerModels.remove(child.id);
  2361. }
  2362. }, function() {
  2363. return _async.each(payload.adds, function(modelToAdd) {
  2364. return _this.newChildMarker(modelToAdd, scope);
  2365. }, function() {
  2366. _this.gMarkerManager.draw();
  2367. return scope.markerModels = _this.scope.markerModels;
  2368. });
  2369. });
  2370. });
  2371. } else {
  2372. return this.reBuildMarkers(scope);
  2373. }
  2374. };
  2375. MarkersParentModel.prototype.newChildMarker = function(model, scope) {
  2376. var child;
  2377. if (model[this.idKey] == null) {
  2378. this.$log.error("Marker model has no id to assign a child to. This is required for performance. Please assign id, or redirect id to a different key.");
  2379. return;
  2380. }
  2381. this.$log.info('child', child, 'markers', this.scope.markerModels);
  2382. child = new MarkerChildModel(model, scope, this.mapCtrl, this.$timeout, this.DEFAULTS, this.doClick, this.gMarkerManager, this.idKey);
  2383. this.scope.markerModels.put(model[this.idKey], child);
  2384. return child;
  2385. };
  2386. MarkersParentModel.prototype.onDestroy = function(scope) {
  2387. _.each(this.scope.markerModels.values(), function(model) {
  2388. if (model != null) {
  2389. return model.destroy();
  2390. }
  2391. });
  2392. delete this.scope.markerModels;
  2393. this.scope.markerModels = new PropMap();
  2394. if (this.gMarkerManager != null) {
  2395. return this.gMarkerManager.clear();
  2396. }
  2397. };
  2398. MarkersParentModel.prototype.maybeExecMappedEvent = function(cluster, fnName) {
  2399. var pair, _ref;
  2400. if (_.isFunction((_ref = this.scope.clusterEvents) != null ? _ref[fnName] : void 0)) {
  2401. pair = this.mapClusterToMarkerModels(cluster);
  2402. if (this.origClusterEvents[fnName]) {
  2403. return this.origClusterEvents[fnName](pair.cluster, pair.mapped);
  2404. }
  2405. }
  2406. };
  2407. MarkersParentModel.prototype.mapClusterToMarkerModels = function(cluster) {
  2408. var gMarkers, mapped,
  2409. _this = this;
  2410. gMarkers = cluster.getMarkers();
  2411. mapped = gMarkers.map(function(g) {
  2412. return _this.scope.markerModels[g.key].model;
  2413. });
  2414. return {
  2415. cluster: cluster,
  2416. mapped: mapped
  2417. };
  2418. };
  2419. return MarkersParentModel;
  2420. })(IMarkerParentModel);
  2421. return MarkersParentModel;
  2422. }
  2423. ]);
  2424. }).call(this);
  2425. /*
  2426. Windows directive where many windows map to the models property
  2427. */
  2428. (function() {
  2429. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2430. __hasProp = {}.hasOwnProperty,
  2431. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2432. angular.module("google-maps.directives.api.models.parent").factory("PolylinesParentModel", [
  2433. "$timeout", "Logger", "ModelKey", "ModelsWatcher", "PropMap", "PolylineChildModel", function($timeout, Logger, ModelKey, ModelsWatcher, PropMap, PolylineChildModel) {
  2434. var PolylinesParentModel;
  2435. return PolylinesParentModel = (function(_super) {
  2436. __extends(PolylinesParentModel, _super);
  2437. PolylinesParentModel.include(ModelsWatcher);
  2438. function PolylinesParentModel(scope, element, attrs, gMap, defaults) {
  2439. var self,
  2440. _this = this;
  2441. this.scope = scope;
  2442. this.element = element;
  2443. this.attrs = attrs;
  2444. this.gMap = gMap;
  2445. this.defaults = defaults;
  2446. this.modelKeyComparison = __bind(this.modelKeyComparison, this);
  2447. this.setChildScope = __bind(this.setChildScope, this);
  2448. this.createChild = __bind(this.createChild, this);
  2449. this.pieceMeal = __bind(this.pieceMeal, this);
  2450. this.createAllNew = __bind(this.createAllNew, this);
  2451. this.watchIdKey = __bind(this.watchIdKey, this);
  2452. this.createChildScopes = __bind(this.createChildScopes, this);
  2453. this.watchOurScope = __bind(this.watchOurScope, this);
  2454. this.watchDestroy = __bind(this.watchDestroy, this);
  2455. this.rebuildAll = __bind(this.rebuildAll, this);
  2456. this.doINeedToWipe = __bind(this.doINeedToWipe, this);
  2457. this.watchModels = __bind(this.watchModels, this);
  2458. this.watch = __bind(this.watch, this);
  2459. PolylinesParentModel.__super__.constructor.call(this, scope);
  2460. self = this;
  2461. this.$log = Logger;
  2462. this.plurals = new PropMap();
  2463. this.scopePropNames = ['path', 'stroke', 'clickable', 'draggable', 'editable', 'geodesic', 'icons', 'visible'];
  2464. _.each(this.scopePropNames, function(name) {
  2465. return _this[name + 'Key'] = void 0;
  2466. });
  2467. this.models = void 0;
  2468. this.firstTime = true;
  2469. this.$log.info(this);
  2470. $timeout(function() {
  2471. _this.watchOurScope(scope);
  2472. return _this.createChildScopes();
  2473. });
  2474. }
  2475. PolylinesParentModel.prototype.watch = function(scope, name, nameKey) {
  2476. var _this = this;
  2477. return scope.$watch(name, function(newValue, oldValue) {
  2478. if (newValue !== oldValue) {
  2479. _this[nameKey] = typeof newValue === 'function' ? newValue() : newValue;
  2480. return _async.each(_.values(_this.plurals), function(model) {
  2481. return model.scope[name] = _this[nameKey] === 'self' ? model : model[_this[nameKey]];
  2482. }, function() {});
  2483. }
  2484. });
  2485. };
  2486. PolylinesParentModel.prototype.watchModels = function(scope) {
  2487. var _this = this;
  2488. return scope.$watch('models', function(newValue, oldValue) {
  2489. if (!_.isEqual(newValue, oldValue)) {
  2490. if (_this.doINeedToWipe(newValue)) {
  2491. return _this.rebuildAll(scope, true, true);
  2492. } else {
  2493. return _this.createChildScopes(false);
  2494. }
  2495. }
  2496. }, true);
  2497. };
  2498. PolylinesParentModel.prototype.doINeedToWipe = function(newValue) {
  2499. var newValueIsEmpty;
  2500. newValueIsEmpty = newValue != null ? newValue.length === 0 : true;
  2501. return this.plurals.length > 0 && newValueIsEmpty;
  2502. };
  2503. PolylinesParentModel.prototype.rebuildAll = function(scope, doCreate, doDelete) {
  2504. var _this = this;
  2505. return _async.each(this.plurals.values(), function(model) {
  2506. return model.destroy();
  2507. }, function() {
  2508. if (doDelete) {
  2509. delete _this.plurals;
  2510. }
  2511. _this.plurals = new PropMap();
  2512. if (doCreate) {
  2513. return _this.createChildScopes();
  2514. }
  2515. });
  2516. };
  2517. PolylinesParentModel.prototype.watchDestroy = function(scope) {
  2518. var _this = this;
  2519. return scope.$on("$destroy", function() {
  2520. return _this.rebuildAll(scope, false, true);
  2521. });
  2522. };
  2523. PolylinesParentModel.prototype.watchOurScope = function(scope) {
  2524. var _this = this;
  2525. return _.each(this.scopePropNames, function(name) {
  2526. var nameKey;
  2527. nameKey = name + 'Key';
  2528. _this[nameKey] = typeof scope[name] === 'function' ? scope[name]() : scope[name];
  2529. return _this.watch(scope, name, nameKey);
  2530. });
  2531. };
  2532. PolylinesParentModel.prototype.createChildScopes = function(isCreatingFromScratch) {
  2533. if (isCreatingFromScratch == null) {
  2534. isCreatingFromScratch = true;
  2535. }
  2536. if (angular.isUndefined(this.scope.models)) {
  2537. this.$log.error("No models to create polylines from! I Need direct models!");
  2538. return;
  2539. }
  2540. if (this.gMap != null) {
  2541. if (this.scope.models != null) {
  2542. this.watchIdKey(this.scope);
  2543. if (isCreatingFromScratch) {
  2544. return this.createAllNew(this.scope, false);
  2545. } else {
  2546. return this.pieceMeal(this.scope, false);
  2547. }
  2548. }
  2549. }
  2550. };
  2551. PolylinesParentModel.prototype.watchIdKey = function(scope) {
  2552. var _this = this;
  2553. this.setIdKey(scope);
  2554. return scope.$watch('idKey', function(newValue, oldValue) {
  2555. if (newValue !== oldValue && (newValue == null)) {
  2556. _this.idKey = newValue;
  2557. return _this.rebuildAll(scope, true, true);
  2558. }
  2559. });
  2560. };
  2561. PolylinesParentModel.prototype.createAllNew = function(scope, isArray) {
  2562. var _this = this;
  2563. if (isArray == null) {
  2564. isArray = false;
  2565. }
  2566. this.models = scope.models;
  2567. if (this.firstTime) {
  2568. this.watchModels(scope);
  2569. this.watchDestroy(scope);
  2570. }
  2571. return _async.each(scope.models, function(model) {
  2572. return _this.createChild(model, _this.gMap);
  2573. }, function() {
  2574. return _this.firstTime = false;
  2575. });
  2576. };
  2577. PolylinesParentModel.prototype.pieceMeal = function(scope, isArray) {
  2578. var _this = this;
  2579. if (isArray == null) {
  2580. isArray = true;
  2581. }
  2582. this.models = scope.models;
  2583. if ((scope != null) && (scope.models != null) && scope.models.length > 0 && this.plurals.length > 0) {
  2584. return this.figureOutState(this.idKey, scope, this.plurals, this.modelKeyComparison, function(state) {
  2585. var payload;
  2586. payload = state;
  2587. return _async.each(payload.removals, function(id) {
  2588. var child;
  2589. child = _this.plurals[id];
  2590. if (child != null) {
  2591. child.destroy();
  2592. return _this.plurals.remove(id);
  2593. }
  2594. }, function() {
  2595. return _async.each(payload.adds, function(modelToAdd) {
  2596. return _this.createChild(modelToAdd, _this.gMap);
  2597. }, function() {});
  2598. });
  2599. });
  2600. } else {
  2601. return this.rebuildAll(this.scope, true, true);
  2602. }
  2603. };
  2604. PolylinesParentModel.prototype.createChild = function(model, gMap) {
  2605. var child, childScope,
  2606. _this = this;
  2607. childScope = this.scope.$new(false);
  2608. this.setChildScope(childScope, model);
  2609. childScope.$watch('model', function(newValue, oldValue) {
  2610. if (newValue !== oldValue) {
  2611. return _this.setChildScope(childScope, newValue);
  2612. }
  2613. }, true);
  2614. childScope["static"] = this.scope["static"];
  2615. child = new PolylineChildModel(childScope, this.attrs, gMap, this.defaults, model);
  2616. if (model[this.idKey] == null) {
  2617. this.$log.error("Polyline model has no id to assign a child to. This is required for performance. Please assign id, or redirect id to a different key.");
  2618. return;
  2619. }
  2620. this.plurals.put(model[this.idKey], child);
  2621. return child;
  2622. };
  2623. PolylinesParentModel.prototype.setChildScope = function(childScope, model) {
  2624. var _this = this;
  2625. _.each(this.scopePropNames, function(name) {
  2626. var nameKey, newValue;
  2627. nameKey = name + 'Key';
  2628. newValue = _this[nameKey] === 'self' ? model : model[_this[nameKey]];
  2629. if (newValue !== childScope[name]) {
  2630. return childScope[name] = newValue;
  2631. }
  2632. });
  2633. return childScope.model = model;
  2634. };
  2635. PolylinesParentModel.prototype.modelKeyComparison = function(model1, model2) {
  2636. return _.isEqual(this.evalModelHandle(model1, this.scope.path), this.evalModelHandle(model2, this.scope.path));
  2637. };
  2638. return PolylinesParentModel;
  2639. })(ModelKey);
  2640. }
  2641. ]);
  2642. }).call(this);
  2643. /*
  2644. Windows directive where many windows map to the models property
  2645. */
  2646. (function() {
  2647. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2648. __hasProp = {}.hasOwnProperty,
  2649. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2650. angular.module("google-maps.directives.api.models.parent").factory("WindowsParentModel", [
  2651. "IWindowParentModel", "ModelsWatcher", "PropMap", "WindowChildModel", "Linked", function(IWindowParentModel, ModelsWatcher, PropMap, WindowChildModel, Linked) {
  2652. var WindowsParentModel;
  2653. WindowsParentModel = (function(_super) {
  2654. __extends(WindowsParentModel, _super);
  2655. WindowsParentModel.include(ModelsWatcher);
  2656. function WindowsParentModel(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache, $interpolate) {
  2657. var self,
  2658. _this = this;
  2659. this.$interpolate = $interpolate;
  2660. this.interpolateContent = __bind(this.interpolateContent, this);
  2661. this.setChildScope = __bind(this.setChildScope, this);
  2662. this.createWindow = __bind(this.createWindow, this);
  2663. this.setContentKeys = __bind(this.setContentKeys, this);
  2664. this.pieceMealWindows = __bind(this.pieceMealWindows, this);
  2665. this.createAllNewWindows = __bind(this.createAllNewWindows, this);
  2666. this.watchIdKey = __bind(this.watchIdKey, this);
  2667. this.createChildScopesWindows = __bind(this.createChildScopesWindows, this);
  2668. this.watchOurScope = __bind(this.watchOurScope, this);
  2669. this.watchDestroy = __bind(this.watchDestroy, this);
  2670. this.rebuildAll = __bind(this.rebuildAll, this);
  2671. this.doINeedToWipe = __bind(this.doINeedToWipe, this);
  2672. this.watchModels = __bind(this.watchModels, this);
  2673. this.watch = __bind(this.watch, this);
  2674. WindowsParentModel.__super__.constructor.call(this, scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache);
  2675. self = this;
  2676. this.windows = new PropMap();
  2677. this.scopePropNames = ['show', 'coords', 'templateUrl', 'templateParameter', 'isIconVisibleOnClick', 'closeClick'];
  2678. _.each(this.scopePropNames, function(name) {
  2679. return _this[name + 'Key'] = void 0;
  2680. });
  2681. this.linked = new Linked(scope, element, attrs, ctrls);
  2682. this.models = void 0;
  2683. this.contentKeys = void 0;
  2684. this.isIconVisibleOnClick = void 0;
  2685. this.firstTime = true;
  2686. this.$log.info(self);
  2687. this.parentScope = void 0;
  2688. this.$timeout(function() {
  2689. _this.watchOurScope(scope);
  2690. _this.doRebuildAll = _this.scope.doRebuildAll != null ? _this.scope.doRebuildAll : true;
  2691. scope.$watch('doRebuildAll', function(newValue, oldValue) {
  2692. if (newValue !== oldValue) {
  2693. return _this.doRebuildAll = newValue;
  2694. }
  2695. });
  2696. return _this.createChildScopesWindows();
  2697. }, 50);
  2698. }
  2699. WindowsParentModel.prototype.watch = function(scope, name, nameKey) {
  2700. var _this = this;
  2701. return scope.$watch(name, function(newValue, oldValue) {
  2702. if (newValue !== oldValue) {
  2703. _this[nameKey] = typeof newValue === 'function' ? newValue() : newValue;
  2704. return _async.each(_.values(_this.windows), function(model) {
  2705. return model.scope[name] = _this[nameKey] === 'self' ? model : model[_this[nameKey]];
  2706. }, function() {});
  2707. }
  2708. });
  2709. };
  2710. WindowsParentModel.prototype.watchModels = function(scope) {
  2711. var _this = this;
  2712. return scope.$watch('models', function(newValue, oldValue) {
  2713. if (!_.isEqual(newValue, oldValue)) {
  2714. if (_this.doRebuildAll || _this.doINeedToWipe(newValue)) {
  2715. return _this.rebuildAll(scope, true, true);
  2716. } else {
  2717. return _this.createChildScopesWindows(false);
  2718. }
  2719. }
  2720. });
  2721. };
  2722. WindowsParentModel.prototype.doINeedToWipe = function(newValue) {
  2723. var newValueIsEmpty;
  2724. newValueIsEmpty = newValue != null ? newValue.length === 0 : true;
  2725. return this.windows.length > 0 && newValueIsEmpty;
  2726. };
  2727. WindowsParentModel.prototype.rebuildAll = function(scope, doCreate, doDelete) {
  2728. var _this = this;
  2729. return _async.each(this.windows.values(), function(model) {
  2730. return model.destroy();
  2731. }, function() {
  2732. if (doDelete) {
  2733. delete _this.windows;
  2734. }
  2735. _this.windows = new PropMap();
  2736. if (doCreate) {
  2737. return _this.createChildScopesWindows();
  2738. }
  2739. });
  2740. };
  2741. WindowsParentModel.prototype.watchDestroy = function(scope) {
  2742. var _this = this;
  2743. return scope.$on("$destroy", function() {
  2744. return _this.rebuildAll(scope, false, true);
  2745. });
  2746. };
  2747. WindowsParentModel.prototype.watchOurScope = function(scope) {
  2748. var _this = this;
  2749. return _.each(this.scopePropNames, function(name) {
  2750. var nameKey;
  2751. nameKey = name + 'Key';
  2752. _this[nameKey] = typeof scope[name] === 'function' ? scope[name]() : scope[name];
  2753. return _this.watch(scope, name, nameKey);
  2754. });
  2755. };
  2756. WindowsParentModel.prototype.createChildScopesWindows = function(isCreatingFromScratch) {
  2757. var markersScope, modelsNotDefined;
  2758. if (isCreatingFromScratch == null) {
  2759. isCreatingFromScratch = true;
  2760. }
  2761. /*
  2762. being that we cannot tell the difference in Key String vs. a normal value string (TemplateUrl)
  2763. we will assume that all scope values are string expressions either pointing to a key (propName) or using
  2764. 'self' to point the model as container/object of interest.
  2765. This may force redundant information into the model, but this appears to be the most flexible approach.
  2766. */
  2767. this.isIconVisibleOnClick = true;
  2768. if (angular.isDefined(this.linked.attrs.isiconvisibleonclick)) {
  2769. this.isIconVisibleOnClick = this.linked.scope.isIconVisibleOnClick;
  2770. }
  2771. this.gMap = this.linked.ctrls[0].getMap();
  2772. if (this.linked.ctrls[1] != null) {
  2773. markersScope = this.linked.ctrls.length > 1 ? this.linked.ctrls[1].getMarkersScope() : void 0;
  2774. }
  2775. modelsNotDefined = angular.isUndefined(this.linked.scope.models);
  2776. if (modelsNotDefined && (markersScope === void 0 || (markersScope.markerModels === void 0 || markersScope.models === void 0))) {
  2777. this.$log.error("No models to create windows from! Need direct models or models derrived from markers!");
  2778. return;
  2779. }
  2780. if (this.gMap != null) {
  2781. if (this.linked.scope.models != null) {
  2782. this.watchIdKey(this.linked.scope);
  2783. if (isCreatingFromScratch) {
  2784. return this.createAllNewWindows(this.linked.scope, false);
  2785. } else {
  2786. return this.pieceMealWindows(this.linked.scope, false);
  2787. }
  2788. } else {
  2789. this.parentScope = markersScope;
  2790. this.watchIdKey(this.parentScope);
  2791. if (isCreatingFromScratch) {
  2792. return this.createAllNewWindows(markersScope, true, 'markerModels', false);
  2793. } else {
  2794. return this.pieceMealWindows(markersScope, true, 'markerModels', false);
  2795. }
  2796. }
  2797. }
  2798. };
  2799. WindowsParentModel.prototype.watchIdKey = function(scope) {
  2800. var _this = this;
  2801. this.setIdKey(scope);
  2802. return scope.$watch('idKey', function(newValue, oldValue) {
  2803. if (newValue !== oldValue && (newValue == null)) {
  2804. _this.idKey = newValue;
  2805. return _this.rebuildAll(scope, true, true);
  2806. }
  2807. });
  2808. };
  2809. WindowsParentModel.prototype.createAllNewWindows = function(scope, hasGMarker, modelsPropToIterate, isArray) {
  2810. var _this = this;
  2811. if (modelsPropToIterate == null) {
  2812. modelsPropToIterate = 'models';
  2813. }
  2814. if (isArray == null) {
  2815. isArray = false;
  2816. }
  2817. this.models = scope.models;
  2818. if (this.firstTime) {
  2819. this.watchModels(scope);
  2820. this.watchDestroy(scope);
  2821. }
  2822. this.setContentKeys(scope.models);
  2823. return _async.each(scope.models, function(model) {
  2824. var gMarker;
  2825. gMarker = hasGMarker ? scope[modelsPropToIterate][[model[_this.idKey]]].gMarker : void 0;
  2826. return _this.createWindow(model, gMarker, _this.gMap);
  2827. }, function() {
  2828. return _this.firstTime = false;
  2829. });
  2830. };
  2831. WindowsParentModel.prototype.pieceMealWindows = function(scope, hasGMarker, modelsPropToIterate, isArray) {
  2832. var _this = this;
  2833. if (modelsPropToIterate == null) {
  2834. modelsPropToIterate = 'models';
  2835. }
  2836. if (isArray == null) {
  2837. isArray = true;
  2838. }
  2839. this.models = scope.models;
  2840. if ((scope != null) && (scope.models != null) && scope.models.length > 0 && this.windows.length > 0) {
  2841. return this.figureOutState(this.idKey, scope, this.windows, this.modelKeyComparison, function(state) {
  2842. var payload;
  2843. payload = state;
  2844. return _async.each(payload.removals, function(child) {
  2845. if (child != null) {
  2846. child.destroy();
  2847. return _this.windows.remove(child.id);
  2848. }
  2849. }, function() {
  2850. return _async.each(payload.adds, function(modelToAdd) {
  2851. var gMarker;
  2852. gMarker = scope[modelsPropToIterate][modelToAdd[_this.idKey]].gMarker;
  2853. return _this.createWindow(modelToAdd, gMarker, _this.gMap);
  2854. }, function() {});
  2855. });
  2856. });
  2857. } else {
  2858. return this.rebuildAll(this.scope, true, true);
  2859. }
  2860. };
  2861. WindowsParentModel.prototype.setContentKeys = function(models) {
  2862. if (models.length > 0) {
  2863. return this.contentKeys = Object.keys(models[0]);
  2864. }
  2865. };
  2866. WindowsParentModel.prototype.createWindow = function(model, gMarker, gMap) {
  2867. var child, childScope, fakeElement, opts,
  2868. _this = this;
  2869. childScope = this.linked.scope.$new(false);
  2870. this.setChildScope(childScope, model);
  2871. childScope.$watch('model', function(newValue, oldValue) {
  2872. if (newValue !== oldValue) {
  2873. return _this.setChildScope(childScope, newValue);
  2874. }
  2875. }, true);
  2876. fakeElement = {
  2877. html: function() {
  2878. return _this.interpolateContent(_this.linked.element.html(), model);
  2879. }
  2880. };
  2881. opts = this.createWindowOptions(gMarker, childScope, fakeElement.html(), this.DEFAULTS);
  2882. child = new WindowChildModel(model, childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, fakeElement, true, true);
  2883. if (model[this.idKey] == null) {
  2884. this.$log.error("Window model has no id to assign a child to. This is required for performance. Please assign id, or redirect id to a different key.");
  2885. return;
  2886. }
  2887. this.windows.put(model[this.idKey], child);
  2888. return child;
  2889. };
  2890. WindowsParentModel.prototype.setChildScope = function(childScope, model) {
  2891. var _this = this;
  2892. _.each(this.scopePropNames, function(name) {
  2893. var nameKey, newValue;
  2894. nameKey = name + 'Key';
  2895. newValue = _this[nameKey] === 'self' ? model : model[_this[nameKey]];
  2896. if (newValue !== childScope[name]) {
  2897. return childScope[name] = newValue;
  2898. }
  2899. });
  2900. return childScope.model = model;
  2901. };
  2902. WindowsParentModel.prototype.interpolateContent = function(content, model) {
  2903. var exp, interpModel, key, _i, _len, _ref;
  2904. if (this.contentKeys === void 0 || this.contentKeys.length === 0) {
  2905. return;
  2906. }
  2907. exp = this.$interpolate(content);
  2908. interpModel = {};
  2909. _ref = this.contentKeys;
  2910. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  2911. key = _ref[_i];
  2912. interpModel[key] = model[key];
  2913. }
  2914. return exp(interpModel);
  2915. };
  2916. return WindowsParentModel;
  2917. })(IWindowParentModel);
  2918. return WindowsParentModel;
  2919. }
  2920. ]);
  2921. }).call(this);
  2922. /*
  2923. - interface for all labels to derrive from
  2924. - to enforce a minimum set of requirements
  2925. - attributes
  2926. - content
  2927. - anchor
  2928. - implementation needed on watches
  2929. */
  2930. (function() {
  2931. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2932. __hasProp = {}.hasOwnProperty,
  2933. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2934. angular.module("google-maps.directives.api").factory("ILabel", [
  2935. "BaseObject", "Logger", function(BaseObject, Logger) {
  2936. var ILabel;
  2937. return ILabel = (function(_super) {
  2938. __extends(ILabel, _super);
  2939. function ILabel($timeout) {
  2940. this.link = __bind(this.link, this);
  2941. var self;
  2942. self = this;
  2943. this.restrict = 'ECMA';
  2944. this.replace = true;
  2945. this.template = void 0;
  2946. this.require = void 0;
  2947. this.transclude = true;
  2948. this.priority = -100;
  2949. this.scope = {
  2950. labelContent: '=content',
  2951. labelAnchor: '@anchor',
  2952. labelClass: '@class',
  2953. labelStyle: '=style'
  2954. };
  2955. this.$log = Logger;
  2956. this.$timeout = $timeout;
  2957. }
  2958. ILabel.prototype.link = function(scope, element, attrs, ctrl) {
  2959. throw new Exception("Not Implemented!!");
  2960. };
  2961. return ILabel;
  2962. })(BaseObject);
  2963. }
  2964. ]);
  2965. }).call(this);
  2966. /*
  2967. - interface for all markers to derrive from
  2968. - to enforce a minimum set of requirements
  2969. - attributes
  2970. - coords
  2971. - icon
  2972. - implementation needed on watches
  2973. */
  2974. (function() {
  2975. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2976. __hasProp = {}.hasOwnProperty,
  2977. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  2978. angular.module("google-maps.directives.api").factory("IMarker", [
  2979. "Logger", "BaseObject", function(Logger, BaseObject) {
  2980. var IMarker;
  2981. return IMarker = (function(_super) {
  2982. __extends(IMarker, _super);
  2983. function IMarker($timeout) {
  2984. this.link = __bind(this.link, this);
  2985. var self;
  2986. self = this;
  2987. this.$log = Logger;
  2988. this.$timeout = $timeout;
  2989. this.restrict = 'ECMA';
  2990. this.require = '^googleMap';
  2991. this.priority = -1;
  2992. this.transclude = true;
  2993. this.replace = true;
  2994. this.scope = {
  2995. coords: '=coords',
  2996. icon: '=icon',
  2997. click: '&click',
  2998. options: '=options',
  2999. events: '=events',
  3000. fit: '=fit'
  3001. };
  3002. }
  3003. IMarker.prototype.controller = [
  3004. '$scope', '$element', function($scope, $element) {
  3005. throw new Exception("Not Implemented!!");
  3006. }
  3007. ];
  3008. IMarker.prototype.link = function(scope, element, attrs, ctrl) {
  3009. throw new Exception("Not implemented!!");
  3010. };
  3011. return IMarker;
  3012. })(BaseObject);
  3013. }
  3014. ]);
  3015. }).call(this);
  3016. (function() {
  3017. var __hasProp = {}.hasOwnProperty,
  3018. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3019. angular.module("google-maps.directives.api").factory("IPolyline", [
  3020. "GmapUtil", "BaseObject", "Logger", function(GmapUtil, BaseObject, Logger) {
  3021. var IPolyline;
  3022. return IPolyline = (function(_super) {
  3023. __extends(IPolyline, _super);
  3024. IPolyline.include(GmapUtil);
  3025. function IPolyline() {
  3026. var self;
  3027. self = this;
  3028. }
  3029. IPolyline.prototype.restrict = "ECA";
  3030. IPolyline.prototype.replace = true;
  3031. IPolyline.prototype.require = "^googleMap";
  3032. IPolyline.prototype.scope = {
  3033. path: "=",
  3034. stroke: "=",
  3035. clickable: "=",
  3036. draggable: "=",
  3037. editable: "=",
  3038. geodesic: "=",
  3039. icons: "=",
  3040. visible: "=",
  3041. "static": "=",
  3042. fit: "="
  3043. };
  3044. IPolyline.prototype.DEFAULTS = {};
  3045. IPolyline.prototype.$log = Logger;
  3046. return IPolyline;
  3047. })(BaseObject);
  3048. }
  3049. ]);
  3050. }).call(this);
  3051. /*
  3052. - interface directive for all window(s) to derrive from
  3053. */
  3054. (function() {
  3055. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3056. __hasProp = {}.hasOwnProperty,
  3057. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3058. angular.module("google-maps.directives.api").factory("IWindow", [
  3059. "BaseObject", "ChildEvents", "Logger", function(BaseObject, ChildEvents, Logger) {
  3060. var IWindow;
  3061. return IWindow = (function(_super) {
  3062. __extends(IWindow, _super);
  3063. IWindow.include(ChildEvents);
  3064. function IWindow($timeout, $compile, $http, $templateCache) {
  3065. var self;
  3066. this.$timeout = $timeout;
  3067. this.$compile = $compile;
  3068. this.$http = $http;
  3069. this.$templateCache = $templateCache;
  3070. this.link = __bind(this.link, this);
  3071. self = this;
  3072. this.restrict = 'ECMA';
  3073. this.template = void 0;
  3074. this.transclude = true;
  3075. this.priority = -100;
  3076. this.require = void 0;
  3077. this.replace = true;
  3078. this.scope = {
  3079. coords: '=coords',
  3080. show: '=show',
  3081. templateUrl: '=templateurl',
  3082. templateParameter: '=templateparameter',
  3083. isIconVisibleOnClick: '=isiconvisibleonclick',
  3084. closeClick: '&closeclick',
  3085. options: '=options'
  3086. };
  3087. this.$log = Logger;
  3088. }
  3089. IWindow.prototype.link = function(scope, element, attrs, ctrls) {
  3090. throw new Exception("Not Implemented!!");
  3091. };
  3092. return IWindow;
  3093. })(BaseObject);
  3094. }
  3095. ]);
  3096. }).call(this);
  3097. (function() {
  3098. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3099. __hasProp = {}.hasOwnProperty,
  3100. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3101. angular.module("google-maps.directives.api").factory("Map", [
  3102. "$timeout", "Logger", "GmapUtil", "BaseObject", function($timeout, Logger, GmapUtil, BaseObject) {
  3103. "use strict";
  3104. var $log, DEFAULTS, Map;
  3105. $log = Logger;
  3106. DEFAULTS = {
  3107. mapTypeId: google.maps.MapTypeId.ROADMAP
  3108. };
  3109. return Map = (function(_super) {
  3110. __extends(Map, _super);
  3111. Map.include(GmapUtil);
  3112. function Map() {
  3113. this.link = __bind(this.link, this);
  3114. var self;
  3115. self = this;
  3116. }
  3117. Map.prototype.restrict = "ECMA";
  3118. Map.prototype.transclude = true;
  3119. Map.prototype.replace = false;
  3120. Map.prototype.template = "<div class=\"angular-google-map\"><div class=\"angular-google-map-container\"></div><div ng-transclude style=\"display: none\"></div></div>";
  3121. Map.prototype.scope = {
  3122. center: "=center",
  3123. zoom: "=zoom",
  3124. dragging: "=dragging",
  3125. control: "=",
  3126. windows: "=windows",
  3127. options: "=options",
  3128. events: "=events",
  3129. styles: "=styles",
  3130. bounds: "=bounds"
  3131. };
  3132. Map.prototype.controller = [
  3133. "$scope", function($scope) {
  3134. return {
  3135. getMap: function() {
  3136. return $scope.map;
  3137. }
  3138. };
  3139. }
  3140. ];
  3141. /*
  3142. @param scope
  3143. @param element
  3144. @param attrs
  3145. */
  3146. Map.prototype.link = function(scope, element, attrs) {
  3147. var dragging, el, eventName, getEventHandler, opts, settingCenterFromScope, type, _m,
  3148. _this = this;
  3149. if (!this.validateCoords(scope.center)) {
  3150. $log.error("angular-google-maps: could not find a valid center property");
  3151. return;
  3152. }
  3153. if (!angular.isDefined(scope.zoom)) {
  3154. $log.error("angular-google-maps: map zoom property not set");
  3155. return;
  3156. }
  3157. el = angular.element(element);
  3158. el.addClass("angular-google-map");
  3159. opts = {
  3160. options: {}
  3161. };
  3162. if (attrs.options) {
  3163. opts.options = scope.options;
  3164. }
  3165. if (attrs.styles) {
  3166. opts.styles = scope.styles;
  3167. }
  3168. if (attrs.type) {
  3169. type = attrs.type.toUpperCase();
  3170. if (google.maps.MapTypeId.hasOwnProperty(type)) {
  3171. opts.mapTypeId = google.maps.MapTypeId[attrs.type.toUpperCase()];
  3172. } else {
  3173. $log.error("angular-google-maps: invalid map type \"" + attrs.type + "\"");
  3174. }
  3175. }
  3176. _m = new google.maps.Map(el.find("div")[1], angular.extend({}, DEFAULTS, opts, {
  3177. center: this.getCoords(scope.center),
  3178. draggable: this.isTrue(attrs.draggable),
  3179. zoom: scope.zoom,
  3180. bounds: scope.bounds
  3181. }));
  3182. dragging = false;
  3183. google.maps.event.addListener(_m, "dragstart", function() {
  3184. dragging = true;
  3185. return _.defer(function() {
  3186. return scope.$apply(function(s) {
  3187. if (s.dragging != null) {
  3188. return s.dragging = dragging;
  3189. }
  3190. });
  3191. });
  3192. });
  3193. google.maps.event.addListener(_m, "dragend", function() {
  3194. dragging = false;
  3195. return _.defer(function() {
  3196. return scope.$apply(function(s) {
  3197. if (s.dragging != null) {
  3198. return s.dragging = dragging;
  3199. }
  3200. });
  3201. });
  3202. });
  3203. google.maps.event.addListener(_m, "drag", function() {
  3204. var c;
  3205. c = _m.center;
  3206. return _.defer(function() {
  3207. return scope.$apply(function(s) {
  3208. if (angular.isDefined(s.center.type)) {
  3209. s.center.coordinates[1] = c.lat();
  3210. return s.center.coordinates[0] = c.lng();
  3211. } else {
  3212. s.center.latitude = c.lat();
  3213. return s.center.longitude = c.lng();
  3214. }
  3215. });
  3216. });
  3217. });
  3218. google.maps.event.addListener(_m, "zoom_changed", function() {
  3219. if (scope.zoom !== _m.zoom) {
  3220. return _.defer(function() {
  3221. return scope.$apply(function(s) {
  3222. return s.zoom = _m.zoom;
  3223. });
  3224. });
  3225. }
  3226. });
  3227. settingCenterFromScope = false;
  3228. google.maps.event.addListener(_m, "center_changed", function() {
  3229. var c;
  3230. c = _m.center;
  3231. if (settingCenterFromScope) {
  3232. return;
  3233. }
  3234. return _.defer(function() {
  3235. return scope.$apply(function(s) {
  3236. if (!_m.dragging) {
  3237. if (angular.isDefined(s.center.type)) {
  3238. if (s.center.coordinates[1] !== c.lat()) {
  3239. s.center.coordinates[1] = c.lat();
  3240. }
  3241. if (s.center.coordinates[0] !== c.lng()) {
  3242. return s.center.coordinates[0] = c.lng();
  3243. }
  3244. } else {
  3245. if (s.center.latitude !== c.lat()) {
  3246. s.center.latitude = c.lat();
  3247. }
  3248. if (s.center.longitude !== c.lng()) {
  3249. return s.center.longitude = c.lng();
  3250. }
  3251. }
  3252. }
  3253. });
  3254. });
  3255. });
  3256. google.maps.event.addListener(_m, "idle", function() {
  3257. var b, ne, sw;
  3258. b = _m.getBounds();
  3259. ne = b.getNorthEast();
  3260. sw = b.getSouthWest();
  3261. return _.defer(function() {
  3262. return scope.$apply(function(s) {
  3263. if (s.bounds !== null && s.bounds !== undefined && s.bounds !== void 0) {
  3264. s.bounds.northeast = {
  3265. latitude: ne.lat(),
  3266. longitude: ne.lng()
  3267. };
  3268. return s.bounds.southwest = {
  3269. latitude: sw.lat(),
  3270. longitude: sw.lng()
  3271. };
  3272. }
  3273. });
  3274. });
  3275. });
  3276. if (angular.isDefined(scope.events) && scope.events !== null && angular.isObject(scope.events)) {
  3277. getEventHandler = function(eventName) {
  3278. return function() {
  3279. return scope.events[eventName].apply(scope, [_m, eventName, arguments]);
  3280. };
  3281. };
  3282. for (eventName in scope.events) {
  3283. if (scope.events.hasOwnProperty(eventName) && angular.isFunction(scope.events[eventName])) {
  3284. google.maps.event.addListener(_m, eventName, getEventHandler(eventName));
  3285. }
  3286. }
  3287. }
  3288. scope.map = _m;
  3289. if ((attrs.control != null) && (scope.control != null)) {
  3290. scope.control.refresh = function(maybeCoords) {
  3291. var coords;
  3292. if (_m == null) {
  3293. return;
  3294. }
  3295. google.maps.event.trigger(_m, "resize");
  3296. if (((maybeCoords != null ? maybeCoords.latitude : void 0) != null) && ((maybeCoords != null ? maybeCoords.latitude : void 0) != null)) {
  3297. coords = _this.getCoords(maybeCoords);
  3298. if (_this.isTrue(attrs.pan)) {
  3299. return _m.panTo(coords);
  3300. } else {
  3301. return _m.setCenter(coords);
  3302. }
  3303. }
  3304. };
  3305. /*
  3306. I am sure you all will love this. You want the instance here you go.. BOOM!
  3307. */
  3308. scope.control.getGMap = function() {
  3309. return _m;
  3310. };
  3311. }
  3312. scope.$watch("center", (function(newValue, oldValue) {
  3313. var coords;
  3314. coords = _this.getCoords(newValue);
  3315. if (coords.lat() === _m.center.lat() && coords.lng() === _m.center.lng()) {
  3316. return;
  3317. }
  3318. settingCenterFromScope = true;
  3319. if (!dragging) {
  3320. if (!_this.validateCoords(newValue)) {
  3321. $log.error("Invalid center for newValue: " + (JSON.stringify(newValue)));
  3322. }
  3323. if (_this.isTrue(attrs.pan) && scope.zoom === _m.zoom) {
  3324. _m.panTo(coords);
  3325. } else {
  3326. _m.setCenter(coords);
  3327. }
  3328. }
  3329. return settingCenterFromScope = false;
  3330. }), true);
  3331. scope.$watch("zoom", function(newValue, oldValue) {
  3332. if (newValue === _m.zoom) {
  3333. return;
  3334. }
  3335. return _.defer(function() {
  3336. return _m.setZoom(newValue);
  3337. });
  3338. });
  3339. scope.$watch("bounds", function(newValue, oldValue) {
  3340. var bounds, ne, sw;
  3341. if (newValue === oldValue) {
  3342. return;
  3343. }
  3344. if ((newValue.northeast.latitude == null) || (newValue.northeast.longitude == null) || (newValue.southwest.latitude == null) || (newValue.southwest.longitude == null)) {
  3345. $log.error("Invalid map bounds for new value: " + (JSON.stringify(newValue)));
  3346. return;
  3347. }
  3348. ne = new google.maps.LatLng(newValue.northeast.latitude, newValue.northeast.longitude);
  3349. sw = new google.maps.LatLng(newValue.southwest.latitude, newValue.southwest.longitude);
  3350. bounds = new google.maps.LatLngBounds(sw, ne);
  3351. return _m.fitBounds(bounds);
  3352. });
  3353. scope.$watch("options", function(newValue, oldValue) {
  3354. if (!_.isEqual(newValue, oldValue)) {
  3355. opts.options = newValue;
  3356. if (_m != null) {
  3357. return _m.setOptions(opts);
  3358. }
  3359. }
  3360. }, true);
  3361. return scope.$watch("styles", function(newValue, oldValue) {
  3362. if (!_.isEqual(newValue, oldValue)) {
  3363. opts.styles = newValue;
  3364. if (_m != null) {
  3365. return _m.setOptions(opts);
  3366. }
  3367. }
  3368. }, true);
  3369. };
  3370. return Map;
  3371. })(BaseObject);
  3372. }
  3373. ]);
  3374. }).call(this);
  3375. (function() {
  3376. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3377. __hasProp = {}.hasOwnProperty,
  3378. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3379. angular.module("google-maps.directives.api").factory("Marker", [
  3380. "IMarker", "MarkerParentModel", "MarkerManager", function(IMarker, MarkerParentModel, MarkerManager) {
  3381. var Marker;
  3382. return Marker = (function(_super) {
  3383. __extends(Marker, _super);
  3384. function Marker($timeout) {
  3385. this.link = __bind(this.link, this);
  3386. var self;
  3387. Marker.__super__.constructor.call(this, $timeout);
  3388. self = this;
  3389. this.template = '<span class="angular-google-map-marker" ng-transclude></span>';
  3390. this.$log.info(this);
  3391. }
  3392. Marker.prototype.controller = [
  3393. '$scope', '$element', function($scope, $element) {
  3394. return {
  3395. getMarkerScope: function() {
  3396. return $scope;
  3397. }
  3398. };
  3399. }
  3400. ];
  3401. Marker.prototype.link = function(scope, element, attrs, ctrl) {
  3402. var doFit;
  3403. if (scope.fit) {
  3404. doFit = true;
  3405. }
  3406. if (!this.gMarkerManager) {
  3407. this.gMarkerManager = new MarkerManager(ctrl.getMap());
  3408. }
  3409. return new MarkerParentModel(scope, element, attrs, ctrl, this.$timeout, this.gMarkerManager, doFit);
  3410. };
  3411. return Marker;
  3412. })(IMarker);
  3413. }
  3414. ]);
  3415. }).call(this);
  3416. (function() {
  3417. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3418. __hasProp = {}.hasOwnProperty,
  3419. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3420. angular.module("google-maps.directives.api").factory("Markers", [
  3421. "IMarker", "MarkersParentModel", function(IMarker, MarkersParentModel) {
  3422. var Markers;
  3423. return Markers = (function(_super) {
  3424. __extends(Markers, _super);
  3425. function Markers($timeout) {
  3426. this.link = __bind(this.link, this);
  3427. var self;
  3428. Markers.__super__.constructor.call(this, $timeout);
  3429. this.template = '<span class="angular-google-map-markers" ng-transclude></span>';
  3430. this.scope.idKey = '=idkey';
  3431. this.scope.doRebuildAll = '=dorebuildall';
  3432. this.scope.models = '=models';
  3433. this.scope.doCluster = '=docluster';
  3434. this.scope.clusterOptions = '=clusteroptions';
  3435. this.scope.clusterEvents = '=clusterevents';
  3436. this.scope.labelContent = '=labelcontent';
  3437. this.scope.labelAnchor = '@labelanchor';
  3438. this.scope.labelClass = '@labelclass';
  3439. this.$timeout = $timeout;
  3440. self = this;
  3441. this.$log.info(this);
  3442. }
  3443. Markers.prototype.controller = [
  3444. '$scope', '$element', function($scope, $element) {
  3445. return {
  3446. getMarkersScope: function() {
  3447. return $scope;
  3448. }
  3449. };
  3450. }
  3451. ];
  3452. Markers.prototype.link = function(scope, element, attrs, ctrl) {
  3453. return new MarkersParentModel(scope, element, attrs, ctrl, this.$timeout);
  3454. };
  3455. return Markers;
  3456. })(IMarker);
  3457. }
  3458. ]);
  3459. }).call(this);
  3460. (function() {
  3461. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3462. __hasProp = {}.hasOwnProperty,
  3463. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3464. angular.module("google-maps.directives.api").factory("Polyline", [
  3465. "IPolyline", "$timeout", "array-sync", "PolylineChildModel", function(IPolyline, $timeout, arraySync, PolylineChildModel) {
  3466. var Polyline, _ref;
  3467. return Polyline = (function(_super) {
  3468. __extends(Polyline, _super);
  3469. function Polyline() {
  3470. this.link = __bind(this.link, this);
  3471. _ref = Polyline.__super__.constructor.apply(this, arguments);
  3472. return _ref;
  3473. }
  3474. Polyline.prototype.link = function(scope, element, attrs, mapCtrl) {
  3475. var _this = this;
  3476. if (angular.isUndefined(scope.path) || scope.path === null || !this.validatePath(scope.path)) {
  3477. this.$log.error("polyline: no valid path attribute found");
  3478. return;
  3479. }
  3480. return $timeout(function() {
  3481. return new PolylineChildModel(scope, attrs, mapCtrl.getMap(), _this.DEFAULTS);
  3482. });
  3483. };
  3484. return Polyline;
  3485. })(IPolyline);
  3486. }
  3487. ]);
  3488. }).call(this);
  3489. (function() {
  3490. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3491. __hasProp = {}.hasOwnProperty,
  3492. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3493. angular.module("google-maps.directives.api").factory("Polylines", [
  3494. "IPolyline", "$timeout", "array-sync", "PolylinesParentModel", function(IPolyline, $timeout, arraySync, PolylinesParentModel) {
  3495. var Polylines;
  3496. return Polylines = (function(_super) {
  3497. __extends(Polylines, _super);
  3498. function Polylines() {
  3499. this.link = __bind(this.link, this);
  3500. Polylines.__super__.constructor.call(this);
  3501. this.scope.idKey = '=idkey';
  3502. this.scope.models = '=models';
  3503. this.$log.info(this);
  3504. }
  3505. Polylines.prototype.link = function(scope, element, attrs, mapCtrl) {
  3506. var _this = this;
  3507. if (angular.isUndefined(scope.path) || scope.path === null) {
  3508. this.$log.error("polylines: no valid path attribute found");
  3509. return;
  3510. }
  3511. if (!scope.models) {
  3512. this.$log.error("polylines: no models found to create from");
  3513. return;
  3514. }
  3515. return $timeout(function() {
  3516. return new PolylinesParentModel(scope, element, attrs, mapCtrl.getMap(), _this.DEFAULTS);
  3517. });
  3518. };
  3519. return Polylines;
  3520. })(IPolyline);
  3521. }
  3522. ]);
  3523. }).call(this);
  3524. (function() {
  3525. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3526. __hasProp = {}.hasOwnProperty,
  3527. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3528. angular.module("google-maps.directives.api").factory("Window", [
  3529. "IWindow", "GmapUtil", "WindowChildModel", function(IWindow, GmapUtil, WindowChildModel) {
  3530. var Window;
  3531. return Window = (function(_super) {
  3532. __extends(Window, _super);
  3533. Window.include(GmapUtil);
  3534. function Window($timeout, $compile, $http, $templateCache) {
  3535. this.link = __bind(this.link, this);
  3536. var self;
  3537. Window.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache);
  3538. self = this;
  3539. this.require = ['^googleMap', '^?marker'];
  3540. this.template = '<span class="angular-google-maps-window" ng-transclude></span>';
  3541. this.$log.info(self);
  3542. }
  3543. Window.prototype.link = function(scope, element, attrs, ctrls) {
  3544. var _this = this;
  3545. return this.$timeout(function() {
  3546. var defaults, hasScopeCoords, isIconVisibleOnClick, mapCtrl, markerCtrl, markerScope, opts, window;
  3547. isIconVisibleOnClick = true;
  3548. if (angular.isDefined(attrs.isiconvisibleonclick)) {
  3549. isIconVisibleOnClick = scope.isIconVisibleOnClick;
  3550. }
  3551. mapCtrl = ctrls[0].getMap();
  3552. markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarkerScope().gMarker : void 0;
  3553. defaults = scope.options != null ? scope.options : {};
  3554. hasScopeCoords = (scope != null) && _this.validateCoords(scope.coords);
  3555. opts = hasScopeCoords ? _this.createWindowOptions(markerCtrl, scope, element.html(), defaults) : defaults;
  3556. if (mapCtrl != null) {
  3557. window = new WindowChildModel({}, scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, element);
  3558. }
  3559. scope.$on("$destroy", function() {
  3560. return window.destroy();
  3561. });
  3562. if (ctrls[1] != null) {
  3563. markerScope = ctrls[1].getMarkerScope();
  3564. markerScope.$watch('coords', function(newValue, oldValue) {
  3565. if (!_this.validateCoords(newValue)) {
  3566. return window.hideWindow();
  3567. }
  3568. if (!angular.equals(newValue, oldValue)) {
  3569. return window.getLatestPosition();
  3570. }
  3571. }, true);
  3572. }
  3573. if ((_this.onChildCreation != null) && (window != null)) {
  3574. return _this.onChildCreation(window);
  3575. }
  3576. }, GmapUtil.defaultDelay + 25);
  3577. };
  3578. return Window;
  3579. })(IWindow);
  3580. }
  3581. ]);
  3582. }).call(this);
  3583. (function() {
  3584. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3585. __hasProp = {}.hasOwnProperty,
  3586. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3587. angular.module("google-maps.directives.api").factory("Windows", [
  3588. "IWindow", "WindowsParentModel", function(IWindow, WindowsParentModel) {
  3589. /*
  3590. Windows directive where many windows map to the models property
  3591. */
  3592. var Windows;
  3593. return Windows = (function(_super) {
  3594. __extends(Windows, _super);
  3595. function Windows($timeout, $compile, $http, $templateCache, $interpolate) {
  3596. this.link = __bind(this.link, this);
  3597. var self;
  3598. Windows.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache);
  3599. self = this;
  3600. this.$interpolate = $interpolate;
  3601. this.require = ['^googleMap', '^?markers'];
  3602. this.template = '<span class="angular-google-maps-windows" ng-transclude></span>';
  3603. this.scope.idKey = '=idkey';
  3604. this.scope.doRebuildAll = '=dorebuildall';
  3605. this.scope.models = '=models';
  3606. this.$log.info(this);
  3607. }
  3608. Windows.prototype.link = function(scope, element, attrs, ctrls) {
  3609. return new WindowsParentModel(scope, element, attrs, ctrls, this.$timeout, this.$compile, this.$http, this.$templateCache, this.$interpolate);
  3610. };
  3611. return Windows;
  3612. })(IWindow);
  3613. }
  3614. ]);
  3615. }).call(this);
  3616. /*
  3617. !
  3618. The MIT License
  3619. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  3620. Permission is hereby granted, free of charge, to any person obtaining a copy
  3621. of this software and associated documentation files (the "Software"), to deal
  3622. in the Software without restriction, including without limitation the rights
  3623. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3624. copies of the Software, and to permit persons to whom the Software is
  3625. furnished to do so, subject to the following conditions:
  3626. The above copyright notice and this permission notice shall be included in
  3627. all copies or substantial portions of the Software.
  3628. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3629. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3630. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3631. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3632. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3633. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3634. THE SOFTWARE.
  3635. angular-google-maps
  3636. https://github.com/nlaplante/angular-google-maps
  3637. @authors
  3638. Nicolas Laplante - https://plus.google.com/108189012221374960701
  3639. Nicholas McCready - https://twitter.com/nmccready
  3640. Nick Baugh - https://github.com/niftylettuce
  3641. */
  3642. (function() {
  3643. angular.module("google-maps").directive("googleMap", [
  3644. "Map", function(Map) {
  3645. return new Map();
  3646. }
  3647. ]);
  3648. }).call(this);
  3649. /*
  3650. !
  3651. The MIT License
  3652. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  3653. Permission is hereby granted, free of charge, to any person obtaining a copy
  3654. of this software and associated documentation files (the "Software"), to deal
  3655. in the Software without restriction, including without limitation the rights
  3656. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3657. copies of the Software, and to permit persons to whom the Software is
  3658. furnished to do so, subject to the following conditions:
  3659. The above copyright notice and this permission notice shall be included in
  3660. all copies or substantial portions of the Software.
  3661. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3662. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3663. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3664. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3665. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3666. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3667. THE SOFTWARE.
  3668. angular-google-maps
  3669. https://github.com/nlaplante/angular-google-maps
  3670. @authors
  3671. Nicolas Laplante - https://plus.google.com/108189012221374960701
  3672. Nicholas McCready - https://twitter.com/nmccready
  3673. */
  3674. /*
  3675. Map marker directive
  3676. This directive is used to create a marker on an existing map.
  3677. This directive creates a new scope.
  3678. {attribute coords required} object containing latitude and longitude properties
  3679. {attribute icon optional} string url to image used for marker icon
  3680. {attribute animate optional} if set to false, the marker won't be animated (on by default)
  3681. */
  3682. (function() {
  3683. angular.module("google-maps").directive("marker", [
  3684. "$timeout", "Marker", function($timeout, Marker) {
  3685. return new Marker($timeout);
  3686. }
  3687. ]);
  3688. }).call(this);
  3689. /*
  3690. !
  3691. The MIT License
  3692. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  3693. Permission is hereby granted, free of charge, to any person obtaining a copy
  3694. of this software and associated documentation files (the "Software"), to deal
  3695. in the Software without restriction, including without limitation the rights
  3696. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3697. copies of the Software, and to permit persons to whom the Software is
  3698. furnished to do so, subject to the following conditions:
  3699. The above copyright notice and this permission notice shall be included in
  3700. all copies or substantial portions of the Software.
  3701. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3702. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3703. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3704. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3705. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3706. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3707. THE SOFTWARE.
  3708. angular-google-maps
  3709. https://github.com/nlaplante/angular-google-maps
  3710. @authors
  3711. Nicolas Laplante - https://plus.google.com/108189012221374960701
  3712. Nicholas McCready - https://twitter.com/nmccready
  3713. */
  3714. /*
  3715. Map marker directive
  3716. This directive is used to create a marker on an existing map.
  3717. This directive creates a new scope.
  3718. {attribute coords required} object containing latitude and longitude properties
  3719. {attribute icon optional} string url to image used for marker icon
  3720. {attribute animate optional} if set to false, the marker won't be animated (on by default)
  3721. */
  3722. (function() {
  3723. angular.module("google-maps").directive("markers", [
  3724. "$timeout", "Markers", function($timeout, Markers) {
  3725. return new Markers($timeout);
  3726. }
  3727. ]);
  3728. }).call(this);
  3729. /*
  3730. !
  3731. The MIT License
  3732. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  3733. Permission is hereby granted, free of charge, to any person obtaining a copy
  3734. of this software and associated documentation files (the "Software"), to deal
  3735. in the Software without restriction, including without limitation the rights
  3736. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3737. copies of the Software, and to permit persons to whom the Software is
  3738. furnished to do so, subject to the following conditions:
  3739. The above copyright notice and this permission notice shall be included in
  3740. all copies or substantial portions of the Software.
  3741. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3742. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3743. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3744. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3745. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3746. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3747. THE SOFTWARE.
  3748. angular-google-maps
  3749. https://github.com/nlaplante/angular-google-maps
  3750. @authors Bruno Queiroz, creativelikeadog@gmail.com
  3751. */
  3752. /*
  3753. Marker label directive
  3754. This directive is used to create a marker label on an existing map.
  3755. {attribute content required} content of the label
  3756. {attribute anchor required} string that contains the x and y point position of the label
  3757. {attribute class optional} class to DOM object
  3758. {attribute style optional} style for the label
  3759. */
  3760. /*
  3761. Basic Directive api for a label. Basic in the sense that this directive contains 1:1 on scope and model.
  3762. Thus there will be one html element per marker within the directive.
  3763. */
  3764. (function() {
  3765. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3766. __hasProp = {}.hasOwnProperty,
  3767. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  3768. angular.module("google-maps").directive("markerLabel", [
  3769. "$timeout", "ILabel", "MarkerLabelChildModel", "GmapUtil", function($timeout, ILabel, MarkerLabelChildModel, GmapUtil) {
  3770. var Label;
  3771. Label = (function(_super) {
  3772. __extends(Label, _super);
  3773. function Label($timeout) {
  3774. this.link = __bind(this.link, this);
  3775. var self;
  3776. Label.__super__.constructor.call(this, $timeout);
  3777. self = this;
  3778. this.require = '^marker';
  3779. this.template = '<span class="angular-google-maps-marker-label" ng-transclude></span>';
  3780. this.$log.info(this);
  3781. }
  3782. Label.prototype.link = function(scope, element, attrs, ctrl) {
  3783. var _this = this;
  3784. return this.$timeout(function() {
  3785. var label, markerCtrl;
  3786. markerCtrl = ctrl.getMarkerScope().gMarker;
  3787. if (markerCtrl != null) {
  3788. label = new MarkerLabelChildModel(markerCtrl, scope);
  3789. }
  3790. return scope.$on("$destroy", function() {
  3791. return label.destroy();
  3792. });
  3793. }, GmapUtil.defaultDelay + 25);
  3794. };
  3795. return Label;
  3796. })(ILabel);
  3797. return new Label($timeout);
  3798. }
  3799. ]);
  3800. }).call(this);
  3801. /*
  3802. !
  3803. The MIT License
  3804. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  3805. Permission is hereby granted, free of charge, to any person obtaining a copy
  3806. of this software and associated documentation files (the "Software"), to deal
  3807. in the Software without restriction, including without limitation the rights
  3808. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3809. copies of the Software, and to permit persons to whom the Software is
  3810. furnished to do so, subject to the following conditions:
  3811. The above copyright notice and this permission notice shall be included in
  3812. all copies or substantial portions of the Software.
  3813. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3814. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3815. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3816. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3817. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3818. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3819. THE SOFTWARE.
  3820. angular-google-maps
  3821. https://github.com/nlaplante/angular-google-maps
  3822. @authors
  3823. Nicolas Laplante - https://plus.google.com/108189012221374960701
  3824. Nicholas McCready - https://twitter.com/nmccready
  3825. Rick Huizinga - https://plus.google.com/+RickHuizinga
  3826. */
  3827. (function() {
  3828. angular.module("google-maps").directive("polygon", [
  3829. "$log", "$timeout", "array-sync", "GmapUtil", function($log, $timeout, arraySync, GmapUtil) {
  3830. /*
  3831. Check if a value is true
  3832. */
  3833. var DEFAULTS, isTrue;
  3834. isTrue = function(val) {
  3835. return angular.isDefined(val) && val !== null && val === true || val === "1" || val === "y" || val === "true";
  3836. };
  3837. "use strict";
  3838. DEFAULTS = {};
  3839. return {
  3840. restrict: "ECA",
  3841. replace: true,
  3842. require: "^googleMap",
  3843. scope: {
  3844. path: "=path",
  3845. stroke: "=stroke",
  3846. clickable: "=",
  3847. draggable: "=",
  3848. editable: "=",
  3849. geodesic: "=",
  3850. fill: "=",
  3851. icons: "=icons",
  3852. visible: "=",
  3853. "static": "=",
  3854. events: "=",
  3855. zIndex: "=zindex",
  3856. fit: "="
  3857. },
  3858. link: function(scope, element, attrs, mapCtrl) {
  3859. if (angular.isUndefined(scope.path) || scope.path === null || !GmapUtil.validatePath(scope.path)) {
  3860. $log.error("polygon: no valid path attribute found");
  3861. return;
  3862. }
  3863. return $timeout(function() {
  3864. var arraySyncer, buildOpts, eventName, getEventHandler, map, pathPoints, polygon;
  3865. buildOpts = function(pathPoints) {
  3866. var opts;
  3867. opts = angular.extend({}, DEFAULTS, {
  3868. map: map,
  3869. path: pathPoints,
  3870. strokeColor: scope.stroke && scope.stroke.color,
  3871. strokeOpacity: scope.stroke && scope.stroke.opacity,
  3872. strokeWeight: scope.stroke && scope.stroke.weight,
  3873. fillColor: scope.fill && scope.fill.color,
  3874. fillOpacity: scope.fill && scope.fill.opacity
  3875. });
  3876. angular.forEach({
  3877. clickable: true,
  3878. draggable: false,
  3879. editable: false,
  3880. geodesic: false,
  3881. visible: true,
  3882. "static": false,
  3883. fit: false,
  3884. zIndex: 0
  3885. }, function(defaultValue, key) {
  3886. if (angular.isUndefined(scope[key]) || scope[key] === null) {
  3887. return opts[key] = defaultValue;
  3888. } else {
  3889. return opts[key] = scope[key];
  3890. }
  3891. });
  3892. if (opts["static"]) {
  3893. opts.editable = false;
  3894. }
  3895. return opts;
  3896. };
  3897. map = mapCtrl.getMap();
  3898. pathPoints = GmapUtil.convertPathPoints(scope.path);
  3899. polygon = new google.maps.Polygon(buildOpts(pathPoints));
  3900. if (scope.fit) {
  3901. GmapUtil.extendMapBounds(map, pathPoints);
  3902. }
  3903. if (!scope["static"] && angular.isDefined(scope.editable)) {
  3904. scope.$watch("editable", function(newValue, oldValue) {
  3905. if (newValue !== oldValue) {
  3906. return polygon.setEditable(newValue);
  3907. }
  3908. });
  3909. }
  3910. if (angular.isDefined(scope.draggable)) {
  3911. scope.$watch("draggable", function(newValue, oldValue) {
  3912. if (newValue !== oldValue) {
  3913. return polygon.setDraggable(newValue);
  3914. }
  3915. });
  3916. }
  3917. if (angular.isDefined(scope.visible)) {
  3918. scope.$watch("visible", function(newValue, oldValue) {
  3919. if (newValue !== oldValue) {
  3920. return polygon.setVisible(newValue);
  3921. }
  3922. });
  3923. }
  3924. if (angular.isDefined(scope.geodesic)) {
  3925. scope.$watch("geodesic", function(newValue, oldValue) {
  3926. if (newValue !== oldValue) {
  3927. return polygon.setOptions(buildOpts(polygon.getPath()));
  3928. }
  3929. });
  3930. }
  3931. if (angular.isDefined(scope.stroke) && angular.isDefined(scope.stroke.opacity)) {
  3932. scope.$watch("stroke.opacity", function(newValue, oldValue) {
  3933. return polygon.setOptions(buildOpts(polygon.getPath()));
  3934. });
  3935. }
  3936. if (angular.isDefined(scope.stroke) && angular.isDefined(scope.stroke.weight)) {
  3937. scope.$watch("stroke.weight", function(newValue, oldValue) {
  3938. if (newValue !== oldValue) {
  3939. return polygon.setOptions(buildOpts(polygon.getPath()));
  3940. }
  3941. });
  3942. }
  3943. if (angular.isDefined(scope.stroke) && angular.isDefined(scope.stroke.color)) {
  3944. scope.$watch("stroke.color", function(newValue, oldValue) {
  3945. if (newValue !== oldValue) {
  3946. return polygon.setOptions(buildOpts(polygon.getPath()));
  3947. }
  3948. });
  3949. }
  3950. if (angular.isDefined(scope.fill) && angular.isDefined(scope.fill.color)) {
  3951. scope.$watch("fill.color", function(newValue, oldValue) {
  3952. if (newValue !== oldValue) {
  3953. return polygon.setOptions(buildOpts(polygon.getPath()));
  3954. }
  3955. });
  3956. }
  3957. if (angular.isDefined(scope.fill) && angular.isDefined(scope.fill.opacity)) {
  3958. scope.$watch("fill.opacity", function(newValue, oldValue) {
  3959. if (newValue !== oldValue) {
  3960. return polygon.setOptions(buildOpts(polygon.getPath()));
  3961. }
  3962. });
  3963. }
  3964. if (angular.isDefined(scope.zIndex)) {
  3965. scope.$watch("zIndex", function(newValue, oldValue) {
  3966. if (newValue !== oldValue) {
  3967. return polygon.setOptions(buildOpts(polygon.getPath()));
  3968. }
  3969. });
  3970. }
  3971. if (angular.isDefined(scope.events) && scope.events !== null && angular.isObject(scope.events)) {
  3972. getEventHandler = function(eventName) {
  3973. return function() {
  3974. return scope.events[eventName].apply(scope, [polygon, eventName, arguments]);
  3975. };
  3976. };
  3977. for (eventName in scope.events) {
  3978. if (scope.events.hasOwnProperty(eventName) && angular.isFunction(scope.events[eventName])) {
  3979. polygon.addListener(eventName, getEventHandler(eventName));
  3980. }
  3981. }
  3982. }
  3983. arraySyncer = arraySync(polygon.getPath(), scope, "path", function(pathPoints) {
  3984. if (scope.fit) {
  3985. return GmapUtil.extendMapBounds(map, pathPoints);
  3986. }
  3987. });
  3988. return scope.$on("$destroy", function() {
  3989. polygon.setMap(null);
  3990. if (arraySyncer) {
  3991. arraySyncer();
  3992. return arraySyncer = null;
  3993. }
  3994. });
  3995. });
  3996. }
  3997. };
  3998. }
  3999. ]);
  4000. }).call(this);
  4001. /*
  4002. !
  4003. The MIT License
  4004. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  4005. Permission is hereby granted, free of charge, to any person obtaining a copy
  4006. of this software and associated documentation files (the "Software"), to deal
  4007. in the Software without restriction, including without limitation the rights
  4008. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4009. copies of the Software, and to permit persons to whom the Software is
  4010. furnished to do so, subject to the following conditions:
  4011. The above copyright notice and this permission notice shall be included in
  4012. all copies or substantial portions of the Software.
  4013. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4014. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4015. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4016. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4017. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4018. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4019. THE SOFTWARE.
  4020. @authors
  4021. Julian Popescu - https://github.com/jpopesculian
  4022. Rick Huizinga - https://plus.google.com/+RickHuizinga
  4023. */
  4024. (function() {
  4025. angular.module("google-maps").directive("circle", [
  4026. "$log", "$timeout", "GmapUtil", "EventsHelper", function($log, $timeout, GmapUtil, EventsHelper) {
  4027. "use strict";
  4028. var DEFAULTS;
  4029. DEFAULTS = {};
  4030. return {
  4031. restrict: "ECA",
  4032. replace: true,
  4033. require: "^googleMap",
  4034. scope: {
  4035. center: "=center",
  4036. radius: "=radius",
  4037. stroke: "=stroke",
  4038. fill: "=fill",
  4039. clickable: "=",
  4040. draggable: "=",
  4041. editable: "=",
  4042. geodesic: "=",
  4043. icons: "=icons",
  4044. visible: "=",
  4045. events: "="
  4046. },
  4047. link: function(scope, element, attrs, mapCtrl) {
  4048. return $timeout(function() {
  4049. var buildOpts, circle, map;
  4050. buildOpts = function() {
  4051. var opts;
  4052. if (!GmapUtil.validateCoords(scope.center)) {
  4053. $log.error("circle: no valid center attribute found");
  4054. return;
  4055. }
  4056. opts = angular.extend({}, DEFAULTS, {
  4057. map: map,
  4058. center: GmapUtil.getCoords(scope.center),
  4059. radius: scope.radius,
  4060. strokeColor: scope.stroke && scope.stroke.color,
  4061. strokeOpacity: scope.stroke && scope.stroke.opacity,
  4062. strokeWeight: scope.stroke && scope.stroke.weight,
  4063. fillColor: scope.fill && scope.fill.color,
  4064. fillOpacity: scope.fill && scope.fill.opacity
  4065. });
  4066. angular.forEach({
  4067. clickable: true,
  4068. draggable: false,
  4069. editable: false,
  4070. geodesic: false,
  4071. visible: true
  4072. }, function(defaultValue, key) {
  4073. if (angular.isUndefined(scope[key]) || scope[key] === null) {
  4074. return opts[key] = defaultValue;
  4075. } else {
  4076. return opts[key] = scope[key];
  4077. }
  4078. });
  4079. return opts;
  4080. };
  4081. map = mapCtrl.getMap();
  4082. circle = new google.maps.Circle(buildOpts());
  4083. scope.$watchCollection('center', function(newVals, oldVals) {
  4084. if (newVals !== oldVals) {
  4085. return circle.setOptions(buildOpts());
  4086. }
  4087. });
  4088. scope.$watchCollection('stroke', function(newVals, oldVals) {
  4089. if (newVals !== oldVals) {
  4090. return circle.setOptions(buildOpts());
  4091. }
  4092. });
  4093. scope.$watchCollection('fill', function(newVals, oldVals) {
  4094. if (newVals !== oldVals) {
  4095. return circle.setOptions(buildOpts());
  4096. }
  4097. });
  4098. scope.$watch('radius', function(newVal, oldVal) {
  4099. if (newVal !== oldVal) {
  4100. return circle.setOptions(buildOpts());
  4101. }
  4102. });
  4103. scope.$watch('clickable', function(newVal, oldVal) {
  4104. if (newVal !== oldVal) {
  4105. return circle.setOptions(buildOpts());
  4106. }
  4107. });
  4108. scope.$watch('editable', function(newVal, oldVal) {
  4109. if (newVal !== oldVal) {
  4110. return circle.setOptions(buildOpts());
  4111. }
  4112. });
  4113. scope.$watch('draggable', function(newVal, oldVal) {
  4114. if (newVal !== oldVal) {
  4115. return circle.setOptions(buildOpts());
  4116. }
  4117. });
  4118. scope.$watch('visible', function(newVal, oldVal) {
  4119. if (newVal !== oldVal) {
  4120. return circle.setOptions(buildOpts());
  4121. }
  4122. });
  4123. scope.$watch('geodesic', function(newVal, oldVal) {
  4124. if (newVal !== oldVal) {
  4125. return circle.setOptions(buildOpts());
  4126. }
  4127. });
  4128. EventsHelper.setEvents(circle, scope, scope);
  4129. google.maps.event.addListener(circle, 'radius_changed', function() {
  4130. scope.radius = circle.getRadius();
  4131. return $timeout(function() {
  4132. return scope.$apply();
  4133. });
  4134. });
  4135. google.maps.event.addListener(circle, 'center_changed', function() {
  4136. if (angular.isDefined(scope.center.type)) {
  4137. scope.center.coordinates[1] = circle.getCenter().lat();
  4138. scope.center.coordinates[0] = circle.getCenter().lng();
  4139. } else {
  4140. scope.center.latitude = circle.getCenter().lat();
  4141. scope.center.longitude = circle.getCenter().lng();
  4142. }
  4143. return $timeout(function() {
  4144. return scope.$apply();
  4145. });
  4146. });
  4147. return scope.$on("$destroy", function() {
  4148. return circle.setMap(null);
  4149. });
  4150. });
  4151. }
  4152. };
  4153. }
  4154. ]);
  4155. }).call(this);
  4156. /*
  4157. !
  4158. The MIT License
  4159. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  4160. Permission is hereby granted, free of charge, to any person obtaining a copy
  4161. of this software and associated documentation files (the "Software"), to deal
  4162. in the Software without restriction, including without limitation the rights
  4163. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4164. copies of the Software, and to permit persons to whom the Software is
  4165. furnished to do so, subject to the following conditions:
  4166. The above copyright notice and this permission notice shall be included in
  4167. all copies or substantial portions of the Software.
  4168. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4169. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4170. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4171. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4172. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4173. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4174. THE SOFTWARE.
  4175. angular-google-maps
  4176. https://github.com/nlaplante/angular-google-maps
  4177. @authors
  4178. Nicolas Laplante - https://plus.google.com/108189012221374960701
  4179. Nicholas McCready - https://twitter.com/nmccready
  4180. */
  4181. (function() {
  4182. angular.module("google-maps").directive("polyline", [
  4183. "Polyline", function(Polyline) {
  4184. return new Polyline();
  4185. }
  4186. ]);
  4187. }).call(this);
  4188. /*
  4189. !
  4190. The MIT License
  4191. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  4192. Permission is hereby granted, free of charge, to any person obtaining a copy
  4193. of this software and associated documentation files (the "Software"), to deal
  4194. in the Software without restriction, including without limitation the rights
  4195. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4196. copies of the Software, and to permit persons to whom the Software is
  4197. furnished to do so, subject to the following conditions:
  4198. The above copyright notice and this permission notice shall be included in
  4199. all copies or substantial portions of the Software.
  4200. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4201. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4202. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4203. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4204. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4205. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4206. THE SOFTWARE.
  4207. angular-google-maps
  4208. https://github.com/nlaplante/angular-google-maps
  4209. @authors
  4210. Nicolas Laplante - https://plus.google.com/108189012221374960701
  4211. Nicholas McCready - https://twitter.com/nmccready
  4212. */
  4213. (function() {
  4214. angular.module("google-maps").directive("polylines", [
  4215. "Polylines", function(Polylines) {
  4216. return new Polylines();
  4217. }
  4218. ]);
  4219. }).call(this);
  4220. /*
  4221. !
  4222. The MIT License
  4223. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  4224. Permission is hereby granted, free of charge, to any person obtaining a copy
  4225. of this software and associated documentation files (the "Software"), to deal
  4226. in the Software without restriction, including without limitation the rights
  4227. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4228. copies of the Software, and to permit persons to whom the Software is
  4229. furnished to do so, subject to the following conditions:
  4230. The above copyright notice and this permission notice shall be included in
  4231. all copies or substantial portions of the Software.
  4232. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4233. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4234. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4235. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4236. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4237. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4238. THE SOFTWARE.
  4239. angular-google-maps
  4240. https://github.com/nlaplante/angular-google-maps
  4241. @authors
  4242. Nicolas Laplante - https://plus.google.com/108189012221374960701
  4243. Nicholas McCready - https://twitter.com/nmccready
  4244. Chentsu Lin - https://github.com/ChenTsuLin
  4245. */
  4246. (function() {
  4247. angular.module("google-maps").directive("rectangle", [
  4248. "$log", "$timeout", function($log, $timeout) {
  4249. var DEFAULTS, convertBoundPoints, fitMapBounds, isTrue, validateBoundPoints;
  4250. validateBoundPoints = function(bounds) {
  4251. if (angular.isUndefined(bounds.sw.latitude) || angular.isUndefined(bounds.sw.longitude) || angular.isUndefined(bounds.ne.latitude) || angular.isUndefined(bounds.ne.longitude)) {
  4252. return false;
  4253. }
  4254. return true;
  4255. };
  4256. convertBoundPoints = function(bounds) {
  4257. var result;
  4258. result = new google.maps.LatLngBounds(new google.maps.LatLng(bounds.sw.latitude, bounds.sw.longitude), new google.maps.LatLng(bounds.ne.latitude, bounds.ne.longitude));
  4259. return result;
  4260. };
  4261. fitMapBounds = function(map, bounds) {
  4262. return map.fitBounds(bounds);
  4263. };
  4264. /*
  4265. Check if a value is true
  4266. */
  4267. isTrue = function(val) {
  4268. return angular.isDefined(val) && val !== null && val === true || val === "1" || val === "y" || val === "true";
  4269. };
  4270. "use strict";
  4271. DEFAULTS = {};
  4272. return {
  4273. restrict: "ECA",
  4274. require: "^googleMap",
  4275. replace: true,
  4276. scope: {
  4277. bounds: "=",
  4278. stroke: "=",
  4279. clickable: "=",
  4280. draggable: "=",
  4281. editable: "=",
  4282. fill: "=",
  4283. visible: "="
  4284. },
  4285. link: function(scope, element, attrs, mapCtrl) {
  4286. if (angular.isUndefined(scope.bounds) || scope.bounds === null || angular.isUndefined(scope.bounds.sw) || scope.bounds.sw === null || angular.isUndefined(scope.bounds.ne) || scope.bounds.ne === null || !validateBoundPoints(scope.bounds)) {
  4287. $log.error("rectangle: no valid bound attribute found");
  4288. return;
  4289. }
  4290. return $timeout(function() {
  4291. var buildOpts, dragging, map, rectangle, settingBoundsFromScope;
  4292. buildOpts = function(bounds) {
  4293. var opts;
  4294. opts = angular.extend({}, DEFAULTS, {
  4295. map: map,
  4296. bounds: bounds,
  4297. strokeColor: scope.stroke && scope.stroke.color,
  4298. strokeOpacity: scope.stroke && scope.stroke.opacity,
  4299. strokeWeight: scope.stroke && scope.stroke.weight,
  4300. fillColor: scope.fill && scope.fill.color,
  4301. fillOpacity: scope.fill && scope.fill.opacity
  4302. });
  4303. angular.forEach({
  4304. clickable: true,
  4305. draggable: false,
  4306. editable: false,
  4307. visible: true
  4308. }, function(defaultValue, key) {
  4309. if (angular.isUndefined(scope[key]) || scope[key] === null) {
  4310. return opts[key] = defaultValue;
  4311. } else {
  4312. return opts[key] = scope[key];
  4313. }
  4314. });
  4315. return opts;
  4316. };
  4317. map = mapCtrl.getMap();
  4318. rectangle = new google.maps.Rectangle(buildOpts(convertBoundPoints(scope.bounds)));
  4319. if (isTrue(attrs.fit)) {
  4320. fitMapBounds(map, bounds);
  4321. }
  4322. dragging = false;
  4323. google.maps.event.addListener(rectangle, "mousedown", function() {
  4324. google.maps.event.addListener(rectangle, "mousemove", function() {
  4325. dragging = true;
  4326. return _.defer(function() {
  4327. return scope.$apply(function(s) {
  4328. if (s.dragging != null) {
  4329. return s.dragging = dragging;
  4330. }
  4331. });
  4332. });
  4333. });
  4334. google.maps.event.addListener(rectangle, "mouseup", function() {
  4335. google.maps.event.clearListeners(rectangle, 'mousemove');
  4336. google.maps.event.clearListeners(rectangle, 'mouseup');
  4337. dragging = false;
  4338. return _.defer(function() {
  4339. return scope.$apply(function(s) {
  4340. if (s.dragging != null) {
  4341. return s.dragging = dragging;
  4342. }
  4343. });
  4344. });
  4345. });
  4346. });
  4347. settingBoundsFromScope = false;
  4348. google.maps.event.addListener(rectangle, "bounds_changed", function() {
  4349. var b, ne, sw;
  4350. b = rectangle.getBounds();
  4351. ne = b.getNorthEast();
  4352. sw = b.getSouthWest();
  4353. if (settingBoundsFromScope) {
  4354. return;
  4355. }
  4356. return _.defer(function() {
  4357. return scope.$apply(function(s) {
  4358. if (!rectangle.dragging) {
  4359. if (s.bounds !== null && s.bounds !== undefined && s.bounds !== void 0) {
  4360. s.bounds.ne = {
  4361. latitude: ne.lat(),
  4362. longitude: ne.lng()
  4363. };
  4364. s.bounds.sw = {
  4365. latitude: sw.lat(),
  4366. longitude: sw.lng()
  4367. };
  4368. }
  4369. }
  4370. });
  4371. });
  4372. });
  4373. scope.$watch("bounds", (function(newValue, oldValue) {
  4374. var bounds;
  4375. if (_.isEqual(newValue, oldValue)) {
  4376. return;
  4377. }
  4378. settingBoundsFromScope = true;
  4379. if (!dragging) {
  4380. if ((newValue.sw.latitude == null) || (newValue.sw.longitude == null) || (newValue.ne.latitude == null) || (newValue.ne.longitude == null)) {
  4381. $log.error("Invalid bounds for newValue: " + (JSON.stringify(newValue)));
  4382. }
  4383. bounds = new google.maps.LatLngBounds(new google.maps.LatLng(newValue.sw.latitude, newValue.sw.longitude), new google.maps.LatLng(newValue.ne.latitude, newValue.ne.longitude));
  4384. rectangle.setBounds(bounds);
  4385. }
  4386. return settingBoundsFromScope = false;
  4387. }), true);
  4388. if (angular.isDefined(scope.editable)) {
  4389. scope.$watch("editable", function(newValue, oldValue) {
  4390. return rectangle.setEditable(newValue);
  4391. });
  4392. }
  4393. if (angular.isDefined(scope.draggable)) {
  4394. scope.$watch("draggable", function(newValue, oldValue) {
  4395. return rectangle.setDraggable(newValue);
  4396. });
  4397. }
  4398. if (angular.isDefined(scope.visible)) {
  4399. scope.$watch("visible", function(newValue, oldValue) {
  4400. return rectangle.setVisible(newValue);
  4401. });
  4402. }
  4403. if (angular.isDefined(scope.stroke)) {
  4404. if (angular.isDefined(scope.stroke.color)) {
  4405. scope.$watch("stroke.color", function(newValue, oldValue) {
  4406. return rectangle.setOptions(buildOpts(rectangle.getBounds()));
  4407. });
  4408. }
  4409. if (angular.isDefined(scope.stroke.weight)) {
  4410. scope.$watch("stroke.weight", function(newValue, oldValue) {
  4411. return rectangle.setOptions(buildOpts(rectangle.getBounds()));
  4412. });
  4413. }
  4414. if (angular.isDefined(scope.stroke.opacity)) {
  4415. scope.$watch("stroke.opacity", function(newValue, oldValue) {
  4416. return rectangle.setOptions(buildOpts(rectangle.getBounds()));
  4417. });
  4418. }
  4419. }
  4420. if (angular.isDefined(scope.fill)) {
  4421. if (angular.isDefined(scope.fill.color)) {
  4422. scope.$watch("fill.color", function(newValue, oldValue) {
  4423. return rectangle.setOptions(buildOpts(rectangle.getBounds()));
  4424. });
  4425. }
  4426. if (angular.isDefined(scope.fill.opacity)) {
  4427. scope.$watch("fill.opacity", function(newValue, oldValue) {
  4428. return rectangle.setOptions(buildOpts(rectangle.getBounds()));
  4429. });
  4430. }
  4431. }
  4432. return scope.$on("$destroy", function() {
  4433. return rectangle.setMap(null);
  4434. });
  4435. });
  4436. }
  4437. };
  4438. }
  4439. ]);
  4440. }).call(this);
  4441. /*
  4442. !
  4443. The MIT License
  4444. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  4445. Permission is hereby granted, free of charge, to any person obtaining a copy
  4446. of this software and associated documentation files (the "Software"), to deal
  4447. in the Software without restriction, including without limitation the rights
  4448. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4449. copies of the Software, and to permit persons to whom the Software is
  4450. furnished to do so, subject to the following conditions:
  4451. The above copyright notice and this permission notice shall be included in
  4452. all copies or substantial portions of the Software.
  4453. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4454. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4455. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4456. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4457. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4458. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4459. THE SOFTWARE.
  4460. angular-google-maps
  4461. https://github.com/nlaplante/angular-google-maps
  4462. @authors
  4463. Nicolas Laplante - https://plus.google.com/108189012221374960701
  4464. Nicholas McCready - https://twitter.com/nmccready
  4465. */
  4466. /*
  4467. Map info window directive
  4468. This directive is used to create an info window on an existing map.
  4469. This directive creates a new scope.
  4470. {attribute coords required} object containing latitude and longitude properties
  4471. {attribute show optional} map will show when this expression returns true
  4472. */
  4473. (function() {
  4474. angular.module("google-maps").directive("window", [
  4475. "$timeout", "$compile", "$http", "$templateCache", "Window", function($timeout, $compile, $http, $templateCache, Window) {
  4476. return new Window($timeout, $compile, $http, $templateCache);
  4477. }
  4478. ]);
  4479. }).call(this);
  4480. /*
  4481. !
  4482. The MIT License
  4483. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  4484. Permission is hereby granted, free of charge, to any person obtaining a copy
  4485. of this software and associated documentation files (the "Software"), to deal
  4486. in the Software without restriction, including without limitation the rights
  4487. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4488. copies of the Software, and to permit persons to whom the Software is
  4489. furnished to do so, subject to the following conditions:
  4490. The above copyright notice and this permission notice shall be included in
  4491. all copies or substantial portions of the Software.
  4492. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4493. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4494. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4495. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4496. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4497. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4498. THE SOFTWARE.
  4499. angular-google-maps
  4500. https://github.com/nlaplante/angular-google-maps
  4501. @authors
  4502. Nicolas Laplante - https://plus.google.com/108189012221374960701
  4503. Nicholas McCready - https://twitter.com/nmccready
  4504. */
  4505. /*
  4506. Map info window directive
  4507. This directive is used to create an info window on an existing map.
  4508. This directive creates a new scope.
  4509. {attribute coords required} object containing latitude and longitude properties
  4510. {attribute show optional} map will show when this expression returns true
  4511. */
  4512. (function() {
  4513. angular.module("google-maps").directive("windows", [
  4514. "$timeout", "$compile", "$http", "$templateCache", "$interpolate", "Windows", function($timeout, $compile, $http, $templateCache, $interpolate, Windows) {
  4515. return new Windows($timeout, $compile, $http, $templateCache, $interpolate);
  4516. }
  4517. ]);
  4518. }).call(this);
  4519. /*
  4520. !
  4521. The MIT License
  4522. Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
  4523. Permission is hereby granted, free of charge, to any person obtaining a copy
  4524. of this software and associated documentation files (the "Software"), to deal
  4525. in the Software without restriction, including without limitation the rights
  4526. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4527. copies of the Software, and to permit persons to whom the Software is
  4528. furnished to do so, subject to the following conditions:
  4529. The above copyright notice and this permission notice shall be included in
  4530. all copies or substantial portions of the Software.
  4531. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4532. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4533. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4534. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4535. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4536. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4537. THE SOFTWARE.
  4538. angular-google-maps
  4539. https://github.com/nlaplante/angular-google-maps
  4540. @authors:
  4541. - Nicolas Laplante https://plus.google.com/108189012221374960701
  4542. - Nicholas McCready - https://twitter.com/nmccready
  4543. */
  4544. /*
  4545. Map Layer directive
  4546. This directive is used to create any type of Layer from the google maps sdk.
  4547. This directive creates a new scope.
  4548. {attribute show optional} true (default) shows the trafficlayer otherwise it is hidden
  4549. */
  4550. (function() {
  4551. var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  4552. angular.module("google-maps").directive("layer", [
  4553. "$timeout", "Logger", "LayerParentModel", function($timeout, Logger, LayerParentModel) {
  4554. var Layer;
  4555. Layer = (function() {
  4556. function Layer($timeout) {
  4557. this.$timeout = $timeout;
  4558. this.link = __bind(this.link, this);
  4559. this.$log = Logger;
  4560. this.restrict = "ECMA";
  4561. this.require = "^googleMap";
  4562. this.priority = -1;
  4563. this.transclude = true;
  4564. this.template = '<span class=\"angular-google-map-layer\" ng-transclude></span>';
  4565. this.replace = true;
  4566. this.scope = {
  4567. show: "=show",
  4568. type: "=type",
  4569. namespace: "=namespace",
  4570. options: '=options',
  4571. onCreated: '&oncreated'
  4572. };
  4573. }
  4574. Layer.prototype.link = function(scope, element, attrs, mapCtrl) {
  4575. if (attrs.oncreated != null) {
  4576. return new LayerParentModel(scope, element, attrs, mapCtrl, this.$timeout, scope.onCreated);
  4577. } else {
  4578. return new LayerParentModel(scope, element, attrs, mapCtrl, this.$timeout);
  4579. }
  4580. };
  4581. return Layer;
  4582. })();
  4583. return new Layer($timeout);
  4584. }
  4585. ]);
  4586. }).call(this);
  4587. ;/**
  4588. * @name InfoBox
  4589. * @version 1.1.12 [December 11, 2012]
  4590. * @author Gary Little (inspired by proof-of-concept code from Pamela Fox of Google)
  4591. * @copyright Copyright 2010 Gary Little [gary at luxcentral.com]
  4592. * @fileoverview InfoBox extends the Google Maps JavaScript API V3 <tt>OverlayView</tt> class.
  4593. * <p>
  4594. * An InfoBox behaves like a <tt>google.maps.InfoWindow</tt>, but it supports several
  4595. * additional properties for advanced styling. An InfoBox can also be used as a map label.
  4596. * <p>
  4597. * An InfoBox also fires the same events as a <tt>google.maps.InfoWindow</tt>.
  4598. */
  4599. /*!
  4600. *
  4601. * Licensed under the Apache License, Version 2.0 (the "License");
  4602. * you may not use this file except in compliance with the License.
  4603. * You may obtain a copy of the License at
  4604. *
  4605. * http://www.apache.org/licenses/LICENSE-2.0
  4606. *
  4607. * Unless required by applicable law or agreed to in writing, software
  4608. * distributed under the License is distributed on an "AS IS" BASIS,
  4609. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  4610. * See the License for the specific language governing permissions and
  4611. * limitations under the License.
  4612. */
  4613. /*jslint browser:true */
  4614. /*global google */
  4615. /**
  4616. * @name InfoBoxOptions
  4617. * @class This class represents the optional parameter passed to the {@link InfoBox} constructor.
  4618. * @property {string|Node} content The content of the InfoBox (plain text or an HTML DOM node).
  4619. * @property {boolean} [disableAutoPan=false] Disable auto-pan on <tt>open</tt>.
  4620. * @property {number} maxWidth The maximum width (in pixels) of the InfoBox. Set to 0 if no maximum.
  4621. * @property {Size} pixelOffset The offset (in pixels) from the top left corner of the InfoBox
  4622. * (or the bottom left corner if the <code>alignBottom</code> property is <code>true</code>)
  4623. * to the map pixel corresponding to <tt>position</tt>.
  4624. * @property {LatLng} position The geographic location at which to display the InfoBox.
  4625. * @property {number} zIndex The CSS z-index style value for the InfoBox.
  4626. * Note: This value overrides a zIndex setting specified in the <tt>boxStyle</tt> property.
  4627. * @property {string} [boxClass="infoBox"] The name of the CSS class defining the styles for the InfoBox container.
  4628. * @property {Object} [boxStyle] An object literal whose properties define specific CSS
  4629. * style values to be applied to the InfoBox. Style values defined here override those that may
  4630. * be defined in the <code>boxClass</code> style sheet. If this property is changed after the
  4631. * InfoBox has been created, all previously set styles (except those defined in the style sheet)
  4632. * are removed from the InfoBox before the new style values are applied.
  4633. * @property {string} closeBoxMargin The CSS margin style value for the close box.
  4634. * The default is "2px" (a 2-pixel margin on all sides).
  4635. * @property {string} closeBoxURL The URL of the image representing the close box.
  4636. * Note: The default is the URL for Google's standard close box.
  4637. * Set this property to "" if no close box is required.
  4638. * @property {Size} infoBoxClearance Minimum offset (in pixels) from the InfoBox to the
  4639. * map edge after an auto-pan.
  4640. * @property {boolean} [isHidden=false] Hide the InfoBox on <tt>open</tt>.
  4641. * [Deprecated in favor of the <tt>visible</tt> property.]
  4642. * @property {boolean} [visible=true] Show the InfoBox on <tt>open</tt>.
  4643. * @property {boolean} alignBottom Align the bottom left corner of the InfoBox to the <code>position</code>
  4644. * location (default is <tt>false</tt> which means that the top left corner of the InfoBox is aligned).
  4645. * @property {string} pane The pane where the InfoBox is to appear (default is "floatPane").
  4646. * Set the pane to "mapPane" if the InfoBox is being used as a map label.
  4647. * Valid pane names are the property names for the <tt>google.maps.MapPanes</tt> object.
  4648. * @property {boolean} enableEventPropagation Propagate mousedown, mousemove, mouseover, mouseout,
  4649. * mouseup, click, dblclick, touchstart, touchend, touchmove, and contextmenu events in the InfoBox
  4650. * (default is <tt>false</tt> to mimic the behavior of a <tt>google.maps.InfoWindow</tt>). Set
  4651. * this property to <tt>true</tt> if the InfoBox is being used as a map label.
  4652. */
  4653. /**
  4654. * Creates an InfoBox with the options specified in {@link InfoBoxOptions}.
  4655. * Call <tt>InfoBox.open</tt> to add the box to the map.
  4656. * @constructor
  4657. * @param {InfoBoxOptions} [opt_opts]
  4658. */
  4659. function InfoBox(opt_opts) {
  4660. opt_opts = opt_opts || {};
  4661. google.maps.OverlayView.apply(this, arguments);
  4662. // Standard options (in common with google.maps.InfoWindow):
  4663. //
  4664. this.content_ = opt_opts.content || "";
  4665. this.disableAutoPan_ = opt_opts.disableAutoPan || false;
  4666. this.maxWidth_ = opt_opts.maxWidth || 0;
  4667. this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);
  4668. this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);
  4669. this.zIndex_ = opt_opts.zIndex || null;
  4670. // Additional options (unique to InfoBox):
  4671. //
  4672. this.boxClass_ = opt_opts.boxClass || "infoBox";
  4673. this.boxStyle_ = opt_opts.boxStyle || {};
  4674. this.closeBoxMargin_ = opt_opts.closeBoxMargin || "2px";
  4675. this.closeBoxURL_ = opt_opts.closeBoxURL || "http://www.google.com/intl/en_us/mapfiles/close.gif";
  4676. if (opt_opts.closeBoxURL === "") {
  4677. this.closeBoxURL_ = "";
  4678. }
  4679. this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);
  4680. if (typeof opt_opts.visible === "undefined") {
  4681. if (typeof opt_opts.isHidden === "undefined") {
  4682. opt_opts.visible = true;
  4683. } else {
  4684. opt_opts.visible = !opt_opts.isHidden;
  4685. }
  4686. }
  4687. this.isHidden_ = !opt_opts.visible;
  4688. this.alignBottom_ = opt_opts.alignBottom || false;
  4689. this.pane_ = opt_opts.pane || "floatPane";
  4690. this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;
  4691. this.div_ = null;
  4692. this.closeListener_ = null;
  4693. this.moveListener_ = null;
  4694. this.contextListener_ = null;
  4695. this.eventListeners_ = null;
  4696. this.fixedWidthSet_ = null;
  4697. }
  4698. /* InfoBox extends OverlayView in the Google Maps API v3.
  4699. */
  4700. InfoBox.prototype = new google.maps.OverlayView();
  4701. /**
  4702. * Creates the DIV representing the InfoBox.
  4703. * @private
  4704. */
  4705. InfoBox.prototype.createInfoBoxDiv_ = function () {
  4706. var i;
  4707. var events;
  4708. var bw;
  4709. var me = this;
  4710. // This handler prevents an event in the InfoBox from being passed on to the map.
  4711. //
  4712. var cancelHandler = function (e) {
  4713. e.cancelBubble = true;
  4714. if (e.stopPropagation) {
  4715. e.stopPropagation();
  4716. }
  4717. };
  4718. // This handler ignores the current event in the InfoBox and conditionally prevents
  4719. // the event from being passed on to the map. It is used for the contextmenu event.
  4720. //
  4721. var ignoreHandler = function (e) {
  4722. e.returnValue = false;
  4723. if (e.preventDefault) {
  4724. e.preventDefault();
  4725. }
  4726. if (!me.enableEventPropagation_) {
  4727. cancelHandler(e);
  4728. }
  4729. };
  4730. if (!this.div_) {
  4731. this.div_ = document.createElement("div");
  4732. this.setBoxStyle_();
  4733. if (typeof this.content_.nodeType === "undefined") {
  4734. this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;
  4735. } else {
  4736. this.div_.innerHTML = this.getCloseBoxImg_();
  4737. this.div_.appendChild(this.content_);
  4738. }
  4739. // Add the InfoBox DIV to the DOM
  4740. this.getPanes()[this.pane_].appendChild(this.div_);
  4741. this.addClickHandler_();
  4742. if (this.div_.style.width) {
  4743. this.fixedWidthSet_ = true;
  4744. } else {
  4745. if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {
  4746. this.div_.style.width = this.maxWidth_;
  4747. this.div_.style.overflow = "auto";
  4748. this.fixedWidthSet_ = true;
  4749. } else { // The following code is needed to overcome problems with MSIE
  4750. bw = this.getBoxWidths_();
  4751. this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + "px";
  4752. this.fixedWidthSet_ = false;
  4753. }
  4754. }
  4755. this.panBox_(this.disableAutoPan_);
  4756. if (!this.enableEventPropagation_) {
  4757. this.eventListeners_ = [];
  4758. // Cancel event propagation.
  4759. //
  4760. // Note: mousemove not included (to resolve Issue 152)
  4761. events = ["mousedown", "mouseover", "mouseout", "mouseup",
  4762. "click", "dblclick", "touchstart", "touchend", "touchmove"];
  4763. for (i = 0; i < events.length; i++) {
  4764. this.eventListeners_.push(google.maps.event.addDomListener(this.div_, events[i], cancelHandler));
  4765. }
  4766. // Workaround for Google bug that causes the cursor to change to a pointer
  4767. // when the mouse moves over a marker underneath InfoBox.
  4768. this.eventListeners_.push(google.maps.event.addDomListener(this.div_, "mouseover", function (e) {
  4769. this.style.cursor = "default";
  4770. }));
  4771. }
  4772. this.contextListener_ = google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler);
  4773. /**
  4774. * This event is fired when the DIV containing the InfoBox's content is attached to the DOM.
  4775. * @name InfoBox#domready
  4776. * @event
  4777. */
  4778. google.maps.event.trigger(this, "domready");
  4779. }
  4780. };
  4781. /**
  4782. * Returns the HTML <IMG> tag for the close box.
  4783. * @private
  4784. */
  4785. InfoBox.prototype.getCloseBoxImg_ = function () {
  4786. var img = "";
  4787. if (this.closeBoxURL_ !== "") {
  4788. img = "<img";
  4789. img += " src='" + this.closeBoxURL_ + "'";
  4790. img += " align=right"; // Do this because Opera chokes on style='float: right;'
  4791. img += " style='";
  4792. img += " position: relative;"; // Required by MSIE
  4793. img += " cursor: pointer;";
  4794. img += " margin: " + this.closeBoxMargin_ + ";";
  4795. img += "'>";
  4796. }
  4797. return img;
  4798. };
  4799. /**
  4800. * Adds the click handler to the InfoBox close box.
  4801. * @private
  4802. */
  4803. InfoBox.prototype.addClickHandler_ = function () {
  4804. var closeBox;
  4805. if (this.closeBoxURL_ !== "") {
  4806. closeBox = this.div_.firstChild;
  4807. this.closeListener_ = google.maps.event.addDomListener(closeBox, "click", this.getCloseClickHandler_());
  4808. } else {
  4809. this.closeListener_ = null;
  4810. }
  4811. };
  4812. /**
  4813. * Returns the function to call when the user clicks the close box of an InfoBox.
  4814. * @private
  4815. */
  4816. InfoBox.prototype.getCloseClickHandler_ = function () {
  4817. var me = this;
  4818. return function (e) {
  4819. // 1.0.3 fix: Always prevent propagation of a close box click to the map:
  4820. e.cancelBubble = true;
  4821. if (e.stopPropagation) {
  4822. e.stopPropagation();
  4823. }
  4824. /**
  4825. * This event is fired when the InfoBox's close box is clicked.
  4826. * @name InfoBox#closeclick
  4827. * @event
  4828. */
  4829. google.maps.event.trigger(me, "closeclick");
  4830. me.close();
  4831. };
  4832. };
  4833. /**
  4834. * Pans the map so that the InfoBox appears entirely within the map's visible area.
  4835. * @private
  4836. */
  4837. InfoBox.prototype.panBox_ = function (disablePan) {
  4838. var map;
  4839. var bounds;
  4840. var xOffset = 0, yOffset = 0;
  4841. if (!disablePan) {
  4842. map = this.getMap();
  4843. if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama
  4844. if (!map.getBounds().contains(this.position_)) {
  4845. // Marker not in visible area of map, so set center
  4846. // of map to the marker position first.
  4847. map.setCenter(this.position_);
  4848. }
  4849. bounds = map.getBounds();
  4850. var mapDiv = map.getDiv();
  4851. var mapWidth = mapDiv.offsetWidth;
  4852. var mapHeight = mapDiv.offsetHeight;
  4853. var iwOffsetX = this.pixelOffset_.width;
  4854. var iwOffsetY = this.pixelOffset_.height;
  4855. var iwWidth = this.div_.offsetWidth;
  4856. var iwHeight = this.div_.offsetHeight;
  4857. var padX = this.infoBoxClearance_.width;
  4858. var padY = this.infoBoxClearance_.height;
  4859. var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);
  4860. if (pixPosition.x < (-iwOffsetX + padX)) {
  4861. xOffset = pixPosition.x + iwOffsetX - padX;
  4862. } else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
  4863. xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
  4864. }
  4865. if (this.alignBottom_) {
  4866. if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {
  4867. yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;
  4868. } else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {
  4869. yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;
  4870. }
  4871. } else {
  4872. if (pixPosition.y < (-iwOffsetY + padY)) {
  4873. yOffset = pixPosition.y + iwOffsetY - padY;
  4874. } else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
  4875. yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
  4876. }
  4877. }
  4878. if (!(xOffset === 0 && yOffset === 0)) {
  4879. // Move the map to the shifted center.
  4880. //
  4881. var c = map.getCenter();
  4882. map.panBy(xOffset, yOffset);
  4883. }
  4884. }
  4885. }
  4886. };
  4887. /**
  4888. * Sets the style of the InfoBox by setting the style sheet and applying
  4889. * other specific styles requested.
  4890. * @private
  4891. */
  4892. InfoBox.prototype.setBoxStyle_ = function () {
  4893. var i, boxStyle;
  4894. if (this.div_) {
  4895. // Apply style values from the style sheet defined in the boxClass parameter:
  4896. this.div_.className = this.boxClass_;
  4897. // Clear existing inline style values:
  4898. this.div_.style.cssText = "";
  4899. // Apply style values defined in the boxStyle parameter:
  4900. boxStyle = this.boxStyle_;
  4901. for (i in boxStyle) {
  4902. if (boxStyle.hasOwnProperty(i)) {
  4903. this.div_.style[i] = boxStyle[i];
  4904. }
  4905. }
  4906. // Fix up opacity style for benefit of MSIE:
  4907. //
  4908. if (typeof this.div_.style.opacity !== "undefined" && this.div_.style.opacity !== "") {
  4909. this.div_.style.filter = "alpha(opacity=" + (this.div_.style.opacity * 100) + ")";
  4910. }
  4911. // Apply required styles:
  4912. //
  4913. this.div_.style.position = "absolute";
  4914. this.div_.style.visibility = 'hidden';
  4915. if (this.zIndex_ !== null) {
  4916. this.div_.style.zIndex = this.zIndex_;
  4917. }
  4918. }
  4919. };
  4920. /**
  4921. * Get the widths of the borders of the InfoBox.
  4922. * @private
  4923. * @return {Object} widths object (top, bottom left, right)
  4924. */
  4925. InfoBox.prototype.getBoxWidths_ = function () {
  4926. var computedStyle;
  4927. var bw = {top: 0, bottom: 0, left: 0, right: 0};
  4928. var box = this.div_;
  4929. if (document.defaultView && document.defaultView.getComputedStyle) {
  4930. computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, "");
  4931. if (computedStyle) {
  4932. // The computed styles are always in pixel units (good!)
  4933. bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
  4934. bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  4935. bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  4936. bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
  4937. }
  4938. } else if (document.documentElement.currentStyle) { // MSIE
  4939. if (box.currentStyle) {
  4940. // The current styles may not be in pixel units, but assume they are (bad!)
  4941. bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;
  4942. bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;
  4943. bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;
  4944. bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;
  4945. }
  4946. }
  4947. return bw;
  4948. };
  4949. /**
  4950. * Invoked when <tt>close</tt> is called. Do not call it directly.
  4951. */
  4952. InfoBox.prototype.onRemove = function () {
  4953. if (this.div_) {
  4954. this.div_.parentNode.removeChild(this.div_);
  4955. this.div_ = null;
  4956. }
  4957. };
  4958. /**
  4959. * Draws the InfoBox based on the current map projection and zoom level.
  4960. */
  4961. InfoBox.prototype.draw = function () {
  4962. this.createInfoBoxDiv_();
  4963. var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);
  4964. this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + "px";
  4965. if (this.alignBottom_) {
  4966. this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + "px";
  4967. } else {
  4968. this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + "px";
  4969. }
  4970. if (this.isHidden_) {
  4971. this.div_.style.visibility = 'hidden';
  4972. } else {
  4973. this.div_.style.visibility = "visible";
  4974. }
  4975. };
  4976. /**
  4977. * Sets the options for the InfoBox. Note that changes to the <tt>maxWidth</tt>,
  4978. * <tt>closeBoxMargin</tt>, <tt>closeBoxURL</tt>, and <tt>enableEventPropagation</tt>
  4979. * properties have no affect until the current InfoBox is <tt>close</tt>d and a new one
  4980. * is <tt>open</tt>ed.
  4981. * @param {InfoBoxOptions} opt_opts
  4982. */
  4983. InfoBox.prototype.setOptions = function (opt_opts) {
  4984. if (typeof opt_opts.boxClass !== "undefined") { // Must be first
  4985. this.boxClass_ = opt_opts.boxClass;
  4986. this.setBoxStyle_();
  4987. }
  4988. if (typeof opt_opts.boxStyle !== "undefined") { // Must be second
  4989. this.boxStyle_ = opt_opts.boxStyle;
  4990. this.setBoxStyle_();
  4991. }
  4992. if (typeof opt_opts.content !== "undefined") {
  4993. this.setContent(opt_opts.content);
  4994. }
  4995. if (typeof opt_opts.disableAutoPan !== "undefined") {
  4996. this.disableAutoPan_ = opt_opts.disableAutoPan;
  4997. }
  4998. if (typeof opt_opts.maxWidth !== "undefined") {
  4999. this.maxWidth_ = opt_opts.maxWidth;
  5000. }
  5001. if (typeof opt_opts.pixelOffset !== "undefined") {
  5002. this.pixelOffset_ = opt_opts.pixelOffset;
  5003. }
  5004. if (typeof opt_opts.alignBottom !== "undefined") {
  5005. this.alignBottom_ = opt_opts.alignBottom;
  5006. }
  5007. if (typeof opt_opts.position !== "undefined") {
  5008. this.setPosition(opt_opts.position);
  5009. }
  5010. if (typeof opt_opts.zIndex !== "undefined") {
  5011. this.setZIndex(opt_opts.zIndex);
  5012. }
  5013. if (typeof opt_opts.closeBoxMargin !== "undefined") {
  5014. this.closeBoxMargin_ = opt_opts.closeBoxMargin;
  5015. }
  5016. if (typeof opt_opts.closeBoxURL !== "undefined") {
  5017. this.closeBoxURL_ = opt_opts.closeBoxURL;
  5018. }
  5019. if (typeof opt_opts.infoBoxClearance !== "undefined") {
  5020. this.infoBoxClearance_ = opt_opts.infoBoxClearance;
  5021. }
  5022. if (typeof opt_opts.isHidden !== "undefined") {
  5023. this.isHidden_ = opt_opts.isHidden;
  5024. }
  5025. if (typeof opt_opts.visible !== "undefined") {
  5026. this.isHidden_ = !opt_opts.visible;
  5027. }
  5028. if (typeof opt_opts.enableEventPropagation !== "undefined") {
  5029. this.enableEventPropagation_ = opt_opts.enableEventPropagation;
  5030. }
  5031. if (this.div_) {
  5032. this.draw();
  5033. }
  5034. };
  5035. /**
  5036. * Sets the content of the InfoBox.
  5037. * The content can be plain text or an HTML DOM node.
  5038. * @param {string|Node} content
  5039. */
  5040. InfoBox.prototype.setContent = function (content) {
  5041. this.content_ = content;
  5042. if (this.div_) {
  5043. if (this.closeListener_) {
  5044. google.maps.event.removeListener(this.closeListener_);
  5045. this.closeListener_ = null;
  5046. }
  5047. // Odd code required to make things work with MSIE.
  5048. //
  5049. if (!this.fixedWidthSet_) {
  5050. this.div_.style.width = "";
  5051. }
  5052. if (typeof content.nodeType === "undefined") {
  5053. this.div_.innerHTML = this.getCloseBoxImg_() + content;
  5054. } else {
  5055. this.div_.innerHTML = this.getCloseBoxImg_();
  5056. this.div_.appendChild(content);
  5057. }
  5058. // Perverse code required to make things work with MSIE.
  5059. // (Ensures the close box does, in fact, float to the right.)
  5060. //
  5061. if (!this.fixedWidthSet_) {
  5062. this.div_.style.width = this.div_.offsetWidth + "px";
  5063. if (typeof content.nodeType === "undefined") {
  5064. this.div_.innerHTML = this.getCloseBoxImg_() + content;
  5065. } else {
  5066. this.div_.innerHTML = this.getCloseBoxImg_();
  5067. this.div_.appendChild(content);
  5068. }
  5069. }
  5070. this.addClickHandler_();
  5071. }
  5072. /**
  5073. * This event is fired when the content of the InfoBox changes.
  5074. * @name InfoBox#content_changed
  5075. * @event
  5076. */
  5077. google.maps.event.trigger(this, "content_changed");
  5078. };
  5079. /**
  5080. * Sets the geographic location of the InfoBox.
  5081. * @param {LatLng} latlng
  5082. */
  5083. InfoBox.prototype.setPosition = function (latlng) {
  5084. this.position_ = latlng;
  5085. if (this.div_) {
  5086. this.draw();
  5087. }
  5088. /**
  5089. * This event is fired when the position of the InfoBox changes.
  5090. * @name InfoBox#position_changed
  5091. * @event
  5092. */
  5093. google.maps.event.trigger(this, "position_changed");
  5094. };
  5095. /**
  5096. * Sets the zIndex style for the InfoBox.
  5097. * @param {number} index
  5098. */
  5099. InfoBox.prototype.setZIndex = function (index) {
  5100. this.zIndex_ = index;
  5101. if (this.div_) {
  5102. this.div_.style.zIndex = index;
  5103. }
  5104. /**
  5105. * This event is fired when the zIndex of the InfoBox changes.
  5106. * @name InfoBox#zindex_changed
  5107. * @event
  5108. */
  5109. google.maps.event.trigger(this, "zindex_changed");
  5110. };
  5111. /**
  5112. * Sets the visibility of the InfoBox.
  5113. * @param {boolean} isVisible
  5114. */
  5115. InfoBox.prototype.setVisible = function (isVisible) {
  5116. this.isHidden_ = !isVisible;
  5117. if (this.div_) {
  5118. this.div_.style.visibility = (this.isHidden_ ? "hidden" : "visible");
  5119. }
  5120. };
  5121. /**
  5122. * Returns the content of the InfoBox.
  5123. * @returns {string}
  5124. */
  5125. InfoBox.prototype.getContent = function () {
  5126. return this.content_;
  5127. };
  5128. /**
  5129. * Returns the geographic location of the InfoBox.
  5130. * @returns {LatLng}
  5131. */
  5132. InfoBox.prototype.getPosition = function () {
  5133. return this.position_;
  5134. };
  5135. /**
  5136. * Returns the zIndex for the InfoBox.
  5137. * @returns {number}
  5138. */
  5139. InfoBox.prototype.getZIndex = function () {
  5140. return this.zIndex_;
  5141. };
  5142. /**
  5143. * Returns a flag indicating whether the InfoBox is visible.
  5144. * @returns {boolean}
  5145. */
  5146. InfoBox.prototype.getVisible = function () {
  5147. var isVisible;
  5148. if ((typeof this.getMap() === "undefined") || (this.getMap() === null)) {
  5149. isVisible = false;
  5150. } else {
  5151. isVisible = !this.isHidden_;
  5152. }
  5153. return isVisible;
  5154. };
  5155. /**
  5156. * Shows the InfoBox. [Deprecated; use <tt>setVisible</tt> instead.]
  5157. */
  5158. InfoBox.prototype.show = function () {
  5159. this.isHidden_ = false;
  5160. if (this.div_) {
  5161. this.div_.style.visibility = "visible";
  5162. }
  5163. };
  5164. /**
  5165. * Hides the InfoBox. [Deprecated; use <tt>setVisible</tt> instead.]
  5166. */
  5167. InfoBox.prototype.hide = function () {
  5168. this.isHidden_ = true;
  5169. if (this.div_) {
  5170. this.div_.style.visibility = "hidden";
  5171. }
  5172. };
  5173. /**
  5174. * Adds the InfoBox to the specified map or Street View panorama. If <tt>anchor</tt>
  5175. * (usually a <tt>google.maps.Marker</tt>) is specified, the position
  5176. * of the InfoBox is set to the position of the <tt>anchor</tt>. If the
  5177. * anchor is dragged to a new location, the InfoBox moves as well.
  5178. * @param {Map|StreetViewPanorama} map
  5179. * @param {MVCObject} [anchor]
  5180. */
  5181. InfoBox.prototype.open = function (map, anchor) {
  5182. var me = this;
  5183. if (anchor) {
  5184. this.position_ = anchor.getPosition();
  5185. this.moveListener_ = google.maps.event.addListener(anchor, "position_changed", function () {
  5186. me.setPosition(this.getPosition());
  5187. });
  5188. }
  5189. this.setMap(map);
  5190. if (this.div_) {
  5191. this.panBox_();
  5192. }
  5193. };
  5194. /**
  5195. * Removes the InfoBox from the map.
  5196. */
  5197. InfoBox.prototype.close = function () {
  5198. var i;
  5199. if (this.closeListener_) {
  5200. google.maps.event.removeListener(this.closeListener_);
  5201. this.closeListener_ = null;
  5202. }
  5203. if (this.eventListeners_) {
  5204. for (i = 0; i < this.eventListeners_.length; i++) {
  5205. google.maps.event.removeListener(this.eventListeners_[i]);
  5206. }
  5207. this.eventListeners_ = null;
  5208. }
  5209. if (this.moveListener_) {
  5210. google.maps.event.removeListener(this.moveListener_);
  5211. this.moveListener_ = null;
  5212. }
  5213. if (this.contextListener_) {
  5214. google.maps.event.removeListener(this.contextListener_);
  5215. this.contextListener_ = null;
  5216. }
  5217. this.setMap(null);
  5218. };;/**
  5219. * @name MarkerClustererPlus for Google Maps V3
  5220. * @version 2.1.1 [November 4, 2013]
  5221. * @author Gary Little
  5222. * @fileoverview
  5223. * The library creates and manages per-zoom-level clusters for large amounts of markers.
  5224. * <p>
  5225. * This is an enhanced V3 implementation of the
  5226. * <a href="http://gmaps-utility-library-dev.googlecode.com/svn/tags/markerclusterer/"
  5227. * >V2 MarkerClusterer</a> by Xiaoxi Wu. It is based on the
  5228. * <a href="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/"
  5229. * >V3 MarkerClusterer</a> port by Luke Mahe. MarkerClustererPlus was created by Gary Little.
  5230. * <p>
  5231. * v2.0 release: MarkerClustererPlus v2.0 is backward compatible with MarkerClusterer v1.0. It
  5232. * adds support for the <code>ignoreHidden</code>, <code>title</code>, <code>batchSizeIE</code>,
  5233. * and <code>calculator</code> properties as well as support for four more events. It also allows
  5234. * greater control over the styling of the text that appears on the cluster marker. The
  5235. * documentation has been significantly improved and the overall code has been simplified and
  5236. * polished. Very large numbers of markers can now be managed without causing Javascript timeout
  5237. * errors on Internet Explorer. Note that the name of the <code>clusterclick</code> event has been
  5238. * deprecated. The new name is <code>click</code>, so please change your application code now.
  5239. */
  5240. /**
  5241. * Licensed under the Apache License, Version 2.0 (the "License");
  5242. * you may not use this file except in compliance with the License.
  5243. * You may obtain a copy of the License at
  5244. *
  5245. * http://www.apache.org/licenses/LICENSE-2.0
  5246. *
  5247. * Unless required by applicable law or agreed to in writing, software
  5248. * distributed under the License is distributed on an "AS IS" BASIS,
  5249. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  5250. * See the License for the specific language governing permissions and
  5251. * limitations under the License.
  5252. */
  5253. /**
  5254. * @name ClusterIconStyle
  5255. * @class This class represents the object for values in the <code>styles</code> array passed
  5256. * to the {@link MarkerClusterer} constructor. The element in this array that is used to
  5257. * style the cluster icon is determined by calling the <code>calculator</code> function.
  5258. *
  5259. * @property {string} url The URL of the cluster icon image file. Required.
  5260. * @property {number} height The display height (in pixels) of the cluster icon. Required.
  5261. * @property {number} width The display width (in pixels) of the cluster icon. Required.
  5262. * @property {Array} [anchorText] The position (in pixels) from the center of the cluster icon to
  5263. * where the text label is to be centered and drawn. The format is <code>[yoffset, xoffset]</code>
  5264. * where <code>yoffset</code> increases as you go down from center and <code>xoffset</code>
  5265. * increases to the right of center. The default is <code>[0, 0]</code>.
  5266. * @property {Array} [anchorIcon] The anchor position (in pixels) of the cluster icon. This is the
  5267. * spot on the cluster icon that is to be aligned with the cluster position. The format is
  5268. * <code>[yoffset, xoffset]</code> where <code>yoffset</code> increases as you go down and
  5269. * <code>xoffset</code> increases to the right of the top-left corner of the icon. The default
  5270. * anchor position is the center of the cluster icon.
  5271. * @property {string} [textColor="black"] The color of the label text shown on the
  5272. * cluster icon.
  5273. * @property {number} [textSize=11] The size (in pixels) of the label text shown on the
  5274. * cluster icon.
  5275. * @property {string} [textDecoration="none"] The value of the CSS <code>text-decoration</code>
  5276. * property for the label text shown on the cluster icon.
  5277. * @property {string} [fontWeight="bold"] The value of the CSS <code>font-weight</code>
  5278. * property for the label text shown on the cluster icon.
  5279. * @property {string} [fontStyle="normal"] The value of the CSS <code>font-style</code>
  5280. * property for the label text shown on the cluster icon.
  5281. * @property {string} [fontFamily="Arial,sans-serif"] The value of the CSS <code>font-family</code>
  5282. * property for the label text shown on the cluster icon.
  5283. * @property {string} [backgroundPosition="0 0"] The position of the cluster icon image
  5284. * within the image defined by <code>url</code>. The format is <code>"xpos ypos"</code>
  5285. * (the same format as for the CSS <code>background-position</code> property). You must set
  5286. * this property appropriately when the image defined by <code>url</code> represents a sprite
  5287. * containing multiple images. Note that the position <i>must</i> be specified in px units.
  5288. */
  5289. /**
  5290. * @name ClusterIconInfo
  5291. * @class This class is an object containing general information about a cluster icon. This is
  5292. * the object that a <code>calculator</code> function returns.
  5293. *
  5294. * @property {string} text The text of the label to be shown on the cluster icon.
  5295. * @property {number} index The index plus 1 of the element in the <code>styles</code>
  5296. * array to be used to style the cluster icon.
  5297. * @property {string} title The tooltip to display when the mouse moves over the cluster icon.
  5298. * If this value is <code>undefined</code> or <code>""</code>, <code>title</code> is set to the
  5299. * value of the <code>title</code> property passed to the MarkerClusterer.
  5300. */
  5301. /**
  5302. * A cluster icon.
  5303. *
  5304. * @constructor
  5305. * @extends google.maps.OverlayView
  5306. * @param {Cluster} cluster The cluster with which the icon is to be associated.
  5307. * @param {Array} [styles] An array of {@link ClusterIconStyle} defining the cluster icons
  5308. * to use for various cluster sizes.
  5309. * @private
  5310. */
  5311. function ClusterIcon(cluster, styles) {
  5312. cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView);
  5313. this.cluster_ = cluster;
  5314. this.className_ = cluster.getMarkerClusterer().getClusterClass();
  5315. this.styles_ = styles;
  5316. this.center_ = null;
  5317. this.div_ = null;
  5318. this.sums_ = null;
  5319. this.visible_ = false;
  5320. this.setMap(cluster.getMap()); // Note: this causes onAdd to be called
  5321. }
  5322. /**
  5323. * Adds the icon to the DOM.
  5324. */
  5325. ClusterIcon.prototype.onAdd = function () {
  5326. var cClusterIcon = this;
  5327. var cMouseDownInCluster;
  5328. var cDraggingMapByCluster;
  5329. this.div_ = document.createElement("div");
  5330. this.div_.className = this.className_;
  5331. if (this.visible_) {
  5332. this.show();
  5333. }
  5334. this.getPanes().overlayMouseTarget.appendChild(this.div_);
  5335. // Fix for Issue 157
  5336. this.boundsChangedListener_ = google.maps.event.addListener(this.getMap(), "bounds_changed", function () {
  5337. cDraggingMapByCluster = cMouseDownInCluster;
  5338. });
  5339. google.maps.event.addDomListener(this.div_, "mousedown", function () {
  5340. cMouseDownInCluster = true;
  5341. cDraggingMapByCluster = false;
  5342. });
  5343. google.maps.event.addDomListener(this.div_, "click", function (e) {
  5344. cMouseDownInCluster = false;
  5345. if (!cDraggingMapByCluster) {
  5346. var theBounds;
  5347. var mz;
  5348. var mc = cClusterIcon.cluster_.getMarkerClusterer();
  5349. /**
  5350. * This event is fired when a cluster marker is clicked.
  5351. * @name MarkerClusterer#click
  5352. * @param {Cluster} c The cluster that was clicked.
  5353. * @event
  5354. */
  5355. google.maps.event.trigger(mc, "click", cClusterIcon.cluster_);
  5356. google.maps.event.trigger(mc, "clusterclick", cClusterIcon.cluster_); // deprecated name
  5357. // The default click handler follows. Disable it by setting
  5358. // the zoomOnClick property to false.
  5359. if (mc.getZoomOnClick()) {
  5360. // Zoom into the cluster.
  5361. mz = mc.getMaxZoom();
  5362. theBounds = cClusterIcon.cluster_.getBounds();
  5363. mc.getMap().fitBounds(theBounds);
  5364. // There is a fix for Issue 170 here:
  5365. setTimeout(function () {
  5366. mc.getMap().fitBounds(theBounds);
  5367. // Don't zoom beyond the max zoom level
  5368. if (mz !== null && (mc.getMap().getZoom() > mz)) {
  5369. mc.getMap().setZoom(mz + 1);
  5370. }
  5371. }, 100);
  5372. }
  5373. // Prevent event propagation to the map:
  5374. e.cancelBubble = true;
  5375. if (e.stopPropagation) {
  5376. e.stopPropagation();
  5377. }
  5378. }
  5379. });
  5380. google.maps.event.addDomListener(this.div_, "mouseover", function () {
  5381. var mc = cClusterIcon.cluster_.getMarkerClusterer();
  5382. /**
  5383. * This event is fired when the mouse moves over a cluster marker.
  5384. * @name MarkerClusterer#mouseover
  5385. * @param {Cluster} c The cluster that the mouse moved over.
  5386. * @event
  5387. */
  5388. google.maps.event.trigger(mc, "mouseover", cClusterIcon.cluster_);
  5389. });
  5390. google.maps.event.addDomListener(this.div_, "mouseout", function () {
  5391. var mc = cClusterIcon.cluster_.getMarkerClusterer();
  5392. /**
  5393. * This event is fired when the mouse moves out of a cluster marker.
  5394. * @name MarkerClusterer#mouseout
  5395. * @param {Cluster} c The cluster that the mouse moved out of.
  5396. * @event
  5397. */
  5398. google.maps.event.trigger(mc, "mouseout", cClusterIcon.cluster_);
  5399. });
  5400. };
  5401. /**
  5402. * Removes the icon from the DOM.
  5403. */
  5404. ClusterIcon.prototype.onRemove = function () {
  5405. if (this.div_ && this.div_.parentNode) {
  5406. this.hide();
  5407. google.maps.event.removeListener(this.boundsChangedListener_);
  5408. google.maps.event.clearInstanceListeners(this.div_);
  5409. this.div_.parentNode.removeChild(this.div_);
  5410. this.div_ = null;
  5411. }
  5412. };
  5413. /**
  5414. * Draws the icon.
  5415. */
  5416. ClusterIcon.prototype.draw = function () {
  5417. if (this.visible_) {
  5418. var pos = this.getPosFromLatLng_(this.center_);
  5419. this.div_.style.top = pos.y + "px";
  5420. this.div_.style.left = pos.x + "px";
  5421. }
  5422. };
  5423. /**
  5424. * Hides the icon.
  5425. */
  5426. ClusterIcon.prototype.hide = function () {
  5427. if (this.div_) {
  5428. this.div_.style.display = "none";
  5429. }
  5430. this.visible_ = false;
  5431. };
  5432. /**
  5433. * Positions and shows the icon.
  5434. */
  5435. ClusterIcon.prototype.show = function () {
  5436. if (this.div_) {
  5437. var img = "";
  5438. // NOTE: values must be specified in px units
  5439. var bp = this.backgroundPosition_.split(" ");
  5440. var spriteH = parseInt(bp[0].trim(), 10);
  5441. var spriteV = parseInt(bp[1].trim(), 10);
  5442. var pos = this.getPosFromLatLng_(this.center_);
  5443. this.div_.style.cssText = this.createCss(pos);
  5444. img = "<img src='" + this.url_ + "' style='position: absolute; top: " + spriteV + "px; left: " + spriteH + "px; ";
  5445. if (!this.cluster_.getMarkerClusterer().enableRetinaIcons_) {
  5446. img += "clip: rect(" + (-1 * spriteV) + "px, " + ((-1 * spriteH) + this.width_) + "px, " +
  5447. ((-1 * spriteV) + this.height_) + "px, " + (-1 * spriteH) + "px);";
  5448. }
  5449. img += "'>";
  5450. this.div_.innerHTML = img + "<div style='" +
  5451. "position: absolute;" +
  5452. "top: " + this.anchorText_[0] + "px;" +
  5453. "left: " + this.anchorText_[1] + "px;" +
  5454. "color: " + this.textColor_ + ";" +
  5455. "font-size: " + this.textSize_ + "px;" +
  5456. "font-family: " + this.fontFamily_ + ";" +
  5457. "font-weight: " + this.fontWeight_ + ";" +
  5458. "font-style: " + this.fontStyle_ + ";" +
  5459. "text-decoration: " + this.textDecoration_ + ";" +
  5460. "text-align: center;" +
  5461. "width: " + this.width_ + "px;" +
  5462. "line-height:" + this.height_ + "px;" +
  5463. "'>" + this.sums_.text + "</div>";
  5464. if (typeof this.sums_.title === "undefined" || this.sums_.title === "") {
  5465. this.div_.title = this.cluster_.getMarkerClusterer().getTitle();
  5466. } else {
  5467. this.div_.title = this.sums_.title;
  5468. }
  5469. this.div_.style.display = "";
  5470. }
  5471. this.visible_ = true;
  5472. };
  5473. /**
  5474. * Sets the icon styles to the appropriate element in the styles array.
  5475. *
  5476. * @param {ClusterIconInfo} sums The icon label text and styles index.
  5477. */
  5478. ClusterIcon.prototype.useStyle = function (sums) {
  5479. this.sums_ = sums;
  5480. var index = Math.max(0, sums.index - 1);
  5481. index = Math.min(this.styles_.length - 1, index);
  5482. var style = this.styles_[index];
  5483. this.url_ = style.url;
  5484. this.height_ = style.height;
  5485. this.width_ = style.width;
  5486. this.anchorText_ = style.anchorText || [0, 0];
  5487. this.anchorIcon_ = style.anchorIcon || [parseInt(this.height_ / 2, 10), parseInt(this.width_ / 2, 10)];
  5488. this.textColor_ = style.textColor || "black";
  5489. this.textSize_ = style.textSize || 11;
  5490. this.textDecoration_ = style.textDecoration || "none";
  5491. this.fontWeight_ = style.fontWeight || "bold";
  5492. this.fontStyle_ = style.fontStyle || "normal";
  5493. this.fontFamily_ = style.fontFamily || "Arial,sans-serif";
  5494. this.backgroundPosition_ = style.backgroundPosition || "0 0";
  5495. };
  5496. /**
  5497. * Sets the position at which to center the icon.
  5498. *
  5499. * @param {google.maps.LatLng} center The latlng to set as the center.
  5500. */
  5501. ClusterIcon.prototype.setCenter = function (center) {
  5502. this.center_ = center;
  5503. };
  5504. /**
  5505. * Creates the cssText style parameter based on the position of the icon.
  5506. *
  5507. * @param {google.maps.Point} pos The position of the icon.
  5508. * @return {string} The CSS style text.
  5509. */
  5510. ClusterIcon.prototype.createCss = function (pos) {
  5511. var style = [];
  5512. style.push("cursor: pointer;");
  5513. style.push("position: absolute; top: " + pos.y + "px; left: " + pos.x + "px;");
  5514. style.push("width: " + this.width_ + "px; height: " + this.height_ + "px;");
  5515. return style.join("");
  5516. };
  5517. /**
  5518. * Returns the position at which to place the DIV depending on the latlng.
  5519. *
  5520. * @param {google.maps.LatLng} latlng The position in latlng.
  5521. * @return {google.maps.Point} The position in pixels.
  5522. */
  5523. ClusterIcon.prototype.getPosFromLatLng_ = function (latlng) {
  5524. var pos = this.getProjection().fromLatLngToDivPixel(latlng);
  5525. pos.x -= this.anchorIcon_[1];
  5526. pos.y -= this.anchorIcon_[0];
  5527. pos.x = parseInt(pos.x, 10);
  5528. pos.y = parseInt(pos.y, 10);
  5529. return pos;
  5530. };
  5531. /**
  5532. * Creates a single cluster that manages a group of proximate markers.
  5533. * Used internally, do not call this constructor directly.
  5534. * @constructor
  5535. * @param {MarkerClusterer} mc The <code>MarkerClusterer</code> object with which this
  5536. * cluster is associated.
  5537. */
  5538. function Cluster(mc) {
  5539. this.markerClusterer_ = mc;
  5540. this.map_ = mc.getMap();
  5541. this.gridSize_ = mc.getGridSize();
  5542. this.minClusterSize_ = mc.getMinimumClusterSize();
  5543. this.averageCenter_ = mc.getAverageCenter();
  5544. this.markers_ = [];
  5545. this.center_ = null;
  5546. this.bounds_ = null;
  5547. this.clusterIcon_ = new ClusterIcon(this, mc.getStyles());
  5548. }
  5549. /**
  5550. * Returns the number of markers managed by the cluster. You can call this from
  5551. * a <code>click</code>, <code>mouseover</code>, or <code>mouseout</code> event handler
  5552. * for the <code>MarkerClusterer</code> object.
  5553. *
  5554. * @return {number} The number of markers in the cluster.
  5555. */
  5556. Cluster.prototype.getSize = function () {
  5557. return this.markers_.length;
  5558. };
  5559. /**
  5560. * Returns the array of markers managed by the cluster. You can call this from
  5561. * a <code>click</code>, <code>mouseover</code>, or <code>mouseout</code> event handler
  5562. * for the <code>MarkerClusterer</code> object.
  5563. *
  5564. * @return {Array} The array of markers in the cluster.
  5565. */
  5566. Cluster.prototype.getMarkers = function () {
  5567. return this.markers_;
  5568. };
  5569. /**
  5570. * Returns the center of the cluster. You can call this from
  5571. * a <code>click</code>, <code>mouseover</code>, or <code>mouseout</code> event handler
  5572. * for the <code>MarkerClusterer</code> object.
  5573. *
  5574. * @return {google.maps.LatLng} The center of the cluster.
  5575. */
  5576. Cluster.prototype.getCenter = function () {
  5577. return this.center_;
  5578. };
  5579. /**
  5580. * Returns the map with which the cluster is associated.
  5581. *
  5582. * @return {google.maps.Map} The map.
  5583. * @ignore
  5584. */
  5585. Cluster.prototype.getMap = function () {
  5586. return this.map_;
  5587. };
  5588. /**
  5589. * Returns the <code>MarkerClusterer</code> object with which the cluster is associated.
  5590. *
  5591. * @return {MarkerClusterer} The associated marker clusterer.
  5592. * @ignore
  5593. */
  5594. Cluster.prototype.getMarkerClusterer = function () {
  5595. return this.markerClusterer_;
  5596. };
  5597. /**
  5598. * Returns the bounds of the cluster.
  5599. *
  5600. * @return {google.maps.LatLngBounds} the cluster bounds.
  5601. * @ignore
  5602. */
  5603. Cluster.prototype.getBounds = function () {
  5604. var i;
  5605. var bounds = new google.maps.LatLngBounds(this.center_, this.center_);
  5606. var markers = this.getMarkers();
  5607. for (i = 0; i < markers.length; i++) {
  5608. bounds.extend(markers[i].getPosition());
  5609. }
  5610. return bounds;
  5611. };
  5612. /**
  5613. * Removes the cluster from the map.
  5614. *
  5615. * @ignore
  5616. */
  5617. Cluster.prototype.remove = function () {
  5618. this.clusterIcon_.setMap(null);
  5619. this.markers_ = [];
  5620. delete this.markers_;
  5621. };
  5622. /**
  5623. * Adds a marker to the cluster.
  5624. *
  5625. * @param {google.maps.Marker} marker The marker to be added.
  5626. * @return {boolean} True if the marker was added.
  5627. * @ignore
  5628. */
  5629. Cluster.prototype.addMarker = function (marker) {
  5630. var i;
  5631. var mCount;
  5632. var mz;
  5633. if (this.isMarkerAlreadyAdded_(marker)) {
  5634. return false;
  5635. }
  5636. if (!this.center_) {
  5637. this.center_ = marker.getPosition();
  5638. this.calculateBounds_();
  5639. } else {
  5640. if (this.averageCenter_) {
  5641. var l = this.markers_.length + 1;
  5642. var lat = (this.center_.lat() * (l - 1) + marker.getPosition().lat()) / l;
  5643. var lng = (this.center_.lng() * (l - 1) + marker.getPosition().lng()) / l;
  5644. this.center_ = new google.maps.LatLng(lat, lng);
  5645. this.calculateBounds_();
  5646. }
  5647. }
  5648. marker.isAdded = true;
  5649. this.markers_.push(marker);
  5650. mCount = this.markers_.length;
  5651. mz = this.markerClusterer_.getMaxZoom();
  5652. if (mz !== null && this.map_.getZoom() > mz) {
  5653. // Zoomed in past max zoom, so show the marker.
  5654. if (marker.getMap() !== this.map_) {
  5655. marker.setMap(this.map_);
  5656. }
  5657. } else if (mCount < this.minClusterSize_) {
  5658. // Min cluster size not reached so show the marker.
  5659. if (marker.getMap() !== this.map_) {
  5660. marker.setMap(this.map_);
  5661. }
  5662. } else if (mCount === this.minClusterSize_) {
  5663. // Hide the markers that were showing.
  5664. for (i = 0; i < mCount; i++) {
  5665. this.markers_[i].setMap(null);
  5666. }
  5667. } else {
  5668. marker.setMap(null);
  5669. }
  5670. this.updateIcon_();
  5671. return true;
  5672. };
  5673. /**
  5674. * Determines if a marker lies within the cluster's bounds.
  5675. *
  5676. * @param {google.maps.Marker} marker The marker to check.
  5677. * @return {boolean} True if the marker lies in the bounds.
  5678. * @ignore
  5679. */
  5680. Cluster.prototype.isMarkerInClusterBounds = function (marker) {
  5681. return this.bounds_.contains(marker.getPosition());
  5682. };
  5683. /**
  5684. * Calculates the extended bounds of the cluster with the grid.
  5685. */
  5686. Cluster.prototype.calculateBounds_ = function () {
  5687. var bounds = new google.maps.LatLngBounds(this.center_, this.center_);
  5688. this.bounds_ = this.markerClusterer_.getExtendedBounds(bounds);
  5689. };
  5690. /**
  5691. * Updates the cluster icon.
  5692. */
  5693. Cluster.prototype.updateIcon_ = function () {
  5694. var mCount = this.markers_.length;
  5695. var mz = this.markerClusterer_.getMaxZoom();
  5696. if (mz !== null && this.map_.getZoom() > mz) {
  5697. this.clusterIcon_.hide();
  5698. return;
  5699. }
  5700. if (mCount < this.minClusterSize_) {
  5701. // Min cluster size not yet reached.
  5702. this.clusterIcon_.hide();
  5703. return;
  5704. }
  5705. var numStyles = this.markerClusterer_.getStyles().length;
  5706. var sums = this.markerClusterer_.getCalculator()(this.markers_, numStyles);
  5707. this.clusterIcon_.setCenter(this.center_);
  5708. this.clusterIcon_.useStyle(sums);
  5709. this.clusterIcon_.show();
  5710. };
  5711. /**
  5712. * Determines if a marker has already been added to the cluster.
  5713. *
  5714. * @param {google.maps.Marker} marker The marker to check.
  5715. * @return {boolean} True if the marker has already been added.
  5716. */
  5717. Cluster.prototype.isMarkerAlreadyAdded_ = function (marker) {
  5718. var i;
  5719. if (this.markers_.indexOf) {
  5720. return this.markers_.indexOf(marker) !== -1;
  5721. } else {
  5722. for (i = 0; i < this.markers_.length; i++) {
  5723. if (marker === this.markers_[i]) {
  5724. return true;
  5725. }
  5726. }
  5727. }
  5728. return false;
  5729. };
  5730. /**
  5731. * @name MarkerClustererOptions
  5732. * @class This class represents the optional parameter passed to
  5733. * the {@link MarkerClusterer} constructor.
  5734. * @property {number} [gridSize=60] The grid size of a cluster in pixels. The grid is a square.
  5735. * @property {number} [maxZoom=null] The maximum zoom level at which clustering is enabled or
  5736. * <code>null</code> if clustering is to be enabled at all zoom levels.
  5737. * @property {boolean} [zoomOnClick=true] Whether to zoom the map when a cluster marker is
  5738. * clicked. You may want to set this to <code>false</code> if you have installed a handler
  5739. * for the <code>click</code> event and it deals with zooming on its own.
  5740. * @property {boolean} [averageCenter=false] Whether the position of a cluster marker should be
  5741. * the average position of all markers in the cluster. If set to <code>false</code>, the
  5742. * cluster marker is positioned at the location of the first marker added to the cluster.
  5743. * @property {number} [minimumClusterSize=2] The minimum number of markers needed in a cluster
  5744. * before the markers are hidden and a cluster marker appears.
  5745. * @property {boolean} [ignoreHidden=false] Whether to ignore hidden markers in clusters. You
  5746. * may want to set this to <code>true</code> to ensure that hidden markers are not included
  5747. * in the marker count that appears on a cluster marker (this count is the value of the
  5748. * <code>text</code> property of the result returned by the default <code>calculator</code>).
  5749. * If set to <code>true</code> and you change the visibility of a marker being clustered, be
  5750. * sure to also call <code>MarkerClusterer.repaint()</code>.
  5751. * @property {string} [title=""] The tooltip to display when the mouse moves over a cluster
  5752. * marker. (Alternatively, you can use a custom <code>calculator</code> function to specify a
  5753. * different tooltip for each cluster marker.)
  5754. * @property {function} [calculator=MarkerClusterer.CALCULATOR] The function used to determine
  5755. * the text to be displayed on a cluster marker and the index indicating which style to use
  5756. * for the cluster marker. The input parameters for the function are (1) the array of markers
  5757. * represented by a cluster marker and (2) the number of cluster icon styles. It returns a
  5758. * {@link ClusterIconInfo} object. The default <code>calculator</code> returns a
  5759. * <code>text</code> property which is the number of markers in the cluster and an
  5760. * <code>index</code> property which is one higher than the lowest integer such that
  5761. * <code>10^i</code> exceeds the number of markers in the cluster, or the size of the styles
  5762. * array, whichever is less. The <code>styles</code> array element used has an index of
  5763. * <code>index</code> minus 1. For example, the default <code>calculator</code> returns a
  5764. * <code>text</code> value of <code>"125"</code> and an <code>index</code> of <code>3</code>
  5765. * for a cluster icon representing 125 markers so the element used in the <code>styles</code>
  5766. * array is <code>2</code>. A <code>calculator</code> may also return a <code>title</code>
  5767. * property that contains the text of the tooltip to be used for the cluster marker. If
  5768. * <code>title</code> is not defined, the tooltip is set to the value of the <code>title</code>
  5769. * property for the MarkerClusterer.
  5770. * @property {string} [clusterClass="cluster"] The name of the CSS class defining general styles
  5771. * for the cluster markers. Use this class to define CSS styles that are not set up by the code
  5772. * that processes the <code>styles</code> array.
  5773. * @property {Array} [styles] An array of {@link ClusterIconStyle} elements defining the styles
  5774. * of the cluster markers to be used. The element to be used to style a given cluster marker
  5775. * is determined by the function defined by the <code>calculator</code> property.
  5776. * The default is an array of {@link ClusterIconStyle} elements whose properties are derived
  5777. * from the values for <code>imagePath</code>, <code>imageExtension</code>, and
  5778. * <code>imageSizes</code>.
  5779. * @property {boolean} [enableRetinaIcons=false] Whether to allow the use of cluster icons that
  5780. * have sizes that are some multiple (typically double) of their actual display size. Icons such
  5781. * as these look better when viewed on high-resolution monitors such as Apple's Retina displays.
  5782. * Note: if this property is <code>true</code>, sprites cannot be used as cluster icons.
  5783. * @property {number} [batchSize=MarkerClusterer.BATCH_SIZE] Set this property to the
  5784. * number of markers to be processed in a single batch when using a browser other than
  5785. * Internet Explorer (for Internet Explorer, use the batchSizeIE property instead).
  5786. * @property {number} [batchSizeIE=MarkerClusterer.BATCH_SIZE_IE] When Internet Explorer is
  5787. * being used, markers are processed in several batches with a small delay inserted between
  5788. * each batch in an attempt to avoid Javascript timeout errors. Set this property to the
  5789. * number of markers to be processed in a single batch; select as high a number as you can
  5790. * without causing a timeout error in the browser. This number might need to be as low as 100
  5791. * if 15,000 markers are being managed, for example.
  5792. * @property {string} [imagePath=MarkerClusterer.IMAGE_PATH]
  5793. * The full URL of the root name of the group of image files to use for cluster icons.
  5794. * The complete file name is of the form <code>imagePath</code>n.<code>imageExtension</code>
  5795. * where n is the image file number (1, 2, etc.).
  5796. * @property {string} [imageExtension=MarkerClusterer.IMAGE_EXTENSION]
  5797. * The extension name for the cluster icon image files (e.g., <code>"png"</code> or
  5798. * <code>"jpg"</code>).
  5799. * @property {Array} [imageSizes=MarkerClusterer.IMAGE_SIZES]
  5800. * An array of numbers containing the widths of the group of
  5801. * <code>imagePath</code>n.<code>imageExtension</code> image files.
  5802. * (The images are assumed to be square.)
  5803. */
  5804. /**
  5805. * Creates a MarkerClusterer object with the options specified in {@link MarkerClustererOptions}.
  5806. * @constructor
  5807. * @extends google.maps.OverlayView
  5808. * @param {google.maps.Map} map The Google map to attach to.
  5809. * @param {Array.<google.maps.Marker>} [opt_markers] The markers to be added to the cluster.
  5810. * @param {MarkerClustererOptions} [opt_options] The optional parameters.
  5811. */
  5812. function MarkerClusterer(map, opt_markers, opt_options) {
  5813. // MarkerClusterer implements google.maps.OverlayView interface. We use the
  5814. // extend function to extend MarkerClusterer with google.maps.OverlayView
  5815. // because it might not always be available when the code is defined so we
  5816. // look for it at the last possible moment. If it doesn't exist now then
  5817. // there is no point going ahead :)
  5818. this.extend(MarkerClusterer, google.maps.OverlayView);
  5819. opt_markers = opt_markers || [];
  5820. opt_options = opt_options || {};
  5821. this.markers_ = [];
  5822. this.clusters_ = [];
  5823. this.listeners_ = [];
  5824. this.activeMap_ = null;
  5825. this.ready_ = false;
  5826. this.gridSize_ = opt_options.gridSize || 60;
  5827. this.minClusterSize_ = opt_options.minimumClusterSize || 2;
  5828. this.maxZoom_ = opt_options.maxZoom || null;
  5829. this.styles_ = opt_options.styles || [];
  5830. this.title_ = opt_options.title || "";
  5831. this.zoomOnClick_ = true;
  5832. if (opt_options.zoomOnClick !== undefined) {
  5833. this.zoomOnClick_ = opt_options.zoomOnClick;
  5834. }
  5835. this.averageCenter_ = false;
  5836. if (opt_options.averageCenter !== undefined) {
  5837. this.averageCenter_ = opt_options.averageCenter;
  5838. }
  5839. this.ignoreHidden_ = false;
  5840. if (opt_options.ignoreHidden !== undefined) {
  5841. this.ignoreHidden_ = opt_options.ignoreHidden;
  5842. }
  5843. this.enableRetinaIcons_ = false;
  5844. if (opt_options.enableRetinaIcons !== undefined) {
  5845. this.enableRetinaIcons_ = opt_options.enableRetinaIcons;
  5846. }
  5847. this.imagePath_ = opt_options.imagePath || MarkerClusterer.IMAGE_PATH;
  5848. this.imageExtension_ = opt_options.imageExtension || MarkerClusterer.IMAGE_EXTENSION;
  5849. this.imageSizes_ = opt_options.imageSizes || MarkerClusterer.IMAGE_SIZES;
  5850. this.calculator_ = opt_options.calculator || MarkerClusterer.CALCULATOR;
  5851. this.batchSize_ = opt_options.batchSize || MarkerClusterer.BATCH_SIZE;
  5852. this.batchSizeIE_ = opt_options.batchSizeIE || MarkerClusterer.BATCH_SIZE_IE;
  5853. this.clusterClass_ = opt_options.clusterClass || "cluster";
  5854. if (navigator.userAgent.toLowerCase().indexOf("msie") !== -1) {
  5855. // Try to avoid IE timeout when processing a huge number of markers:
  5856. this.batchSize_ = this.batchSizeIE_;
  5857. }
  5858. this.setupStyles_();
  5859. this.addMarkers(opt_markers, true);
  5860. this.setMap(map); // Note: this causes onAdd to be called
  5861. }
  5862. /**
  5863. * Implementation of the onAdd interface method.
  5864. * @ignore
  5865. */
  5866. MarkerClusterer.prototype.onAdd = function () {
  5867. var cMarkerClusterer = this;
  5868. this.activeMap_ = this.getMap();
  5869. this.ready_ = true;
  5870. this.repaint();
  5871. // Add the map event listeners
  5872. this.listeners_ = [
  5873. google.maps.event.addListener(this.getMap(), "zoom_changed", function () {
  5874. cMarkerClusterer.resetViewport_(false);
  5875. // Workaround for this Google bug: when map is at level 0 and "-" of
  5876. // zoom slider is clicked, a "zoom_changed" event is fired even though
  5877. // the map doesn't zoom out any further. In this situation, no "idle"
  5878. // event is triggered so the cluster markers that have been removed
  5879. // do not get redrawn. Same goes for a zoom in at maxZoom.
  5880. if (this.getZoom() === (this.get("minZoom") || 0) || this.getZoom() === this.get("maxZoom")) {
  5881. google.maps.event.trigger(this, "idle");
  5882. }
  5883. }),
  5884. google.maps.event.addListener(this.getMap(), "idle", function () {
  5885. cMarkerClusterer.redraw_();
  5886. })
  5887. ];
  5888. };
  5889. /**
  5890. * Implementation of the onRemove interface method.
  5891. * Removes map event listeners and all cluster icons from the DOM.
  5892. * All managed markers are also put back on the map.
  5893. * @ignore
  5894. */
  5895. MarkerClusterer.prototype.onRemove = function () {
  5896. var i;
  5897. // Put all the managed markers back on the map:
  5898. for (i = 0; i < this.markers_.length; i++) {
  5899. if (this.markers_[i].getMap() !== this.activeMap_) {
  5900. this.markers_[i].setMap(this.activeMap_);
  5901. }
  5902. }
  5903. // Remove all clusters:
  5904. for (i = 0; i < this.clusters_.length; i++) {
  5905. this.clusters_[i].remove();
  5906. }
  5907. this.clusters_ = [];
  5908. // Remove map event listeners:
  5909. for (i = 0; i < this.listeners_.length; i++) {
  5910. google.maps.event.removeListener(this.listeners_[i]);
  5911. }
  5912. this.listeners_ = [];
  5913. this.activeMap_ = null;
  5914. this.ready_ = false;
  5915. };
  5916. /**
  5917. * Implementation of the draw interface method.
  5918. * @ignore
  5919. */
  5920. MarkerClusterer.prototype.draw = function () {};
  5921. /**
  5922. * Sets up the styles object.
  5923. */
  5924. MarkerClusterer.prototype.setupStyles_ = function () {
  5925. var i, size;
  5926. if (this.styles_.length > 0) {
  5927. return;
  5928. }
  5929. for (i = 0; i < this.imageSizes_.length; i++) {
  5930. size = this.imageSizes_[i];
  5931. this.styles_.push({
  5932. url: this.imagePath_ + (i + 1) + "." + this.imageExtension_,
  5933. height: size,
  5934. width: size
  5935. });
  5936. }
  5937. };
  5938. /**
  5939. * Fits the map to the bounds of the markers managed by the clusterer.
  5940. */
  5941. MarkerClusterer.prototype.fitMapToMarkers = function () {
  5942. var i;
  5943. var markers = this.getMarkers();
  5944. var bounds = new google.maps.LatLngBounds();
  5945. for (i = 0; i < markers.length; i++) {
  5946. bounds.extend(markers[i].getPosition());
  5947. }
  5948. this.getMap().fitBounds(bounds);
  5949. };
  5950. /**
  5951. * Returns the value of the <code>gridSize</code> property.
  5952. *
  5953. * @return {number} The grid size.
  5954. */
  5955. MarkerClusterer.prototype.getGridSize = function () {
  5956. return this.gridSize_;
  5957. };
  5958. /**
  5959. * Sets the value of the <code>gridSize</code> property.
  5960. *
  5961. * @param {number} gridSize The grid size.
  5962. */
  5963. MarkerClusterer.prototype.setGridSize = function (gridSize) {
  5964. this.gridSize_ = gridSize;
  5965. };
  5966. /**
  5967. * Returns the value of the <code>minimumClusterSize</code> property.
  5968. *
  5969. * @return {number} The minimum cluster size.
  5970. */
  5971. MarkerClusterer.prototype.getMinimumClusterSize = function () {
  5972. return this.minClusterSize_;
  5973. };
  5974. /**
  5975. * Sets the value of the <code>minimumClusterSize</code> property.
  5976. *
  5977. * @param {number} minimumClusterSize The minimum cluster size.
  5978. */
  5979. MarkerClusterer.prototype.setMinimumClusterSize = function (minimumClusterSize) {
  5980. this.minClusterSize_ = minimumClusterSize;
  5981. };
  5982. /**
  5983. * Returns the value of the <code>maxZoom</code> property.
  5984. *
  5985. * @return {number} The maximum zoom level.
  5986. */
  5987. MarkerClusterer.prototype.getMaxZoom = function () {
  5988. return this.maxZoom_;
  5989. };
  5990. /**
  5991. * Sets the value of the <code>maxZoom</code> property.
  5992. *
  5993. * @param {number} maxZoom The maximum zoom level.
  5994. */
  5995. MarkerClusterer.prototype.setMaxZoom = function (maxZoom) {
  5996. this.maxZoom_ = maxZoom;
  5997. };
  5998. /**
  5999. * Returns the value of the <code>styles</code> property.
  6000. *
  6001. * @return {Array} The array of styles defining the cluster markers to be used.
  6002. */
  6003. MarkerClusterer.prototype.getStyles = function () {
  6004. return this.styles_;
  6005. };
  6006. /**
  6007. * Sets the value of the <code>styles</code> property.
  6008. *
  6009. * @param {Array.<ClusterIconStyle>} styles The array of styles to use.
  6010. */
  6011. MarkerClusterer.prototype.setStyles = function (styles) {
  6012. this.styles_ = styles;
  6013. };
  6014. /**
  6015. * Returns the value of the <code>title</code> property.
  6016. *
  6017. * @return {string} The content of the title text.
  6018. */
  6019. MarkerClusterer.prototype.getTitle = function () {
  6020. return this.title_;
  6021. };
  6022. /**
  6023. * Sets the value of the <code>title</code> property.
  6024. *
  6025. * @param {string} title The value of the title property.
  6026. */
  6027. MarkerClusterer.prototype.setTitle = function (title) {
  6028. this.title_ = title;
  6029. };
  6030. /**
  6031. * Returns the value of the <code>zoomOnClick</code> property.
  6032. *
  6033. * @return {boolean} True if zoomOnClick property is set.
  6034. */
  6035. MarkerClusterer.prototype.getZoomOnClick = function () {
  6036. return this.zoomOnClick_;
  6037. };
  6038. /**
  6039. * Sets the value of the <code>zoomOnClick</code> property.
  6040. *
  6041. * @param {boolean} zoomOnClick The value of the zoomOnClick property.
  6042. */
  6043. MarkerClusterer.prototype.setZoomOnClick = function (zoomOnClick) {
  6044. this.zoomOnClick_ = zoomOnClick;
  6045. };
  6046. /**
  6047. * Returns the value of the <code>averageCenter</code> property.
  6048. *
  6049. * @return {boolean} True if averageCenter property is set.
  6050. */
  6051. MarkerClusterer.prototype.getAverageCenter = function () {
  6052. return this.averageCenter_;
  6053. };
  6054. /**
  6055. * Sets the value of the <code>averageCenter</code> property.
  6056. *
  6057. * @param {boolean} averageCenter The value of the averageCenter property.
  6058. */
  6059. MarkerClusterer.prototype.setAverageCenter = function (averageCenter) {
  6060. this.averageCenter_ = averageCenter;
  6061. };
  6062. /**
  6063. * Returns the value of the <code>ignoreHidden</code> property.
  6064. *
  6065. * @return {boolean} True if ignoreHidden property is set.
  6066. */
  6067. MarkerClusterer.prototype.getIgnoreHidden = function () {
  6068. return this.ignoreHidden_;
  6069. };
  6070. /**
  6071. * Sets the value of the <code>ignoreHidden</code> property.
  6072. *
  6073. * @param {boolean} ignoreHidden The value of the ignoreHidden property.
  6074. */
  6075. MarkerClusterer.prototype.setIgnoreHidden = function (ignoreHidden) {
  6076. this.ignoreHidden_ = ignoreHidden;
  6077. };
  6078. /**
  6079. * Returns the value of the <code>enableRetinaIcons</code> property.
  6080. *
  6081. * @return {boolean} True if enableRetinaIcons property is set.
  6082. */
  6083. MarkerClusterer.prototype.getEnableRetinaIcons = function () {
  6084. return this.enableRetinaIcons_;
  6085. };
  6086. /**
  6087. * Sets the value of the <code>enableRetinaIcons</code> property.
  6088. *
  6089. * @param {boolean} enableRetinaIcons The value of the enableRetinaIcons property.
  6090. */
  6091. MarkerClusterer.prototype.setEnableRetinaIcons = function (enableRetinaIcons) {
  6092. this.enableRetinaIcons_ = enableRetinaIcons;
  6093. };
  6094. /**
  6095. * Returns the value of the <code>imageExtension</code> property.
  6096. *
  6097. * @return {string} The value of the imageExtension property.
  6098. */
  6099. MarkerClusterer.prototype.getImageExtension = function () {
  6100. return this.imageExtension_;
  6101. };
  6102. /**
  6103. * Sets the value of the <code>imageExtension</code> property.
  6104. *
  6105. * @param {string} imageExtension The value of the imageExtension property.
  6106. */
  6107. MarkerClusterer.prototype.setImageExtension = function (imageExtension) {
  6108. this.imageExtension_ = imageExtension;
  6109. };
  6110. /**
  6111. * Returns the value of the <code>imagePath</code> property.
  6112. *
  6113. * @return {string} The value of the imagePath property.
  6114. */
  6115. MarkerClusterer.prototype.getImagePath = function () {
  6116. return this.imagePath_;
  6117. };
  6118. /**
  6119. * Sets the value of the <code>imagePath</code> property.
  6120. *
  6121. * @param {string} imagePath The value of the imagePath property.
  6122. */
  6123. MarkerClusterer.prototype.setImagePath = function (imagePath) {
  6124. this.imagePath_ = imagePath;
  6125. };
  6126. /**
  6127. * Returns the value of the <code>imageSizes</code> property.
  6128. *
  6129. * @return {Array} The value of the imageSizes property.
  6130. */
  6131. MarkerClusterer.prototype.getImageSizes = function () {
  6132. return this.imageSizes_;
  6133. };
  6134. /**
  6135. * Sets the value of the <code>imageSizes</code> property.
  6136. *
  6137. * @param {Array} imageSizes The value of the imageSizes property.
  6138. */
  6139. MarkerClusterer.prototype.setImageSizes = function (imageSizes) {
  6140. this.imageSizes_ = imageSizes;
  6141. };
  6142. /**
  6143. * Returns the value of the <code>calculator</code> property.
  6144. *
  6145. * @return {function} the value of the calculator property.
  6146. */
  6147. MarkerClusterer.prototype.getCalculator = function () {
  6148. return this.calculator_;
  6149. };
  6150. /**
  6151. * Sets the value of the <code>calculator</code> property.
  6152. *
  6153. * @param {function(Array.<google.maps.Marker>, number)} calculator The value
  6154. * of the calculator property.
  6155. */
  6156. MarkerClusterer.prototype.setCalculator = function (calculator) {
  6157. this.calculator_ = calculator;
  6158. };
  6159. /**
  6160. * Returns the value of the <code>batchSizeIE</code> property.
  6161. *
  6162. * @return {number} the value of the batchSizeIE property.
  6163. */
  6164. MarkerClusterer.prototype.getBatchSizeIE = function () {
  6165. return this.batchSizeIE_;
  6166. };
  6167. /**
  6168. * Sets the value of the <code>batchSizeIE</code> property.
  6169. *
  6170. * @param {number} batchSizeIE The value of the batchSizeIE property.
  6171. */
  6172. MarkerClusterer.prototype.setBatchSizeIE = function (batchSizeIE) {
  6173. this.batchSizeIE_ = batchSizeIE;
  6174. };
  6175. /**
  6176. * Returns the value of the <code>clusterClass</code> property.
  6177. *
  6178. * @return {string} the value of the clusterClass property.
  6179. */
  6180. MarkerClusterer.prototype.getClusterClass = function () {
  6181. return this.clusterClass_;
  6182. };
  6183. /**
  6184. * Sets the value of the <code>clusterClass</code> property.
  6185. *
  6186. * @param {string} clusterClass The value of the clusterClass property.
  6187. */
  6188. MarkerClusterer.prototype.setClusterClass = function (clusterClass) {
  6189. this.clusterClass_ = clusterClass;
  6190. };
  6191. /**
  6192. * Returns the array of markers managed by the clusterer.
  6193. *
  6194. * @return {Array} The array of markers managed by the clusterer.
  6195. */
  6196. MarkerClusterer.prototype.getMarkers = function () {
  6197. return this.markers_;
  6198. };
  6199. /**
  6200. * Returns the number of markers managed by the clusterer.
  6201. *
  6202. * @return {number} The number of markers.
  6203. */
  6204. MarkerClusterer.prototype.getTotalMarkers = function () {
  6205. return this.markers_.length;
  6206. };
  6207. /**
  6208. * Returns the current array of clusters formed by the clusterer.
  6209. *
  6210. * @return {Array} The array of clusters formed by the clusterer.
  6211. */
  6212. MarkerClusterer.prototype.getClusters = function () {
  6213. return this.clusters_;
  6214. };
  6215. /**
  6216. * Returns the number of clusters formed by the clusterer.
  6217. *
  6218. * @return {number} The number of clusters formed by the clusterer.
  6219. */
  6220. MarkerClusterer.prototype.getTotalClusters = function () {
  6221. return this.clusters_.length;
  6222. };
  6223. /**
  6224. * Adds a marker to the clusterer. The clusters are redrawn unless
  6225. * <code>opt_nodraw</code> is set to <code>true</code>.
  6226. *
  6227. * @param {google.maps.Marker} marker The marker to add.
  6228. * @param {boolean} [opt_nodraw] Set to <code>true</code> to prevent redrawing.
  6229. */
  6230. MarkerClusterer.prototype.addMarker = function (marker, opt_nodraw) {
  6231. this.pushMarkerTo_(marker);
  6232. if (!opt_nodraw) {
  6233. this.redraw_();
  6234. }
  6235. };
  6236. /**
  6237. * Adds an array of markers to the clusterer. The clusters are redrawn unless
  6238. * <code>opt_nodraw</code> is set to <code>true</code>.
  6239. *
  6240. * @param {Array.<google.maps.Marker>} markers The markers to add.
  6241. * @param {boolean} [opt_nodraw] Set to <code>true</code> to prevent redrawing.
  6242. */
  6243. MarkerClusterer.prototype.addMarkers = function (markers, opt_nodraw) {
  6244. var key;
  6245. for (key in markers) {
  6246. if (markers.hasOwnProperty(key)) {
  6247. this.pushMarkerTo_(markers[key]);
  6248. }
  6249. }
  6250. if (!opt_nodraw) {
  6251. this.redraw_();
  6252. }
  6253. };
  6254. /**
  6255. * Pushes a marker to the clusterer.
  6256. *
  6257. * @param {google.maps.Marker} marker The marker to add.
  6258. */
  6259. MarkerClusterer.prototype.pushMarkerTo_ = function (marker) {
  6260. // If the marker is draggable add a listener so we can update the clusters on the dragend:
  6261. if (marker.getDraggable()) {
  6262. var cMarkerClusterer = this;
  6263. google.maps.event.addListener(marker, "dragend", function () {
  6264. if (cMarkerClusterer.ready_) {
  6265. this.isAdded = false;
  6266. cMarkerClusterer.repaint();
  6267. }
  6268. });
  6269. }
  6270. marker.isAdded = false;
  6271. this.markers_.push(marker);
  6272. };
  6273. /**
  6274. * Removes a marker from the cluster. The clusters are redrawn unless
  6275. * <code>opt_nodraw</code> is set to <code>true</code>. Returns <code>true</code> if the
  6276. * marker was removed from the clusterer.
  6277. *
  6278. * @param {google.maps.Marker} marker The marker to remove.
  6279. * @param {boolean} [opt_nodraw] Set to <code>true</code> to prevent redrawing.
  6280. * @return {boolean} True if the marker was removed from the clusterer.
  6281. */
  6282. MarkerClusterer.prototype.removeMarker = function (marker, opt_nodraw) {
  6283. var removed = this.removeMarker_(marker);
  6284. if (!opt_nodraw && removed) {
  6285. this.repaint();
  6286. }
  6287. return removed;
  6288. };
  6289. /**
  6290. * Removes an array of markers from the cluster. The clusters are redrawn unless
  6291. * <code>opt_nodraw</code> is set to <code>true</code>. Returns <code>true</code> if markers
  6292. * were removed from the clusterer.
  6293. *
  6294. * @param {Array.<google.maps.Marker>} markers The markers to remove.
  6295. * @param {boolean} [opt_nodraw] Set to <code>true</code> to prevent redrawing.
  6296. * @return {boolean} True if markers were removed from the clusterer.
  6297. */
  6298. MarkerClusterer.prototype.removeMarkers = function (markers, opt_nodraw) {
  6299. var i, r;
  6300. var removed = false;
  6301. for (i = 0; i < markers.length; i++) {
  6302. r = this.removeMarker_(markers[i]);
  6303. removed = removed || r;
  6304. }
  6305. if (!opt_nodraw && removed) {
  6306. this.repaint();
  6307. }
  6308. return removed;
  6309. };
  6310. /**
  6311. * Removes a marker and returns true if removed, false if not.
  6312. *
  6313. * @param {google.maps.Marker} marker The marker to remove
  6314. * @return {boolean} Whether the marker was removed or not
  6315. */
  6316. MarkerClusterer.prototype.removeMarker_ = function (marker) {
  6317. var i;
  6318. var index = -1;
  6319. if (this.markers_.indexOf) {
  6320. index = this.markers_.indexOf(marker);
  6321. } else {
  6322. for (i = 0; i < this.markers_.length; i++) {
  6323. if (marker === this.markers_[i]) {
  6324. index = i;
  6325. break;
  6326. }
  6327. }
  6328. }
  6329. if (index === -1) {
  6330. // Marker is not in our list of markers, so do nothing:
  6331. return false;
  6332. }
  6333. marker.setMap(null);
  6334. this.markers_.splice(index, 1); // Remove the marker from the list of managed markers
  6335. return true;
  6336. };
  6337. /**
  6338. * Removes all clusters and markers from the map and also removes all markers
  6339. * managed by the clusterer.
  6340. */
  6341. MarkerClusterer.prototype.clearMarkers = function () {
  6342. this.resetViewport_(true);
  6343. this.markers_ = [];
  6344. };
  6345. /**
  6346. * Recalculates and redraws all the marker clusters from scratch.
  6347. * Call this after changing any properties.
  6348. */
  6349. MarkerClusterer.prototype.repaint = function () {
  6350. var oldClusters = this.clusters_.slice();
  6351. this.clusters_ = [];
  6352. this.resetViewport_(false);
  6353. this.redraw_();
  6354. // Remove the old clusters.
  6355. // Do it in a timeout to prevent blinking effect.
  6356. setTimeout(function () {
  6357. var i;
  6358. for (i = 0; i < oldClusters.length; i++) {
  6359. oldClusters[i].remove();
  6360. }
  6361. }, 0);
  6362. };
  6363. /**
  6364. * Returns the current bounds extended by the grid size.
  6365. *
  6366. * @param {google.maps.LatLngBounds} bounds The bounds to extend.
  6367. * @return {google.maps.LatLngBounds} The extended bounds.
  6368. * @ignore
  6369. */
  6370. MarkerClusterer.prototype.getExtendedBounds = function (bounds) {
  6371. var projection = this.getProjection();
  6372. // Turn the bounds into latlng.
  6373. var tr = new google.maps.LatLng(bounds.getNorthEast().lat(),
  6374. bounds.getNorthEast().lng());
  6375. var bl = new google.maps.LatLng(bounds.getSouthWest().lat(),
  6376. bounds.getSouthWest().lng());
  6377. // Convert the points to pixels and the extend out by the grid size.
  6378. var trPix = projection.fromLatLngToDivPixel(tr);
  6379. trPix.x += this.gridSize_;
  6380. trPix.y -= this.gridSize_;
  6381. var blPix = projection.fromLatLngToDivPixel(bl);
  6382. blPix.x -= this.gridSize_;
  6383. blPix.y += this.gridSize_;
  6384. // Convert the pixel points back to LatLng
  6385. var ne = projection.fromDivPixelToLatLng(trPix);
  6386. var sw = projection.fromDivPixelToLatLng(blPix);
  6387. // Extend the bounds to contain the new bounds.
  6388. bounds.extend(ne);
  6389. bounds.extend(sw);
  6390. return bounds;
  6391. };
  6392. /**
  6393. * Redraws all the clusters.
  6394. */
  6395. MarkerClusterer.prototype.redraw_ = function () {
  6396. this.createClusters_(0);
  6397. };
  6398. /**
  6399. * Removes all clusters from the map. The markers are also removed from the map
  6400. * if <code>opt_hide</code> is set to <code>true</code>.
  6401. *
  6402. * @param {boolean} [opt_hide] Set to <code>true</code> to also remove the markers
  6403. * from the map.
  6404. */
  6405. MarkerClusterer.prototype.resetViewport_ = function (opt_hide) {
  6406. var i, marker;
  6407. // Remove all the clusters
  6408. for (i = 0; i < this.clusters_.length; i++) {
  6409. this.clusters_[i].remove();
  6410. }
  6411. this.clusters_ = [];
  6412. // Reset the markers to not be added and to be removed from the map.
  6413. for (i = 0; i < this.markers_.length; i++) {
  6414. marker = this.markers_[i];
  6415. marker.isAdded = false;
  6416. if (opt_hide) {
  6417. marker.setMap(null);
  6418. }
  6419. }
  6420. };
  6421. /**
  6422. * Calculates the distance between two latlng locations in km.
  6423. *
  6424. * @param {google.maps.LatLng} p1 The first lat lng point.
  6425. * @param {google.maps.LatLng} p2 The second lat lng point.
  6426. * @return {number} The distance between the two points in km.
  6427. * @see http://www.movable-type.co.uk/scripts/latlong.html
  6428. */
  6429. MarkerClusterer.prototype.distanceBetweenPoints_ = function (p1, p2) {
  6430. var R = 6371; // Radius of the Earth in km
  6431. var dLat = (p2.lat() - p1.lat()) * Math.PI / 180;
  6432. var dLon = (p2.lng() - p1.lng()) * Math.PI / 180;
  6433. var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
  6434. Math.cos(p1.lat() * Math.PI / 180) * Math.cos(p2.lat() * Math.PI / 180) *
  6435. Math.sin(dLon / 2) * Math.sin(dLon / 2);
  6436. var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  6437. var d = R * c;
  6438. return d;
  6439. };
  6440. /**
  6441. * Determines if a marker is contained in a bounds.
  6442. *
  6443. * @param {google.maps.Marker} marker The marker to check.
  6444. * @param {google.maps.LatLngBounds} bounds The bounds to check against.
  6445. * @return {boolean} True if the marker is in the bounds.
  6446. */
  6447. MarkerClusterer.prototype.isMarkerInBounds_ = function (marker, bounds) {
  6448. return bounds.contains(marker.getPosition());
  6449. };
  6450. /**
  6451. * Adds a marker to a cluster, or creates a new cluster.
  6452. *
  6453. * @param {google.maps.Marker} marker The marker to add.
  6454. */
  6455. MarkerClusterer.prototype.addToClosestCluster_ = function (marker) {
  6456. var i, d, cluster, center;
  6457. var distance = 40000; // Some large number
  6458. var clusterToAddTo = null;
  6459. for (i = 0; i < this.clusters_.length; i++) {
  6460. cluster = this.clusters_[i];
  6461. center = cluster.getCenter();
  6462. if (center) {
  6463. d = this.distanceBetweenPoints_(center, marker.getPosition());
  6464. if (d < distance) {
  6465. distance = d;
  6466. clusterToAddTo = cluster;
  6467. }
  6468. }
  6469. }
  6470. if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {
  6471. clusterToAddTo.addMarker(marker);
  6472. } else {
  6473. cluster = new Cluster(this);
  6474. cluster.addMarker(marker);
  6475. this.clusters_.push(cluster);
  6476. }
  6477. };
  6478. /**
  6479. * Creates the clusters. This is done in batches to avoid timeout errors
  6480. * in some browsers when there is a huge number of markers.
  6481. *
  6482. * @param {number} iFirst The index of the first marker in the batch of
  6483. * markers to be added to clusters.
  6484. */
  6485. MarkerClusterer.prototype.createClusters_ = function (iFirst) {
  6486. var i, marker;
  6487. var mapBounds;
  6488. var cMarkerClusterer = this;
  6489. if (!this.ready_) {
  6490. return;
  6491. }
  6492. // Cancel previous batch processing if we're working on the first batch:
  6493. if (iFirst === 0) {
  6494. /**
  6495. * This event is fired when the <code>MarkerClusterer</code> begins
  6496. * clustering markers.
  6497. * @name MarkerClusterer#clusteringbegin
  6498. * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.
  6499. * @event
  6500. */
  6501. google.maps.event.trigger(this, "clusteringbegin", this);
  6502. if (typeof this.timerRefStatic !== "undefined") {
  6503. clearTimeout(this.timerRefStatic);
  6504. delete this.timerRefStatic;
  6505. }
  6506. }
  6507. // Get our current map view bounds.
  6508. // Create a new bounds object so we don't affect the map.
  6509. //
  6510. // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
  6511. if (this.getMap().getZoom() > 3) {
  6512. mapBounds = new google.maps.LatLngBounds(this.getMap().getBounds().getSouthWest(),
  6513. this.getMap().getBounds().getNorthEast());
  6514. } else {
  6515. mapBounds = new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));
  6516. }
  6517. var bounds = this.getExtendedBounds(mapBounds);
  6518. var iLast = Math.min(iFirst + this.batchSize_, this.markers_.length);
  6519. for (i = iFirst; i < iLast; i++) {
  6520. marker = this.markers_[i];
  6521. if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) {
  6522. if (!this.ignoreHidden_ || (this.ignoreHidden_ && marker.getVisible())) {
  6523. this.addToClosestCluster_(marker);
  6524. }
  6525. }
  6526. }
  6527. if (iLast < this.markers_.length) {
  6528. this.timerRefStatic = setTimeout(function () {
  6529. cMarkerClusterer.createClusters_(iLast);
  6530. }, 0);
  6531. } else {
  6532. delete this.timerRefStatic;
  6533. /**
  6534. * This event is fired when the <code>MarkerClusterer</code> stops
  6535. * clustering markers.
  6536. * @name MarkerClusterer#clusteringend
  6537. * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.
  6538. * @event
  6539. */
  6540. google.maps.event.trigger(this, "clusteringend", this);
  6541. }
  6542. };
  6543. /**
  6544. * Extends an object's prototype by another's.
  6545. *
  6546. * @param {Object} obj1 The object to be extended.
  6547. * @param {Object} obj2 The object to extend with.
  6548. * @return {Object} The new extended object.
  6549. * @ignore
  6550. */
  6551. MarkerClusterer.prototype.extend = function (obj1, obj2) {
  6552. return (function (object) {
  6553. var property;
  6554. for (property in object.prototype) {
  6555. this.prototype[property] = object.prototype[property];
  6556. }
  6557. return this;
  6558. }).apply(obj1, [obj2]);
  6559. };
  6560. /**
  6561. * The default function for determining the label text and style
  6562. * for a cluster icon.
  6563. *
  6564. * @param {Array.<google.maps.Marker>} markers The array of markers represented by the cluster.
  6565. * @param {number} numStyles The number of marker styles available.
  6566. * @return {ClusterIconInfo} The information resource for the cluster.
  6567. * @constant
  6568. * @ignore
  6569. */
  6570. MarkerClusterer.CALCULATOR = function (markers, numStyles) {
  6571. var index = 0;
  6572. var title = "";
  6573. var count = markers.length.toString();
  6574. var dv = count;
  6575. while (dv !== 0) {
  6576. dv = parseInt(dv / 10, 10);
  6577. index++;
  6578. }
  6579. index = Math.min(index, numStyles);
  6580. return {
  6581. text: count,
  6582. index: index,
  6583. title: title
  6584. };
  6585. };
  6586. /**
  6587. * The number of markers to process in one batch.
  6588. *
  6589. * @type {number}
  6590. * @constant
  6591. */
  6592. MarkerClusterer.BATCH_SIZE = 2000;
  6593. /**
  6594. * The number of markers to process in one batch (IE only).
  6595. *
  6596. * @type {number}
  6597. * @constant
  6598. */
  6599. MarkerClusterer.BATCH_SIZE_IE = 500;
  6600. /**
  6601. * The default root name for the marker cluster images.
  6602. *
  6603. * @type {string}
  6604. * @constant
  6605. */
  6606. MarkerClusterer.IMAGE_PATH = "http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m";
  6607. /**
  6608. * The default extension name for the marker cluster images.
  6609. *
  6610. * @type {string}
  6611. * @constant
  6612. */
  6613. MarkerClusterer.IMAGE_EXTENSION = "png";
  6614. /**
  6615. * The default array of sizes for the marker cluster images.
  6616. *
  6617. * @type {Array.<number>}
  6618. * @constant
  6619. */
  6620. MarkerClusterer.IMAGE_SIZES = [53, 56, 66, 78, 90];
  6621. if (typeof String.prototype.trim !== 'function') {
  6622. /**
  6623. * IE hack since trim() doesn't exist in all browsers
  6624. * @return {string} The string with removed whitespace
  6625. */
  6626. String.prototype.trim = function() {
  6627. return this.replace(/^\s+|\s+$/g, '');
  6628. }
  6629. }
  6630. ;/**
  6631. * 1.1.9-patched
  6632. * @name MarkerWithLabel for V3
  6633. * @version 1.1.8 [February 26, 2013]
  6634. * @author Gary Little (inspired by code from Marc Ridey of Google).
  6635. * @copyright Copyright 2012 Gary Little [gary at luxcentral.com]
  6636. * @fileoverview MarkerWithLabel extends the Google Maps JavaScript API V3
  6637. * <code>google.maps.Marker</code> class.
  6638. * <p>
  6639. * MarkerWithLabel allows you to define markers with associated labels. As you would expect,
  6640. * if the marker is draggable, so too will be the label. In addition, a marker with a label
  6641. * responds to all mouse events in the same manner as a regular marker. It also fires mouse
  6642. * events and "property changed" events just as a regular marker would. Version 1.1 adds
  6643. * support for the raiseOnDrag feature introduced in API V3.3.
  6644. * <p>
  6645. * If you drag a marker by its label, you can cancel the drag and return the marker to its
  6646. * original position by pressing the <code>Esc</code> key. This doesn't work if you drag the marker
  6647. * itself because this feature is not (yet) supported in the <code>google.maps.Marker</code> class.
  6648. */
  6649. /*!
  6650. *
  6651. * Licensed under the Apache License, Version 2.0 (the "License");
  6652. * you may not use this file except in compliance with the License.
  6653. * You may obtain a copy of the License at
  6654. *
  6655. * http://www.apache.org/licenses/LICENSE-2.0
  6656. *
  6657. * Unless required by applicable law or agreed to in writing, software
  6658. * distributed under the License is distributed on an "AS IS" BASIS,
  6659. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  6660. * See the License for the specific language governing permissions and
  6661. * limitations under the License.
  6662. */
  6663. /*jslint browser:true */
  6664. /*global document,google */
  6665. /**
  6666. * @param {Function} childCtor Child class.
  6667. * @param {Function} parentCtor Parent class.
  6668. */
  6669. function inherits(childCtor, parentCtor) {
  6670. /** @constructor */
  6671. function tempCtor() {}
  6672. tempCtor.prototype = parentCtor.prototype;
  6673. childCtor.superClass_ = parentCtor.prototype;
  6674. childCtor.prototype = new tempCtor();
  6675. /** @override */
  6676. childCtor.prototype.constructor = childCtor;
  6677. }
  6678. /**
  6679. * This constructor creates a label and associates it with a marker.
  6680. * It is for the private use of the MarkerWithLabel class.
  6681. * @constructor
  6682. * @param {Marker} marker The marker with which the label is to be associated.
  6683. * @param {string} crossURL The URL of the cross image =.
  6684. * @param {string} handCursor The URL of the hand cursor.
  6685. * @private
  6686. */
  6687. function MarkerLabel_(marker, crossURL, handCursorURL) {
  6688. this.marker_ = marker;
  6689. this.handCursorURL_ = marker.handCursorURL;
  6690. this.labelDiv_ = document.createElement("div");
  6691. this.labelDiv_.style.cssText = "position: absolute; overflow: hidden;";
  6692. // Set up the DIV for handling mouse events in the label. This DIV forms a transparent veil
  6693. // in the "overlayMouseTarget" pane, a veil that covers just the label. This is done so that
  6694. // events can be captured even if the label is in the shadow of a google.maps.InfoWindow.
  6695. // Code is included here to ensure the veil is always exactly the same size as the label.
  6696. this.eventDiv_ = document.createElement("div");
  6697. this.eventDiv_.style.cssText = this.labelDiv_.style.cssText;
  6698. // This is needed for proper behavior on MSIE:
  6699. this.eventDiv_.setAttribute("onselectstart", "return false;");
  6700. this.eventDiv_.setAttribute("ondragstart", "return false;");
  6701. // Get the DIV for the "X" to be displayed when the marker is raised.
  6702. this.crossDiv_ = MarkerLabel_.getSharedCross(crossURL);
  6703. }
  6704. inherits(MarkerLabel_, google.maps.OverlayView);
  6705. /**
  6706. * Returns the DIV for the cross used when dragging a marker when the
  6707. * raiseOnDrag parameter set to true. One cross is shared with all markers.
  6708. * @param {string} crossURL The URL of the cross image =.
  6709. * @private
  6710. */
  6711. MarkerLabel_.getSharedCross = function (crossURL) {
  6712. var div;
  6713. if (typeof MarkerLabel_.getSharedCross.crossDiv === "undefined") {
  6714. div = document.createElement("img");
  6715. div.style.cssText = "position: absolute; z-index: 1000002; display: none;";
  6716. // Hopefully Google never changes the standard "X" attributes:
  6717. div.style.marginLeft = "-8px";
  6718. div.style.marginTop = "-9px";
  6719. div.src = crossURL;
  6720. MarkerLabel_.getSharedCross.crossDiv = div;
  6721. }
  6722. return MarkerLabel_.getSharedCross.crossDiv;
  6723. };
  6724. /**
  6725. * Adds the DIV representing the label to the DOM. This method is called
  6726. * automatically when the marker's <code>setMap</code> method is called.
  6727. * @private
  6728. */
  6729. MarkerLabel_.prototype.onAdd = function () {
  6730. var me = this;
  6731. var cMouseIsDown = false;
  6732. var cDraggingLabel = false;
  6733. var cSavedZIndex;
  6734. var cLatOffset, cLngOffset;
  6735. var cIgnoreClick;
  6736. var cRaiseEnabled;
  6737. var cStartPosition;
  6738. var cStartCenter;
  6739. // Constants:
  6740. var cRaiseOffset = 20;
  6741. var cDraggingCursor = "url(" + this.handCursorURL_ + ")";
  6742. // Stops all processing of an event.
  6743. //
  6744. var cAbortEvent = function (e) {
  6745. if (e.preventDefault) {
  6746. e.preventDefault();
  6747. }
  6748. e.cancelBubble = true;
  6749. if (e.stopPropagation) {
  6750. e.stopPropagation();
  6751. }
  6752. };
  6753. var cStopBounce = function () {
  6754. me.marker_.setAnimation(null);
  6755. };
  6756. this.getPanes().overlayImage.appendChild(this.labelDiv_);
  6757. this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_);
  6758. // One cross is shared with all markers, so only add it once:
  6759. if (typeof MarkerLabel_.getSharedCross.processed === "undefined") {
  6760. this.getPanes().overlayImage.appendChild(this.crossDiv_);
  6761. MarkerLabel_.getSharedCross.processed = true;
  6762. }
  6763. this.listeners_ = [
  6764. google.maps.event.addDomListener(this.eventDiv_, "mouseover", function (e) {
  6765. if (me.marker_.getDraggable() || me.marker_.getClickable()) {
  6766. this.style.cursor = "pointer";
  6767. google.maps.event.trigger(me.marker_, "mouseover", e);
  6768. }
  6769. }),
  6770. google.maps.event.addDomListener(this.eventDiv_, "mouseout", function (e) {
  6771. if ((me.marker_.getDraggable() || me.marker_.getClickable()) && !cDraggingLabel) {
  6772. this.style.cursor = me.marker_.getCursor();
  6773. google.maps.event.trigger(me.marker_, "mouseout", e);
  6774. }
  6775. }),
  6776. google.maps.event.addDomListener(this.eventDiv_, "mousedown", function (e) {
  6777. cDraggingLabel = false;
  6778. if (me.marker_.getDraggable()) {
  6779. cMouseIsDown = true;
  6780. this.style.cursor = cDraggingCursor;
  6781. }
  6782. if (me.marker_.getDraggable() || me.marker_.getClickable()) {
  6783. google.maps.event.trigger(me.marker_, "mousedown", e);
  6784. cAbortEvent(e); // Prevent map pan when starting a drag on a label
  6785. }
  6786. }),
  6787. google.maps.event.addDomListener(document, "mouseup", function (mEvent) {
  6788. var position;
  6789. if (cMouseIsDown) {
  6790. cMouseIsDown = false;
  6791. me.eventDiv_.style.cursor = "pointer";
  6792. google.maps.event.trigger(me.marker_, "mouseup", mEvent);
  6793. }
  6794. if (cDraggingLabel) {
  6795. if (cRaiseEnabled) { // Lower the marker & label
  6796. position = me.getProjection().fromLatLngToDivPixel(me.marker_.getPosition());
  6797. position.y += cRaiseOffset;
  6798. me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));
  6799. // This is not the same bouncing style as when the marker portion is dragged,
  6800. // but it will have to do:
  6801. try { // Will fail if running Google Maps API earlier than V3.3
  6802. me.marker_.setAnimation(google.maps.Animation.BOUNCE);
  6803. setTimeout(cStopBounce, 1406);
  6804. } catch (e) {}
  6805. }
  6806. me.crossDiv_.style.display = "none";
  6807. me.marker_.setZIndex(cSavedZIndex);
  6808. cIgnoreClick = true; // Set flag to ignore the click event reported after a label drag
  6809. cDraggingLabel = false;
  6810. mEvent.latLng = me.marker_.getPosition();
  6811. google.maps.event.trigger(me.marker_, "dragend", mEvent);
  6812. }
  6813. }),
  6814. google.maps.event.addListener(me.marker_.getMap(), "mousemove", function (mEvent) {
  6815. var position;
  6816. if (cMouseIsDown) {
  6817. if (cDraggingLabel) {
  6818. // Change the reported location from the mouse position to the marker position:
  6819. mEvent.latLng = new google.maps.LatLng(mEvent.latLng.lat() - cLatOffset, mEvent.latLng.lng() - cLngOffset);
  6820. position = me.getProjection().fromLatLngToDivPixel(mEvent.latLng);
  6821. if (cRaiseEnabled) {
  6822. me.crossDiv_.style.left = position.x + "px";
  6823. me.crossDiv_.style.top = position.y + "px";
  6824. me.crossDiv_.style.display = "";
  6825. position.y -= cRaiseOffset;
  6826. }
  6827. me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));
  6828. if (cRaiseEnabled) { // Don't raise the veil; this hack needed to make MSIE act properly
  6829. me.eventDiv_.style.top = (position.y + cRaiseOffset) + "px";
  6830. }
  6831. google.maps.event.trigger(me.marker_, "drag", mEvent);
  6832. } else {
  6833. // Calculate offsets from the click point to the marker position:
  6834. cLatOffset = mEvent.latLng.lat() - me.marker_.getPosition().lat();
  6835. cLngOffset = mEvent.latLng.lng() - me.marker_.getPosition().lng();
  6836. cSavedZIndex = me.marker_.getZIndex();
  6837. cStartPosition = me.marker_.getPosition();
  6838. cStartCenter = me.marker_.getMap().getCenter();
  6839. cRaiseEnabled = me.marker_.get("raiseOnDrag");
  6840. cDraggingLabel = true;
  6841. me.marker_.setZIndex(1000000); // Moves the marker & label to the foreground during a drag
  6842. mEvent.latLng = me.marker_.getPosition();
  6843. google.maps.event.trigger(me.marker_, "dragstart", mEvent);
  6844. }
  6845. }
  6846. }),
  6847. google.maps.event.addDomListener(document, "keydown", function (e) {
  6848. if (cDraggingLabel) {
  6849. if (e.keyCode === 27) { // Esc key
  6850. cRaiseEnabled = false;
  6851. me.marker_.setPosition(cStartPosition);
  6852. me.marker_.getMap().setCenter(cStartCenter);
  6853. google.maps.event.trigger(document, "mouseup", e);
  6854. }
  6855. }
  6856. }),
  6857. google.maps.event.addDomListener(this.eventDiv_, "click", function (e) {
  6858. if (me.marker_.getDraggable() || me.marker_.getClickable()) {
  6859. if (cIgnoreClick) { // Ignore the click reported when a label drag ends
  6860. cIgnoreClick = false;
  6861. } else {
  6862. google.maps.event.trigger(me.marker_, "click", e);
  6863. cAbortEvent(e); // Prevent click from being passed on to map
  6864. }
  6865. }
  6866. }),
  6867. google.maps.event.addDomListener(this.eventDiv_, "dblclick", function (e) {
  6868. if (me.marker_.getDraggable() || me.marker_.getClickable()) {
  6869. google.maps.event.trigger(me.marker_, "dblclick", e);
  6870. cAbortEvent(e); // Prevent map zoom when double-clicking on a label
  6871. }
  6872. }),
  6873. google.maps.event.addListener(this.marker_, "dragstart", function (mEvent) {
  6874. if (!cDraggingLabel) {
  6875. cRaiseEnabled = this.get("raiseOnDrag");
  6876. }
  6877. }),
  6878. google.maps.event.addListener(this.marker_, "drag", function (mEvent) {
  6879. if (!cDraggingLabel) {
  6880. if (cRaiseEnabled) {
  6881. me.setPosition(cRaiseOffset);
  6882. // During a drag, the marker's z-index is temporarily set to 1000000 to
  6883. // ensure it appears above all other markers. Also set the label's z-index
  6884. // to 1000000 (plus or minus 1 depending on whether the label is supposed
  6885. // to be above or below the marker).
  6886. me.labelDiv_.style.zIndex = 1000000 + (this.get("labelInBackground") ? -1 : +1);
  6887. }
  6888. }
  6889. }),
  6890. google.maps.event.addListener(this.marker_, "dragend", function (mEvent) {
  6891. if (!cDraggingLabel) {
  6892. if (cRaiseEnabled) {
  6893. me.setPosition(0); // Also restores z-index of label
  6894. }
  6895. }
  6896. }),
  6897. google.maps.event.addListener(this.marker_, "position_changed", function () {
  6898. me.setPosition();
  6899. }),
  6900. google.maps.event.addListener(this.marker_, "zindex_changed", function () {
  6901. me.setZIndex();
  6902. }),
  6903. google.maps.event.addListener(this.marker_, "visible_changed", function () {
  6904. me.setVisible();
  6905. }),
  6906. google.maps.event.addListener(this.marker_, "labelvisible_changed", function () {
  6907. me.setVisible();
  6908. }),
  6909. google.maps.event.addListener(this.marker_, "title_changed", function () {
  6910. me.setTitle();
  6911. }),
  6912. google.maps.event.addListener(this.marker_, "labelcontent_changed", function () {
  6913. me.setContent();
  6914. }),
  6915. google.maps.event.addListener(this.marker_, "labelanchor_changed", function () {
  6916. me.setAnchor();
  6917. }),
  6918. google.maps.event.addListener(this.marker_, "labelclass_changed", function () {
  6919. me.setStyles();
  6920. }),
  6921. google.maps.event.addListener(this.marker_, "labelstyle_changed", function () {
  6922. me.setStyles();
  6923. })
  6924. ];
  6925. };
  6926. /**
  6927. * Removes the DIV for the label from the DOM. It also removes all event handlers.
  6928. * This method is called automatically when the marker's <code>setMap(null)</code>
  6929. * method is called.
  6930. * @private
  6931. */
  6932. MarkerLabel_.prototype.onRemove = function () {
  6933. var i;
  6934. if (this.labelDiv_.parentNode !== null)
  6935. this.labelDiv_.parentNode.removeChild(this.labelDiv_);
  6936. if (this.eventDiv_.parentNode !== null)
  6937. this.eventDiv_.parentNode.removeChild(this.eventDiv_);
  6938. // Remove event listeners:
  6939. for (i = 0; i < this.listeners_.length; i++) {
  6940. google.maps.event.removeListener(this.listeners_[i]);
  6941. }
  6942. };
  6943. /**
  6944. * Draws the label on the map.
  6945. * @private
  6946. */
  6947. MarkerLabel_.prototype.draw = function () {
  6948. this.setContent();
  6949. this.setTitle();
  6950. this.setStyles();
  6951. };
  6952. /**
  6953. * Sets the content of the label.
  6954. * The content can be plain text or an HTML DOM node.
  6955. * @private
  6956. */
  6957. MarkerLabel_.prototype.setContent = function () {
  6958. var content = this.marker_.get("labelContent");
  6959. if (typeof content.nodeType === "undefined") {
  6960. this.labelDiv_.innerHTML = content;
  6961. this.eventDiv_.innerHTML = this.labelDiv_.innerHTML;
  6962. } else {
  6963. this.labelDiv_.innerHTML = ""; // Remove current content
  6964. this.labelDiv_.appendChild(content);
  6965. content = content.cloneNode(true);
  6966. this.eventDiv_.appendChild(content);
  6967. }
  6968. };
  6969. /**
  6970. * Sets the content of the tool tip for the label. It is
  6971. * always set to be the same as for the marker itself.
  6972. * @private
  6973. */
  6974. MarkerLabel_.prototype.setTitle = function () {
  6975. this.eventDiv_.title = this.marker_.getTitle() || "";
  6976. };
  6977. /**
  6978. * Sets the style of the label by setting the style sheet and applying
  6979. * other specific styles requested.
  6980. * @private
  6981. */
  6982. MarkerLabel_.prototype.setStyles = function () {
  6983. var i, labelStyle;
  6984. // Apply style values from the style sheet defined in the labelClass parameter:
  6985. this.labelDiv_.className = this.marker_.get("labelClass");
  6986. this.eventDiv_.className = this.labelDiv_.className;
  6987. // Clear existing inline style values:
  6988. this.labelDiv_.style.cssText = "";
  6989. this.eventDiv_.style.cssText = "";
  6990. // Apply style values defined in the labelStyle parameter:
  6991. labelStyle = this.marker_.get("labelStyle");
  6992. for (i in labelStyle) {
  6993. if (labelStyle.hasOwnProperty(i)) {
  6994. this.labelDiv_.style[i] = labelStyle[i];
  6995. this.eventDiv_.style[i] = labelStyle[i];
  6996. }
  6997. }
  6998. this.setMandatoryStyles();
  6999. };
  7000. /**
  7001. * Sets the mandatory styles to the DIV representing the label as well as to the
  7002. * associated event DIV. This includes setting the DIV position, z-index, and visibility.
  7003. * @private
  7004. */
  7005. MarkerLabel_.prototype.setMandatoryStyles = function () {
  7006. this.labelDiv_.style.position = "absolute";
  7007. this.labelDiv_.style.overflow = "hidden";
  7008. // Make sure the opacity setting causes the desired effect on MSIE:
  7009. if (typeof this.labelDiv_.style.opacity !== "undefined" && this.labelDiv_.style.opacity !== "") {
  7010. this.labelDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")\"";
  7011. this.labelDiv_.style.filter = "alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")";
  7012. }
  7013. this.eventDiv_.style.position = this.labelDiv_.style.position;
  7014. this.eventDiv_.style.overflow = this.labelDiv_.style.overflow;
  7015. this.eventDiv_.style.opacity = 0.01; // Don't use 0; DIV won't be clickable on MSIE
  7016. this.eventDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=1)\"";
  7017. this.eventDiv_.style.filter = "alpha(opacity=1)"; // For MSIE
  7018. this.setAnchor();
  7019. this.setPosition(); // This also updates z-index, if necessary.
  7020. this.setVisible();
  7021. };
  7022. /**
  7023. * Sets the anchor point of the label.
  7024. * @private
  7025. */
  7026. MarkerLabel_.prototype.setAnchor = function () {
  7027. var anchor = this.marker_.get("labelAnchor");
  7028. this.labelDiv_.style.marginLeft = -anchor.x + "px";
  7029. this.labelDiv_.style.marginTop = -anchor.y + "px";
  7030. this.eventDiv_.style.marginLeft = -anchor.x + "px";
  7031. this.eventDiv_.style.marginTop = -anchor.y + "px";
  7032. };
  7033. /**
  7034. * Sets the position of the label. The z-index is also updated, if necessary.
  7035. * @private
  7036. */
  7037. MarkerLabel_.prototype.setPosition = function (yOffset) {
  7038. var position = this.getProjection().fromLatLngToDivPixel(this.marker_.getPosition());
  7039. if (typeof yOffset === "undefined") {
  7040. yOffset = 0;
  7041. }
  7042. this.labelDiv_.style.left = Math.round(position.x) + "px";
  7043. this.labelDiv_.style.top = Math.round(position.y - yOffset) + "px";
  7044. this.eventDiv_.style.left = this.labelDiv_.style.left;
  7045. this.eventDiv_.style.top = this.labelDiv_.style.top;
  7046. this.setZIndex();
  7047. };
  7048. /**
  7049. * Sets the z-index of the label. If the marker's z-index property has not been defined, the z-index
  7050. * of the label is set to the vertical coordinate of the label. This is in keeping with the default
  7051. * stacking order for Google Maps: markers to the south are in front of markers to the north.
  7052. * @private
  7053. */
  7054. MarkerLabel_.prototype.setZIndex = function () {
  7055. var zAdjust = (this.marker_.get("labelInBackground") ? -1 : +1);
  7056. if (typeof this.marker_.getZIndex() === "undefined") {
  7057. this.labelDiv_.style.zIndex = parseInt(this.labelDiv_.style.top, 10) + zAdjust;
  7058. this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
  7059. } else {
  7060. this.labelDiv_.style.zIndex = this.marker_.getZIndex() + zAdjust;
  7061. this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
  7062. }
  7063. };
  7064. /**
  7065. * Sets the visibility of the label. The label is visible only if the marker itself is
  7066. * visible (i.e., its visible property is true) and the labelVisible property is true.
  7067. * @private
  7068. */
  7069. MarkerLabel_.prototype.setVisible = function () {
  7070. if (this.marker_.get("labelVisible")) {
  7071. this.labelDiv_.style.display = this.marker_.getVisible() ? "block" : "none";
  7072. } else {
  7073. this.labelDiv_.style.display = "none";
  7074. }
  7075. this.eventDiv_.style.display = this.labelDiv_.style.display;
  7076. };
  7077. /**
  7078. * @name MarkerWithLabelOptions
  7079. * @class This class represents the optional parameter passed to the {@link MarkerWithLabel} constructor.
  7080. * The properties available are the same as for <code>google.maps.Marker</code> with the addition
  7081. * of the properties listed below. To change any of these additional properties after the labeled
  7082. * marker has been created, call <code>google.maps.Marker.set(propertyName, propertyValue)</code>.
  7083. * <p>
  7084. * When any of these properties changes, a property changed event is fired. The names of these
  7085. * events are derived from the name of the property and are of the form <code>propertyname_changed</code>.
  7086. * For example, if the content of the label changes, a <code>labelcontent_changed</code> event
  7087. * is fired.
  7088. * <p>
  7089. * @property {string|Node} [labelContent] The content of the label (plain text or an HTML DOM node).
  7090. * @property {Point} [labelAnchor] By default, a label is drawn with its anchor point at (0,0) so
  7091. * that its top left corner is positioned at the anchor point of the associated marker. Use this
  7092. * property to change the anchor point of the label. For example, to center a 50px-wide label
  7093. * beneath a marker, specify a <code>labelAnchor</code> of <code>google.maps.Point(25, 0)</code>.
  7094. * (Note: x-values increase to the right and y-values increase to the top.)
  7095. * @property {string} [labelClass] The name of the CSS class defining the styles for the label.
  7096. * Note that style values for <code>position</code>, <code>overflow</code>, <code>top</code>,
  7097. * <code>left</code>, <code>zIndex</code>, <code>display</code>, <code>marginLeft</code>, and
  7098. * <code>marginTop</code> are ignored; these styles are for internal use only.
  7099. * @property {Object} [labelStyle] An object literal whose properties define specific CSS
  7100. * style values to be applied to the label. Style values defined here override those that may
  7101. * be defined in the <code>labelClass</code> style sheet. If this property is changed after the
  7102. * label has been created, all previously set styles (except those defined in the style sheet)
  7103. * are removed from the label before the new style values are applied.
  7104. * Note that style values for <code>position</code>, <code>overflow</code>, <code>top</code>,
  7105. * <code>left</code>, <code>zIndex</code>, <code>display</code>, <code>marginLeft</code>, and
  7106. * <code>marginTop</code> are ignored; these styles are for internal use only.
  7107. * @property {boolean} [labelInBackground] A flag indicating whether a label that overlaps its
  7108. * associated marker should appear in the background (i.e., in a plane below the marker).
  7109. * The default is <code>false</code>, which causes the label to appear in the foreground.
  7110. * @property {boolean} [labelVisible] A flag indicating whether the label is to be visible.
  7111. * The default is <code>true</code>. Note that even if <code>labelVisible</code> is
  7112. * <code>true</code>, the label will <i>not</i> be visible unless the associated marker is also
  7113. * visible (i.e., unless the marker's <code>visible</code> property is <code>true</code>).
  7114. * @property {boolean} [raiseOnDrag] A flag indicating whether the label and marker are to be
  7115. * raised when the marker is dragged. The default is <code>true</code>. If a draggable marker is
  7116. * being created and a version of Google Maps API earlier than V3.3 is being used, this property
  7117. * must be set to <code>false</code>.
  7118. * @property {boolean} [optimized] A flag indicating whether rendering is to be optimized for the
  7119. * marker. <b>Important: The optimized rendering technique is not supported by MarkerWithLabel,
  7120. * so the value of this parameter is always forced to <code>false</code>.
  7121. * @property {string} [crossImage="http://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png"]
  7122. * The URL of the cross image to be displayed while dragging a marker.
  7123. * @property {string} [handCursor="http://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur"]
  7124. * The URL of the cursor to be displayed while dragging a marker.
  7125. */
  7126. /**
  7127. * Creates a MarkerWithLabel with the options specified in {@link MarkerWithLabelOptions}.
  7128. * @constructor
  7129. * @param {MarkerWithLabelOptions} [opt_options] The optional parameters.
  7130. */
  7131. function MarkerWithLabel(opt_options) {
  7132. opt_options = opt_options || {};
  7133. opt_options.labelContent = opt_options.labelContent || "";
  7134. opt_options.labelAnchor = opt_options.labelAnchor || new google.maps.Point(0, 0);
  7135. opt_options.labelClass = opt_options.labelClass || "markerLabels";
  7136. opt_options.labelStyle = opt_options.labelStyle || {};
  7137. opt_options.labelInBackground = opt_options.labelInBackground || false;
  7138. if (typeof opt_options.labelVisible === "undefined") {
  7139. opt_options.labelVisible = true;
  7140. }
  7141. if (typeof opt_options.raiseOnDrag === "undefined") {
  7142. opt_options.raiseOnDrag = true;
  7143. }
  7144. if (typeof opt_options.clickable === "undefined") {
  7145. opt_options.clickable = true;
  7146. }
  7147. if (typeof opt_options.draggable === "undefined") {
  7148. opt_options.draggable = false;
  7149. }
  7150. if (typeof opt_options.optimized === "undefined") {
  7151. opt_options.optimized = false;
  7152. }
  7153. opt_options.crossImage = opt_options.crossImage || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png";
  7154. opt_options.handCursor = opt_options.handCursor || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur";
  7155. opt_options.optimized = false; // Optimized rendering is not supported
  7156. this.label = new MarkerLabel_(this, opt_options.crossImage, opt_options.handCursor); // Bind the label to the marker
  7157. // Call the parent constructor. It calls Marker.setValues to initialize, so all
  7158. // the new parameters are conveniently saved and can be accessed with get/set.
  7159. // Marker.set triggers a property changed event (called "propertyname_changed")
  7160. // that the marker label listens for in order to react to state changes.
  7161. google.maps.Marker.apply(this, arguments);
  7162. }
  7163. inherits(MarkerWithLabel, google.maps.Marker);
  7164. /**
  7165. * Overrides the standard Marker setMap function.
  7166. * @param {Map} theMap The map to which the marker is to be added.
  7167. * @private
  7168. */
  7169. MarkerWithLabel.prototype.setMap = function (theMap) {
  7170. // Call the inherited function...
  7171. google.maps.Marker.prototype.setMap.apply(this, arguments);
  7172. // ... then deal with the label:
  7173. this.label.setMap(theMap);
  7174. };