/www/js/angular-google-maps.js
JavaScript | 8131 lines | 5539 code | 912 blank | 1680 comment | 1237 complexity | f181de0b80499e1d68469cc3f32e2b3c MD5 | raw file
Possible License(s): Apache-2.0
Large files files are truncated, but you can click here to view the full file
- /*! angular-google-maps 1.1.1-SNAPSHOT 2014-05-26
- * AngularJS directives for Google Maps
- * git: https://github.com/nlaplante/angular-google-maps.git
- */
- /*
- !
- The MIT License
- Copyright (c) 2010-2013 Google, Inc. http://angularjs.org
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- angular-google-maps
- https://github.com/nlaplante/angular-google-maps
- @authors
- Nicolas Laplante - https://plus.google.com/108189012221374960701
- Nicholas McCready - https://twitter.com/nmccready
- */
- (function() {
- angular.module("google-maps.directives.api.utils", []);
- angular.module("google-maps.directives.api.managers", []);
- angular.module("google-maps.directives.api.models.child", ["google-maps.directives.api.utils"]);
- angular.module("google-maps.directives.api.models.parent", ["google-maps.directives.api.managers", "google-maps.directives.api.models.child"]);
- angular.module("google-maps.directives.api", ["google-maps.directives.api.models.parent"]);
- angular.module("google-maps", ["google-maps.directives.api"]).factory("debounce", [
- "$timeout", function($timeout) {
- return function(fn) {
- var nthCall;
- nthCall = 0;
- return function() {
- var argz, later, that;
- that = this;
- argz = arguments;
- nthCall++;
- later = (function(version) {
- return function() {
- if (version === nthCall) {
- return fn.apply(that, argz);
- }
- };
- })(nthCall);
- return $timeout(later, 0, true);
- };
- };
- }
- ]);
- }).call(this);
- (function() {
- angular.element(document).ready(function() {
- if (!(google || (typeof google !== "undefined" && google !== null ? google.maps : void 0) || (google.maps.InfoWindow != null))) {
- return;
- }
- google.maps.InfoWindow.prototype._open = google.maps.InfoWindow.prototype.open;
- google.maps.InfoWindow.prototype._close = google.maps.InfoWindow.prototype.close;
- google.maps.InfoWindow.prototype._isOpen = false;
- google.maps.InfoWindow.prototype.open = function(map, anchor) {
- this._isOpen = true;
- this._open(map, anchor);
- };
- google.maps.InfoWindow.prototype.close = function() {
- this._isOpen = false;
- this._close();
- };
- google.maps.InfoWindow.prototype.isOpen = function(val) {
- if (val == null) {
- val = void 0;
- }
- if (val == null) {
- return this._isOpen;
- } else {
- return this._isOpen = val;
- }
- };
- /*
- Do the same for InfoBox
- TODO: Clean this up so the logic is defined once, wait until develop becomes master as this will be easier
- */
- if (!window.InfoBox) {
- return;
- }
- window.InfoBox.prototype._open = window.InfoBox.prototype.open;
- window.InfoBox.prototype._close = window.InfoBox.prototype.close;
- window.InfoBox.prototype._isOpen = false;
- window.InfoBox.prototype.open = function(map, anchor) {
- this._isOpen = true;
- this._open(map, anchor);
- };
- window.InfoBox.prototype.close = function() {
- this._isOpen = false;
- this._close();
- };
- return window.InfoBox.prototype.isOpen = function(val) {
- if (val == null) {
- val = void 0;
- }
- if (val == null) {
- return this._isOpen;
- } else {
- return this._isOpen = val;
- }
- };
- });
- }).call(this);
- /*
- Author Nick McCready
- Intersection of Objects if the arrays have something in common each intersecting object will be returned
- in an new array.
- */
- (function() {
- _.intersectionObjects = function(array1, array2, comparison) {
- var res,
- _this = this;
- if (comparison == null) {
- comparison = void 0;
- }
- res = _.map(array1, function(obj1) {
- return _.find(array2, function(obj2) {
- if (comparison != null) {
- return comparison(obj1, obj2);
- } else {
- return _.isEqual(obj1, obj2);
- }
- });
- });
- return _.filter(res, function(o) {
- return o != null;
- });
- };
- _.containsObject = _.includeObject = function(obj, target, comparison) {
- var _this = this;
- if (comparison == null) {
- comparison = void 0;
- }
- if (obj === null) {
- return false;
- }
- return _.any(obj, function(value) {
- if (comparison != null) {
- return comparison(value, target);
- } else {
- return _.isEqual(value, target);
- }
- });
- };
- _.differenceObjects = function(array1, array2, comparison) {
- if (comparison == null) {
- comparison = void 0;
- }
- return _.filter(array1, function(value) {
- return !_.containsObject(array2, value);
- });
- };
- _.withoutObjects = function(array, array2) {
- return _.differenceObjects(array, array2);
- };
- _.indexOfObject = function(array, item, comparison, isSorted) {
- var i, length;
- if (array == null) {
- return -1;
- }
- i = 0;
- length = array.length;
- if (isSorted) {
- if (typeof isSorted === "number") {
- i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted);
- } else {
- i = _.sortedIndex(array, item);
- return (array[i] === item ? i : -1);
- }
- }
- while (i < length) {
- if (comparison != null) {
- if (comparison(array[i], item)) {
- return i;
- }
- } else {
- if (_.isEqual(array[i], item)) {
- return i;
- }
- }
- i++;
- }
- return -1;
- };
- _["extends"] = function(arrayOfObjectsToCombine) {
- return _.reduce(arrayOfObjectsToCombine, function(combined, toAdd) {
- return _.extend(combined, toAdd);
- }, {});
- };
- }).call(this);
- /*
- Author: Nicholas McCready & jfriend00
- _async handles things asynchronous-like :), to allow the UI to be free'd to do other things
- Code taken from http://stackoverflow.com/questions/10344498/best-way-to-iterate-over-an-array-without-blocking-the-ui
- The design of any funcitonality of _async is to be like lodash/underscore and replicate it but call things
- asynchronously underneath. Each should be sufficient for most things to be derrived from.
- TODO: Handle Object iteration like underscore and lodash as well.. not that important right now
- */
- (function() {
- var async;
- async = {
- each: function(array, callback, doneCallBack, pausedCallBack, chunk, index, pause) {
- var doChunk;
- if (chunk == null) {
- chunk = 20;
- }
- if (index == null) {
- index = 0;
- }
- if (pause == null) {
- pause = 1;
- }
- if (!pause) {
- throw "pause (delay) must be set from _async!";
- return;
- }
- if (array === void 0 || (array != null ? array.length : void 0) <= 0) {
- doneCallBack();
- return;
- }
- doChunk = function() {
- var cnt, i;
- cnt = chunk;
- i = index;
- while (cnt-- && i < (array ? array.length : i + 1)) {
- callback(array[i], i);
- ++i;
- }
- if (array) {
- if (i < array.length) {
- index = i;
- if (pausedCallBack != null) {
- pausedCallBack();
- }
- return setTimeout(doChunk, pause);
- } else {
- if (doneCallBack) {
- return doneCallBack();
- }
- }
- }
- };
- return doChunk();
- },
- map: function(objs, iterator, doneCallBack, pausedCallBack, chunk) {
- var results;
- results = [];
- if (objs == null) {
- return results;
- }
- return _async.each(objs, function(o) {
- return results.push(iterator(o));
- }, function() {
- return doneCallBack(results);
- }, pausedCallBack, chunk);
- }
- };
- window._async = async;
- angular.module("google-maps.directives.api.utils").factory("async", function() {
- return window._async;
- });
- }).call(this);
- (function() {
- 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; };
- angular.module("google-maps.directives.api.utils").factory("BaseObject", function() {
- var BaseObject, baseObjectKeywords;
- baseObjectKeywords = ['extended', 'included'];
- BaseObject = (function() {
- function BaseObject() {}
- BaseObject.extend = function(obj) {
- var key, value, _ref;
- for (key in obj) {
- value = obj[key];
- if (__indexOf.call(baseObjectKeywords, key) < 0) {
- this[key] = value;
- }
- }
- if ((_ref = obj.extended) != null) {
- _ref.apply(this);
- }
- return this;
- };
- BaseObject.include = function(obj) {
- var key, value, _ref;
- for (key in obj) {
- value = obj[key];
- if (__indexOf.call(baseObjectKeywords, key) < 0) {
- this.prototype[key] = value;
- }
- }
- if ((_ref = obj.included) != null) {
- _ref.apply(this);
- }
- return this;
- };
- return BaseObject;
- })();
- return BaseObject;
- });
- }).call(this);
- /*
- Useful function callbacks that should be defined at later time.
- Mainly to be used for specs to verify creation / linking.
- This is to lead a common design in notifying child stuff.
- */
- (function() {
- angular.module("google-maps.directives.api.utils").factory("ChildEvents", function() {
- return {
- onChildCreation: function(child) {}
- };
- });
- }).call(this);
- (function() {
- var __hasProp = {}.hasOwnProperty,
- __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; };
- angular.module("google-maps.directives.api.utils").factory("FitHelper", [
- "BaseObject", "Logger", function(BaseObject, $log) {
- var FitHelper, _ref;
- return FitHelper = (function(_super) {
- __extends(FitHelper, _super);
- function FitHelper() {
- _ref = FitHelper.__super__.constructor.apply(this, arguments);
- return _ref;
- }
- FitHelper.prototype.fit = function(gMarkers, gMap) {
- var bounds, everSet,
- _this = this;
- if (gMap && gMarkers && gMarkers.length > 0) {
- bounds = new google.maps.LatLngBounds();
- everSet = false;
- return _async.each(gMarkers, function(gMarker) {
- if (gMarker) {
- if (!everSet) {
- everSet = true;
- }
- return bounds.extend(gMarker.getPosition());
- }
- }, function() {
- if (everSet) {
- return gMap.fitBounds(bounds);
- }
- });
- }
- };
- return FitHelper;
- })(BaseObject);
- }
- ]);
- }).call(this);
- (function() {
- angular.module("google-maps.directives.api.utils").service("GmapUtil", [
- "Logger", "$compile", function(Logger, $compile) {
- var getCoords, validateCoords;
- getCoords = function(value) {
- if (Array.isArray(value) && value.length === 2) {
- return new google.maps.LatLng(value[1], value[0]);
- } else if (angular.isDefined(value.type) && value.type === "Point") {
- return new google.maps.LatLng(value.coordinates[1], value.coordinates[0]);
- } else {
- return new google.maps.LatLng(value.latitude, value.longitude);
- }
- };
- validateCoords = function(coords) {
- if (angular.isUndefined(coords)) {
- return false;
- }
- if (_.isArray(coords)) {
- if (coords.length === 2) {
- return true;
- }
- } else if ((coords != null) && (coords != null ? coords.type : void 0)) {
- if (coords.type === "Point" && _.isArray(coords.coordinates) && coords.coordinates.length === 2) {
- return true;
- }
- } else {
- if (coords && angular.isDefined((coords != null ? coords.latitude : void 0) && angular.isDefined(coords != null ? coords.longitude : void 0))) {
- return true;
- }
- }
- return false;
- };
- return {
- getLabelPositionPoint: function(anchor) {
- var xPos, yPos;
- if (anchor === void 0) {
- return void 0;
- }
- anchor = /^([-\d\.]+)\s([-\d\.]+)$/.exec(anchor);
- xPos = parseFloat(anchor[1]);
- yPos = parseFloat(anchor[2]);
- if ((xPos != null) && (yPos != null)) {
- return new google.maps.Point(xPos, yPos);
- }
- },
- createMarkerOptions: function(coords, icon, defaults, map) {
- var opts;
- if (map == null) {
- map = void 0;
- }
- if (defaults == null) {
- defaults = {};
- }
- opts = angular.extend({}, defaults, {
- position: defaults.position != null ? defaults.position : getCoords(coords),
- icon: defaults.icon != null ? defaults.icon : icon,
- visible: defaults.visible != null ? defaults.visible : validateCoords(coords)
- });
- if (map != null) {
- opts.map = map;
- }
- return opts;
- },
- createWindowOptions: function(gMarker, scope, content, defaults) {
- if ((content != null) && (defaults != null) && ($compile != null)) {
- return angular.extend({}, defaults, {
- content: this.buildContent(scope, defaults, content),
- position: defaults.position != null ? defaults.position : angular.isObject(gMarker) ? gMarker.getPosition() : getCoords(scope.coords)
- });
- } else {
- if (!defaults) {
- Logger.error("infoWindow defaults not defined");
- if (!content) {
- return Logger.error("infoWindow content not defined");
- }
- } else {
- return defaults;
- }
- }
- },
- buildContent: function(scope, defaults, content) {
- var parsed, ret;
- if (defaults.content != null) {
- ret = defaults.content;
- } else {
- if ($compile != null) {
- parsed = $compile(content)(scope);
- if (parsed.length > 0) {
- ret = parsed[0];
- }
- } else {
- ret = content;
- }
- }
- return ret;
- },
- defaultDelay: 50,
- isTrue: function(val) {
- return angular.isDefined(val) && val !== null && val === true || val === "1" || val === "y" || val === "true";
- },
- isFalse: function(value) {
- return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) !== -1;
- },
- getCoords: getCoords,
- validateCoords: validateCoords,
- validatePath: function(path) {
- var array, i;
- i = 0;
- if (angular.isUndefined(path.type)) {
- if (!Array.isArray(path) || path.length < 2) {
- return false;
- }
- while (i < path.length) {
- if (!((angular.isDefined(path[i].latitude) && angular.isDefined(path[i].longitude)) || (typeof path[i].lat === "function" && typeof path[i].lng === "function"))) {
- return false;
- }
- i++;
- }
- return true;
- } else {
- if (angular.isUndefined(path.coordinates)) {
- return false;
- }
- if (path.type === "Polygon") {
- if (path.coordinates[0].length < 4) {
- return false;
- }
- array = path.coordinates[0];
- } else if (path.type === "LineString") {
- if (path.coordinates.length < 2) {
- return false;
- }
- array = path.coordinates;
- } else {
- return false;
- }
- while (i < array.length) {
- if (array[i].length !== 2) {
- return false;
- }
- i++;
- }
- return true;
- }
- },
- convertPathPoints: function(path) {
- var array, i, latlng, result;
- i = 0;
- result = new google.maps.MVCArray();
- if (angular.isUndefined(path.type)) {
- while (i < path.length) {
- latlng;
- if (angular.isDefined(path[i].latitude) && angular.isDefined(path[i].longitude)) {
- latlng = new google.maps.LatLng(path[i].latitude, path[i].longitude);
- } else if (typeof path[i].lat === "function" && typeof path[i].lng === "function") {
- latlng = path[i];
- }
- result.push(latlng);
- i++;
- }
- } else {
- array;
- if (path.type === "Polygon") {
- array = path.coordinates[0];
- } else if (path.type === "LineString") {
- array = path.coordinates;
- }
- while (i < array.length) {
- result.push(new google.maps.LatLng(array[i][1], array[i][0]));
- i++;
- }
- }
- return result;
- },
- extendMapBounds: function(map, points) {
- var bounds, i;
- bounds = new google.maps.LatLngBounds();
- i = 0;
- while (i < points.length) {
- bounds.extend(points.getAt(i));
- i++;
- }
- return map.fitBounds(bounds);
- }
- };
- }
- ]);
- }).call(this);
- (function() {
- var __hasProp = {}.hasOwnProperty,
- __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; };
- angular.module("google-maps.directives.api.utils").factory("Linked", [
- "BaseObject", function(BaseObject) {
- var Linked;
- Linked = (function(_super) {
- __extends(Linked, _super);
- function Linked(scope, element, attrs, ctrls) {
- this.scope = scope;
- this.element = element;
- this.attrs = attrs;
- this.ctrls = ctrls;
- }
- return Linked;
- })(BaseObject);
- return Linked;
- }
- ]);
- }).call(this);
- (function() {
- angular.module("google-maps.directives.api.utils").service("Logger", [
- "$log", function($log) {
- return {
- logger: $log,
- doLog: false,
- info: function(msg) {
- if (this.doLog) {
- if (this.logger != null) {
- return this.logger.info(msg);
- } else {
- return console.info(msg);
- }
- }
- },
- error: function(msg) {
- if (this.doLog) {
- if (this.logger != null) {
- return this.logger.error(msg);
- } else {
- return console.error(msg);
- }
- }
- },
- warn: function(msg) {
- if (this.doLog) {
- if (this.logger != null) {
- return this.logger.warn(msg);
- } else {
- return console.warn(msg);
- }
- }
- }
- };
- }
- ]);
- }).call(this);
- (function() {
- angular.module("google-maps.directives.api.utils").service("MarkerEventHelper", [
- "Logger", function($log) {
- return {
- setEvents: function(marker, scope, model) {
- if (angular.isDefined(scope.events) && (scope.events != null) && angular.isObject(scope.events)) {
- return _.compact(_.map(scope.events, function(eventHandler, eventName) {
- if (scope.events.hasOwnProperty(eventName) && angular.isFunction(scope.events[eventName])) {
- return google.maps.event.addListener(marker, eventName, function() {
- return eventHandler.apply(scope, [marker, eventName, model, arguments]);
- });
- } else {
- return $log.info("MarkerEventHelper: invalid event listener " + eventName);
- }
- }));
- }
- }
- };
- }
- ]);
- }).call(this);
- (function() {
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __hasProp = {}.hasOwnProperty,
- __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; };
- angular.module("google-maps.directives.api.utils").factory("ModelKey", [
- "BaseObject", function(BaseObject) {
- var ModelKey;
- return ModelKey = (function(_super) {
- __extends(ModelKey, _super);
- function ModelKey(scope) {
- this.scope = scope;
- this.setIdKey = __bind(this.setIdKey, this);
- this.modelKeyComparison = __bind(this.modelKeyComparison, this);
- ModelKey.__super__.constructor.call(this);
- this.defaultIdKey = "id";
- this.idKey = void 0;
- }
- ModelKey.prototype.evalModelHandle = function(model, modelKey) {
- if (model === void 0) {
- return void 0;
- }
- if (modelKey === 'self') {
- return model;
- } else {
- return model[modelKey];
- }
- };
- ModelKey.prototype.modelKeyComparison = function(model1, model2) {
- var scope;
- scope = this.scope.coords != null ? this.scope : this.parentScope;
- if (scope == null) {
- throw "No scope or parentScope set!";
- }
- 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;
- };
- ModelKey.prototype.setIdKey = function(scope) {
- return this.idKey = scope.idKey != null ? scope.idKey : this.defaultIdKey;
- };
- return ModelKey;
- })(BaseObject);
- }
- ]);
- }).call(this);
- (function() {
- angular.module("google-maps.directives.api.utils").factory("ModelsWatcher", [
- "Logger", function(Logger) {
- return {
- figureOutState: function(idKey, scope, childObjects, comparison, callBack) {
- var adds, mappedScopeModelIds, removals,
- _this = this;
- adds = [];
- mappedScopeModelIds = {};
- removals = [];
- return _async.each(scope.models, function(m) {
- var child;
- if (m[idKey] != null) {
- mappedScopeModelIds[m[idKey]] = {};
- if (childObjects[m[idKey]] == null) {
- return adds.push(m);
- } else {
- child = childObjects[m[idKey]];
- if (!comparison(m, child.model)) {
- adds.push(m);
- return removals.push(child.model);
- }
- }
- } else {
- return Logger.error("id missing for model " + (m.toString()) + ", can not use do comparison/insertion");
- }
- }, function() {
- return _async.each(childObjects.values(), function(c) {
- var id;
- if (c == null) {
- Logger.error("child undefined in ModelsWatcher.");
- return;
- }
- if (c.model == null) {
- Logger.error("child.model undefined in ModelsWatcher.");
- return;
- }
- id = c.model[idKey];
- if (mappedScopeModelIds[id] == null) {
- return removals.push(c.model[idKey]);
- }
- }, function() {
- return callBack({
- adds: adds,
- removals: removals
- });
- });
- });
- }
- };
- }
- ]);
- }).call(this);
- /*
- Simple Object Map with a lenght property to make it easy to track length/size
- */
- (function() {
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
- angular.module("google-maps.directives.api.utils").factory("PropMap", function() {
- var PropMap, propsToPop;
- propsToPop = ['get', 'put', 'remove', 'values', 'keys', 'length'];
- PropMap = (function() {
- function PropMap() {
- this.keys = __bind(this.keys, this);
- this.values = __bind(this.values, this);
- this.remove = __bind(this.remove, this);
- this.put = __bind(this.put, this);
- this.get = __bind(this.get, this);
- this.length = 0;
- }
- PropMap.prototype.get = function(key) {
- return this[key];
- };
- PropMap.prototype.put = function(key, value) {
- if (this[key] == null) {
- this.length++;
- }
- return this[key] = value;
- };
- PropMap.prototype.remove = function(key) {
- delete this[key];
- return this.length--;
- };
- PropMap.prototype.values = function() {
- var all, keys,
- _this = this;
- all = [];
- keys = _.keys(this);
- _.each(keys, function(value) {
- if (_.indexOf(propsToPop, value) === -1) {
- return all.push(_this[value]);
- }
- });
- return all;
- };
- PropMap.prototype.keys = function() {
- var all, keys,
- _this = this;
- keys = _.keys(this);
- all = [];
- _.each(keys, function(prop) {
- if (_.indexOf(propsToPop, prop) === -1) {
- return all.push(prop);
- }
- });
- return all;
- };
- return PropMap;
- })();
- return PropMap;
- });
- }).call(this);
- (function() {
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __hasProp = {}.hasOwnProperty,
- __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; };
- angular.module("google-maps.directives.api.managers").factory("ClustererMarkerManager", [
- "Logger", "FitHelper", function($log, FitHelper) {
- var ClustererMarkerManager;
- ClustererMarkerManager = (function(_super) {
- __extends(ClustererMarkerManager, _super);
- function ClustererMarkerManager(gMap, opt_markers, opt_options, opt_events) {
- var self;
- this.opt_events = opt_events;
- this.fit = __bind(this.fit, this);
- this.destroy = __bind(this.destroy, this);
- this.clear = __bind(this.clear, this);
- this.draw = __bind(this.draw, this);
- this.removeMany = __bind(this.removeMany, this);
- this.remove = __bind(this.remove, this);
- this.addMany = __bind(this.addMany, this);
- this.add = __bind(this.add, this);
- ClustererMarkerManager.__super__.constructor.call(this);
- self = this;
- this.opt_options = opt_options;
- if ((opt_options != null) && opt_markers === void 0) {
- this.clusterer = new MarkerClusterer(gMap, void 0, opt_options);
- } else if ((opt_options != null) && (opt_markers != null)) {
- this.clusterer = new MarkerClusterer(gMap, opt_markers, opt_options);
- } else {
- this.clusterer = new MarkerClusterer(gMap);
- }
- this.attachEvents(this.opt_events, "opt_events");
- this.clusterer.setIgnoreHidden(true);
- this.noDrawOnSingleAddRemoves = true;
- $log.info(this);
- }
- ClustererMarkerManager.prototype.add = function(gMarker) {
- return this.clusterer.addMarker(gMarker, this.noDrawOnSingleAddRemoves);
- };
- ClustererMarkerManager.prototype.addMany = function(gMarkers) {
- return this.clusterer.addMarkers(gMarkers);
- };
- ClustererMarkerManager.prototype.remove = function(gMarker) {
- return this.clusterer.removeMarker(gMarker, this.noDrawOnSingleAddRemoves);
- };
- ClustererMarkerManager.prototype.removeMany = function(gMarkers) {
- return this.clusterer.addMarkers(gMarkers);
- };
- ClustererMarkerManager.prototype.draw = function() {
- return this.clusterer.repaint();
- };
- ClustererMarkerManager.prototype.clear = function() {
- this.clusterer.clearMarkers();
- return this.clusterer.repaint();
- };
- ClustererMarkerManager.prototype.attachEvents = function(options, optionsName) {
- var eventHandler, eventName, _results;
- if (angular.isDefined(options) && (options != null) && angular.isObject(options)) {
- _results = [];
- for (eventName in options) {
- eventHandler = options[eventName];
- if (options.hasOwnProperty(eventName) && angular.isFunction(options[eventName])) {
- $log.info("" + optionsName + ": Attaching event: " + eventName + " to clusterer");
- _results.push(google.maps.event.addListener(this.clusterer, eventName, options[eventName]));
- } else {
- _results.push(void 0);
- }
- }
- return _results;
- }
- };
- ClustererMarkerManager.prototype.clearEvents = function(options) {
- var eventHandler, eventName, _results;
- if (angular.isDefined(options) && (options != null) && angular.isObject(options)) {
- _results = [];
- for (eventName in options) {
- eventHandler = options[eventName];
- if (options.hasOwnProperty(eventName) && angular.isFunction(options[eventName])) {
- $log.info("" + optionsName + ": Clearing event: " + eventName + " to clusterer");
- _results.push(google.maps.event.clearListeners(this.clusterer, eventName));
- } else {
- _results.push(void 0);
- }
- }
- return _results;
- }
- };
- ClustererMarkerManager.prototype.destroy = function() {
- this.clearEvents(this.opt_events);
- this.clearEvents(this.opt_internal_events);
- return this.clear();
- };
- ClustererMarkerManager.prototype.fit = function() {
- return ClustererMarkerManager.__super__.fit.call(this, this.clusterer.getMarkers(), this.clusterer.getMap());
- };
- return ClustererMarkerManager;
- })(FitHelper);
- return ClustererMarkerManager;
- }
- ]);
- }).call(this);
- (function() {
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __hasProp = {}.hasOwnProperty,
- __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; };
- angular.module("google-maps.directives.api.managers").factory("MarkerManager", [
- "Logger", "FitHelper", function(Logger, FitHelper) {
- var MarkerManager;
- MarkerManager = (function(_super) {
- __extends(MarkerManager, _super);
- MarkerManager.include(FitHelper);
- function MarkerManager(gMap, opt_markers, opt_options) {
- this.fit = __bind(this.fit, this);
- this.handleOptDraw = __bind(this.handleOptDraw, this);
- this.clear = __bind(this.clear, this);
- this.draw = __bind(this.draw, this);
- this.removeMany = __bind(this.removeMany, this);
- this.remove = __bind(this.remove, this);
- this.addMany = __bind(this.addMany, this);
- this.add = __bind(this.add, this);
- var self;
- MarkerManager.__super__.constructor.call(this);
- self = this;
- this.gMap = gMap;
- this.gMarkers = [];
- this.$log = Logger;
- this.$log.info(this);
- }
- MarkerManager.prototype.add = function(gMarker, optDraw) {
- this.handleOptDraw(gMarker, optDraw, true);
- return this.gMarkers.push(gMarker);
- };
- MarkerManager.prototype.addMany = function(gMarkers) {
- var gMarker, _i, _len, _results;
- _results = [];
- for (_i = 0, _len = gMarkers.length; _i < _len; _i++) {
- gMarker = gMarkers[_i];
- _results.push(this.add(gMarker));
- }
- return _results;
- };
- MarkerManager.prototype.remove = function(gMarker, optDraw) {
- var index, tempIndex;
- this.handleOptDraw(gMarker, optDraw, false);
- if (!optDraw) {
- return;
- }
- index = void 0;
- if (this.gMarkers.indexOf != null) {
- index = this.gMarkers.indexOf(gMarker);
- } else {
- tempIndex = 0;
- _.find(this.gMarkers, function(marker) {
- tempIndex += 1;
- if (marker === gMarker) {
- index = tempIndex;
- }
- });
- }
- if (index != null) {
- return this.gMarkers.splice(index, 1);
- }
- };
- MarkerManager.prototype.removeMany = function(gMarkers) {
- var _this = this;
- return this.gMarkers.forEach(function(marker) {
- return _this.remove(marker);
- });
- };
- MarkerManager.prototype.draw = function() {
- var deletes,
- _this = this;
- deletes = [];
- this.gMarkers.forEach(function(gMarker) {
- if (!gMarker.isDrawn) {
- if (gMarker.doAdd) {
- return gMarker.setMap(_this.gMap);
- } else {
- return deletes.push(gMarker);
- }
- }
- });
- return deletes.forEach(function(gMarker) {
- return _this.remove(gMarker, true);
- });
- };
- MarkerManager.prototype.clear = function() {
- var gMarker, _i, _len, _ref;
- _ref = this.gMarkers;
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- gMarker = _ref[_i];
- gMarker.setMap(null);
- }
- delete this.gMarkers;
- return this.gMarkers = [];
- };
- MarkerManager.prototype.handleOptDraw = function(gMarker, optDraw, doAdd) {
- if (optDraw === true) {
- if (doAdd) {
- gMarker.setMap(this.gMap);
- } else {
- gMarker.setMap(null);
- }
- return gMarker.isDrawn = true;
- } else {
- gMarker.isDrawn = false;
- return gMarker.doAdd = doAdd;
- }
- };
- MarkerManager.prototype.fit = function() {
- return MarkerManager.__super__.fit.call(this, this.gMarkers, this.gMap);
- };
- return MarkerManager;
- })(FitHelper);
- return MarkerManager;
- }
- ]);
- }).call(this);
- (function() {
- angular.module("google-maps").factory("array-sync", [
- "add-events", function(mapEvents) {
- return function(mapArray, scope, pathEval) {
- var geojsonArray, geojsonHandlers, geojsonWatcher, isSetFromScope, legacyHandlers, legacyWatcher, mapArrayListener, scopePath, watchListener;
- isSetFromScope = false;
- scopePath = scope.$eval(pathEval);
- if (!scope["static"]) {
- legacyHandlers = {
- set_at: function(index) {
- var value;
- if (isSetFromScope) {
- return;
- }
- value = mapArray.getAt(index);
- if (!value) {
- return;
- }
- if (!value.lng || !value.lat) {
- return scopePath[index] = value;
- } else {
- scopePath[index].latitude = value.lat();
- return scopePath[index].longitude = value.lng();
- }
- },
- insert_at: function(index) {
- var value;
- if (isSetFromScope) {
- return;
- }
- value = mapArray.getAt(index);
- if (!value) {
- return;
- }
- if (!value.lng || !value.lat) {
- return scopePath.splice(index, 0, value);
- } else {
- return scopePath.splice(index, 0, {
- latitude: value.lat(),
- longitude: value.lng()
- });
- }
- },
- remove_at: function(index) {
- if (isSetFromScope) {
- return;
- }
- return scopePath.splice(index, 1);
- }
- };
- geojsonArray;
- if (scopePath.type === "Polygon") {
- geojsonArray = scopePath.coordinates[0];
- } else if (scopePath.type === "LineString") {
- geojsonArray = scopePath.coordinates;
- }
- geojsonHandlers = {
- set_at: function(index) {
- var value;
- if (isSetFromScope) {
- return;
- }
- value = mapArray.getAt(index);
- if (!value) {
- return;
- }
- if (!value.lng || !value.lat) {
- return;
- }
- geojsonArray[index][1] = value.lat();
- return geojsonArray[index][0] = value.lng();
- },
- insert_at: function(index) {
- var value;
- if (isSetFromScope) {
- return;
- }
- value = mapArray.getAt(index);
- if (!value) {
- return;
- }
- if (!value.lng || !value.lat) {
- return;
- }
- return geojsonArray.splice(index, 0, [value.lng(), value.lat()]);
- },
- remove_at: function(index) {
- if (isSetFromScope) {
- return;
- }
- return geojsonArray.splice(index, 1);
- }
- };
- mapArrayListener = mapEvents(mapArray, angular.isUndefined(scopePath.type) ? legacyHandlers : geojsonHandlers);
- }
- legacyWatcher = function(newPath) {
- var i, l, newLength, newValue, oldArray, oldLength, oldValue;
- isSetFromScope = true;
- oldArray = mapArray;
- if (newPath) {
- i = 0;
- oldLength = oldArray.getLength();
- newLength = newPath.length;
- l = Math.min(oldLength, newLength);
- newValue = void 0;
- while (i < l) {
- oldValue = oldArray.getAt(i);
- newValue = newPath[i];
- if (typeof newValue.equals === "function") {
- if (!newValue.equals(oldValue)) {
- oldArray.setAt(i, newValue);
- }
- } else {
- if ((oldValue.lat() !== newValue.latitude) || (oldValue.lng() !== newValue.longitude)) {
- oldArray.setAt(i, new google.maps.LatLng(newValue.latitude, newValue.longitude));
- }
- }
- i++;
- }
- while (i < newLength) {
- newValue = newPath[i];
- if (typeof newValue.lat === "function" && typeof newValue.lng === "function") {
- oldArray.push(newValue);
- } else {
- oldArray.push(new google.maps.LatLng(newValue.latitude, newValue.longitude));
- }
- i++;
- }
- while (i < oldLength) {
- oldArray.pop();
- i++;
- }
- }
- return isSetFromScope = false;
- };
- geojsonWatcher = function(newPath) {
- var array, i, l, newLength, newValue, oldArray, oldLength, oldValue;
- isSetFromScope = true;
- oldArray = mapArray;
- if (newPath) {
- array;
- if (scopePath.type === "Polygon") {
- array = newPath.coordinates[0];
- } else if (scopePath.type === "LineString") {
- array = newPath.coordinates;
- }
- i = 0;
- oldLength = oldArray.getLength();
- newLength = array.length;
- l = Math.min(oldLength, newLength);
- newValue = void 0;
- while (i < l) {
- oldValue = oldArray.getAt(i);
- newValue = array[i];
- if ((oldValue.lat() !== newValue[1]) || (oldValue.lng() !== newValue[0])) {
- oldArray.setAt(i, new google.maps.LatLng(newValue[1], newValue[0]));
- }
- i++;
- }
- while (i < newLength) {
- newValue = array[i];
- oldArray.push(new google.maps.LatLng(newValue[1], newValue[0]));
- i++;
- }
- while (i < oldLength) {
- oldArray.pop();
- i++;
- }
- }
- return isSetFromScope = false;
- };
- watchListener;
- if (!scope["static"]) {
- if (angular.isUndefined(scopePath.type)) {
- watchListener = scope.$watchCollection(pathEval, legacyWatcher);
- } else {
- watchListener = scope.$watch(pathEval, geojsonWatcher);
- }
- }
- return function() {
- if (mapArrayListener) {
- mapArrayListener();
- mapArrayListener = null;
- }
- if (watchListener) {
- watchListener();
- return watchListener = null;
- }
- };
- };
- }
- ]);
- }).call(this);
- (function() {
- angular.module("google-maps").factory("add-events", [
- "$timeout", function($timeout) {
- var addEvent, addEvents;
- addEvent = function(target, eventName, handler) {
- return google.maps.event.addListener(target, eventName, function() {
- handler.apply(this, arguments);
- return $timeout((function() {}), true);
- });
- };
- addEvents = function(target, eventName, handler) {
- var remove;
- if (handler) {
- return addEvent(target, eventName, handler);
- }
- remove = [];
- angular.forEach(eventName, function(_handler, key) {
- return remove.push(addEvent(target, key, _handler));
- });
- return function() {
- angular.forEach(remove, function(listener) {
- return google.maps.event.removeListener(listener);
- });
- return remove = null;
- };
- };
- return addEvents;
- }
- ]);
- }).call(this);
- (function() {
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __hasProp = {}.hasOwnProperty,
- __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; };
- angular.module("google-maps.directives.api.models.child").factory("MarkerLabelChildModel", [
- "BaseObject", "GmapUtil", function(BaseObject, GmapUtil) {
- var MarkerLabelChildModel;
- MarkerLabelChildModel = (function(_super) {
- __extends(MarkerLabelChildModel, _super);
- MarkerLabelChildModel.include(GmapUtil);
- function MarkerLabelChildModel(gMarker, opt_options) {
- this.destroy = __bind(this.destroy, this);
- this.draw = __bind(this.draw, this);
- this.setPosition = __bind(this.setPosition, this);
- this.setZIndex = __bind(this.setZIndex, this);
- this.setVisible = __bind(this.setVisible, this);
- this.setAnchor = __bind(this.setAnchor, this);
- this.setMandatoryStyles = __bind(this.setMandatoryStyles, this);
- this.setStyles = __bind(this.setStyles, this);
- this.setContent = __bind(this.setContent, this);
- this.setTitle = __bind(this.setTitle, this);
- this.getSharedCross = __bind(this.getSharedCross, this);
- var self, _ref, _ref1;
- MarkerLabelChildModel.__super__.constructor.call(this);
- self = this;
- this.marker = gMarker;
- this.marker.set("labelContent", opt_options.labelContent);
- this.marker.set("labelAnchor", this.getLabelPositionPoint(opt_options.labelAnchor));
- this.marker.set("labelClass", opt_options.labelClass || 'labels');
- this.marker.set("labelStyle", opt_options.labelStyle || {
- opacity: 100
- });
- this.marker.set("labelInBackground", opt_options.labelInBackground || false);
- if (!opt_options.labelVisible) {
- this.marker.set("labelVisible", true);
- }
- if (!opt_options.raiseOnDrag) {
- this.marker.set("raiseOnDrag", true);
- }
- if (!opt_options.clickable) {
- this.marker.set("clickable", true);
- }
- if (!opt_options.draggable) {
- this.marker.set("draggable", false);
- }
- if (!opt_options.optimized) {
- this.marker.set("optimized", false);
- }
- opt_options.crossImage = (_ref = opt_options.crossImage) != null ? _ref : document.location.protocol + "//maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png";
- opt_options.handCursor = (_ref1 = opt_options.handCursor) != null ? _ref1 : document.location.protocol + "//maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur";
- this.markerLabel = new MarkerLabel_(this.marker, opt_options.crossImage, opt_options.handCursor);
- this.marker.set("setMap", function(theMap) {
- google.maps.Marker.prototype.setMap.apply(this, arguments);
- return self.markerLabel.setMap(theMap);
- });
- this.marker.setMap(this.marker.getMap());
- }
- MarkerLabelChildModel.prototype.getSharedCross = function(crossUrl) {
- return this.markerLabel.getSharedCross(crossUrl);
- };
- MarkerLabelChildModel.prototype.setTitle = function() {
- return this.markerLabel.setTitle();
- };
- MarkerLabelChildModel.prototype.setContent = function() {
- return this.markerLabel.setContent();
- };
- MarkerLabelChildModel.prototype.setStyles = function() {
- return this.markerLabel.setStyles();
- };
- MarkerLabelChildModel.prototype.setMandatoryStyles = function() {
- return this.markerLabel.setMandatoryStyles();
- };
- MarkerLabelChildModel.prototype.setAnchor = function() {
- return this.markerLabel.setAnchor();
- };
- MarkerLabelChildModel.prototype.setVisible = function() {
- return this.markerLabel.setVisible();
- };
- MarkerLabelChildModel.prototype.setZIndex = function() {
- return this.markerLabel.setZIndex();
- };
- MarkerLabelChildModel.prototype.setPosition = function() {
- return this.markerLabel.setPosition();
- };
- MarkerLabelChildModel.prototype.draw = function() {
- return this.markerLabel.draw();
- };
- MarkerLabelChildModel.prototype.destroy = function() {
- if ((this.markerLabel.labelDiv_.parentNode != null) && (this.markerLabel.eventDiv_.parentNode != null)) {
- return this.markerLabel.onRemove();
- }
- };
- return MarkerLabelChildModel;
- })(BaseObject);
- return MarkerLabelChildModel;
- }
- ]);
- }).call(this);
- (function() {
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- __hasProp = {}.hasOwnProperty,
- __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; };
- angular.module("google-maps.directives.api.models.child").factory("MarkerChildModel", [
- "ModelKey", "GmapUtil", "Logger", "$injector", "MarkerEventHelper", function(ModelKey, GmapUtil, Logger, $injector, MarkerEventHelper) {
- var MarkerChildModel;
- MarkerChildModel = (function(_super) {
- __extends(MarkerChildModel, _super);
- MarkerChildModel.include(GmapUtil);
- MarkerChildModel.include(MarkerEventHelper);
- function MarkerChildModel(model, parentScope, gMap, $timeout, defaults, doClick, gMarkerManager, idKey) {
- var self,
- _this = this;
- this.model = model;
- this.parentScope = parentScope;
- this.g…
Large files files are truncated, but you can click here to view the full file