From 5fd291978fd3a98f137b2d3c013fe85b9000ecc6 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Tue, 23 Jul 2013 09:54:53 -0400 Subject: [PATCH 01/41] coffeescript compiling added to Gruntfile with some basic coffee files to compile --- .gitignore | 4 +- Gruntfile.js | 38 +- dist/angular-google-maps.js | 1274 ++++++++++++++------------- dist/angular-google-maps.min.js | 10 +- package.json | 3 +- src/coffee/oo/base_object.coffee | 15 + src/coffee/oo/module.coffee | 8 + src/{ => js}/directives/map.js | 0 src/{ => js}/directives/marker.js | 0 src/{ => js}/directives/polyline.js | 0 src/{ => js}/directives/window.js | 0 src/{ => js}/module.js | 0 12 files changed, 726 insertions(+), 626 deletions(-) create mode 100644 src/coffee/oo/base_object.coffee create mode 100644 src/coffee/oo/module.coffee rename src/{ => js}/directives/map.js (100%) rename src/{ => js}/directives/marker.js (100%) rename src/{ => js}/directives/polyline.js (100%) rename src/{ => js}/directives/window.js (100%) rename src/{ => js}/module.js (100%) diff --git a/.gitignore b/.gitignore index 0d906c7fc..68edb922e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ +.DS_Store /.settings /.project node_modules old/ tmp/ *~ -app/components \ No newline at end of file +app/components +/nbproject \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index a22f9f3a9..79f1d9234 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,13 +10,16 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-open'); grunt.loadNpmTasks('grunt-mkdir'); + grunt.loadNpmTasks('grunt-contrib-coffee'); + // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), clean: { + coffee: ['tmp/output_coffee.js'], dist: ['dist/*', 'tmp'], example: ['example/<%= pkg.name %>.js'] }, @@ -29,25 +32,35 @@ module.exports = function(grunt) { } } }, + + coffee: { + compile: { + files: { + 'tmp/output_coffee.js': ['src/coffee/*.coffee','src/coffee/oo/*.coffee'] // concat then compile into single file + } + } + }, concat: { options: { separator: ';' }, dist: { - src: ['src/module.js', - 'src/directives/map.js', - 'src/directives/marker.js', - 'src/directives/polyline.js', - 'src/directives/window.js'], + src: ['src/js/module.js', + 'src/js/directives/map.js', + 'src/js/directives/marker.js', + 'src/js/directives/polyline.js', + 'src/js/directives/window.js', + 'tmp/output_coffee.js'], dest: 'tmp/output.js' }, example: { - src: ['src/module.js', - 'src/directives/map.js', - 'src/directives/marker.js', - 'src/directives/polyline.js', - 'src/directives/window.js'], + src: ['src/js/module.js', + 'src/js/directives/map.js', + 'src/js/directives/marker.js', + 'src/js/directives/polyline.js', + 'src/js/directives/window.js', + 'tmp/output_coffee.js'], dest: 'example/<%= pkg.name %>.js' } }, @@ -74,7 +87,7 @@ module.exports = function(grunt) { }, jshint: { - all: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'] + all: ['Gruntfile.js', 'src/js/**/*.js', 'test/js/**/*.js'] }, test: { @@ -84,7 +97,7 @@ module.exports = function(grunt) { watch: { all: { options: { livereload: true }, - files: ['src/**/*.js'], + files: ['src/js/**/*.js'], tasks: ['clean:example', 'concat:example'], }, }, @@ -114,6 +127,7 @@ module.exports = function(grunt) { 'test', 'jshint', 'mkdir', + 'coffee', 'concat:dist', 'copy:dist', 'uglify']); diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index efb8bca12..728efc291 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -1,317 +1,317 @@ -/**! - * The MIT License - * - * Copyright (c) 2010-2012 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 - * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 - */ - -angular.module('google-maps', []);;/**! - * The MIT License - * - * Copyright (c) 2010-2012 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 - * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 - */ - -angular.module('google-maps') - .directive('googleMap', ['$log', '$timeout', function ($log, $timeout) { - - "use strict"; - - var DEFAULTS = { - mapTypeId: google.maps.MapTypeId.ROADMAP - }; - - /* - * Utility functions - */ - - /** - * Check if a value is true - */ - function isTrue(val) { - return angular.isDefined(val) && - val !== null && - val === true || - val === '1' || - val === 'y' || - val === 'true'; - } - - return { - /** - * - */ - restrict: 'ECMA', - - /** - * - */ - transclude: true, - - /** - * - */ - replace: false, - - /** - * - */ - //priority: 100, - - /** - * - */ - template: '
', - - /** - * - */ - scope: { - center: '=center', // required - zoom: '=zoom', // required - dragging: '=dragging', // optional - markers: '=markers', // optional - refresh: '&refresh', // optional - windows: '=windows', // optional - events: '=events' // optional - }, - - /** - * - */ - controller: ['$scope', function ($scope) { - /** - * @return the map instance - */ - this.getMap = function () { - return $scope.map; - }; - }], - - /** - * - * @param scope - * @param element - * @param attrs - */ - link: function (scope, element, attrs) { - - // Center property must be specified and provide lat & - // lng properties - if (!angular.isDefined(scope.center) || - (!angular.isDefined(scope.center.latitude) || !angular.isDefined(scope.center.longitude))) { - - $log.error("angular-google-maps: could not find a valid center property"); - return; - } - - if (!angular.isDefined(scope.zoom)) { - $log.error("angular-google-maps: map zoom property not set"); - return; - } - - var el = angular.element(element); - - el.addClass("angular-google-map"); - - // Parse options - var opts = {options: {}}; - if (attrs.options) { - opts.options = angular.fromJson(attrs.options); - } - - if (attrs.type) { - var type = attrs.type.toUpperCase(); - - if (google.maps.MapTypeId.hasOwnProperty(type)) { - opts.mapTypeId = google.maps.MapTypeId[attrs.type.toUpperCase()]; - } - else { - $log.error('angular-google-maps: invalid map type "' + attrs.type + '"'); - } - } - - // Create the map - var _m = new google.maps.Map(el.find('div')[1], angular.extend({}, DEFAULTS, opts, { - center: new google.maps.LatLng(scope.center.latitude, scope.center.longitude), - draggable: isTrue(attrs.draggable), - zoom: scope.zoom - })); - - var dragging = false; - - google.maps.event.addListener(_m, 'dragstart', function () { - dragging = true; - $timeout(function () { - scope.$apply(function (s) { - s.dragging = dragging; - }); - }); - }); - - google.maps.event.addListener(_m, 'dragend', function () { - dragging = false; - $timeout(function () { - scope.$apply(function (s) { - s.dragging = dragging; - }); - }); - }); - - google.maps.event.addListener(_m, 'drag', function () { - var c = _m.center; - - $timeout(function () { - scope.$apply(function (s) { - s.center.latitude = c.lat(); - s.center.longitude = c.lng(); - }); - }); - }); - - google.maps.event.addListener(_m, 'zoom_changed', function () { - if (scope.zoom != _m.zoom) { - - $timeout(function () { - scope.$apply(function (s) { - s.zoom = _m.zoom; - }); - }); - } - }); - - google.maps.event.addListener(_m, 'center_changed', function () { - var c = _m.center; - - $timeout(function () { - scope.$apply(function (s) { - if (!_m.dragging) { - s.center.latitude = c.lat(); - s.center.longitude = c.lng(); - } - }); - }); - }); - - if (angular.isDefined(scope.events) && - scope.events !== null && - angular.isObject(scope.events)) { - - var getEventHandler = function (eventName) { - return function () { - scope.events[eventName].apply(scope, [_m, eventName, arguments ]); - }; - }; - - for (var eventName in scope.events) { - - if (scope.events.hasOwnProperty(eventName) && angular.isFunction(scope.events[eventName])) { - google.maps.event.addListener(_m, eventName, getEventHandler(eventName)); - } - } - } - - // Put the map into the scope - scope.map = _m; - - google.maps.event.trigger(_m, "resize"); - - // Check if we need to refresh the map - if (!angular.isUndefined(scope.refresh())) { - scope.$watch("refresh()", function (newValue, oldValue) { - if (newValue && !oldValue) { - // _m.draw(); - var coords = new google.maps.LatLng(newValue.latitude, newValue.longitude); - - if (isTrue(attrs.pan)) { - _m.panTo(coords); - } - else { - _m.setCenter(coords); - } - - - } - }); - } - - // Update map when center coordinates change - scope.$watch('center', function (newValue, oldValue) { - if (newValue === oldValue) { - return; - } - - if (!dragging) { - - var coords = new google.maps.LatLng(newValue.latitude, newValue.longitude); - - if (isTrue(attrs.pan)) { - _m.panTo(coords); - } - else { - _m.setCenter(coords); - } - - //_m.draw(); - } - }, true); - - scope.$watch('zoom', function (newValue, oldValue) { - if (newValue === oldValue) { - return; - } - - _m.setZoom(newValue); - - //_m.draw(); - }); - } - }; - }]); +/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + */ + +angular.module('google-maps', []);;/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + */ + +angular.module('google-maps') + .directive('googleMap', ['$log', '$timeout', function ($log, $timeout) { + + "use strict"; + + var DEFAULTS = { + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + + /* + * Utility functions + */ + + /** + * Check if a value is true + */ + function isTrue(val) { + return angular.isDefined(val) && + val !== null && + val === true || + val === '1' || + val === 'y' || + val === 'true'; + } + + return { + /** + * + */ + restrict: 'ECMA', + + /** + * + */ + transclude: true, + + /** + * + */ + replace: false, + + /** + * + */ + //priority: 100, + + /** + * + */ + template: '
', + + /** + * + */ + scope: { + center: '=center', // required + zoom: '=zoom', // required + dragging: '=dragging', // optional + markers: '=markers', // optional + refresh: '&refresh', // optional + windows: '=windows', // optional + events: '=events' // optional + }, + + /** + * + */ + controller: ['$scope', function ($scope) { + /** + * @return the map instance + */ + this.getMap = function () { + return $scope.map; + }; + }], + + /** + * + * @param scope + * @param element + * @param attrs + */ + link: function (scope, element, attrs) { + + // Center property must be specified and provide lat & + // lng properties + if (!angular.isDefined(scope.center) || + (!angular.isDefined(scope.center.latitude) || !angular.isDefined(scope.center.longitude))) { + + $log.error("angular-google-maps: could not find a valid center property"); + return; + } + + if (!angular.isDefined(scope.zoom)) { + $log.error("angular-google-maps: map zoom property not set"); + return; + } + + var el = angular.element(element); + + el.addClass("angular-google-map"); + + // Parse options + var opts = {options: {}}; + if (attrs.options) { + opts.options = angular.fromJson(attrs.options); + } + + if (attrs.type) { + var type = attrs.type.toUpperCase(); + + if (google.maps.MapTypeId.hasOwnProperty(type)) { + opts.mapTypeId = google.maps.MapTypeId[attrs.type.toUpperCase()]; + } + else { + $log.error('angular-google-maps: invalid map type "' + attrs.type + '"'); + } + } + + // Create the map + var _m = new google.maps.Map(el.find('div')[1], angular.extend({}, DEFAULTS, opts, { + center: new google.maps.LatLng(scope.center.latitude, scope.center.longitude), + draggable: isTrue(attrs.draggable), + zoom: scope.zoom + })); + + var dragging = false; + + google.maps.event.addListener(_m, 'dragstart', function () { + dragging = true; + $timeout(function () { + scope.$apply(function (s) { + s.dragging = dragging; + }); + }); + }); + + google.maps.event.addListener(_m, 'dragend', function () { + dragging = false; + $timeout(function () { + scope.$apply(function (s) { + s.dragging = dragging; + }); + }); + }); + + google.maps.event.addListener(_m, 'drag', function () { + var c = _m.center; + + $timeout(function () { + scope.$apply(function (s) { + s.center.latitude = c.lat(); + s.center.longitude = c.lng(); + }); + }); + }); + + google.maps.event.addListener(_m, 'zoom_changed', function () { + if (scope.zoom != _m.zoom) { + + $timeout(function () { + scope.$apply(function (s) { + s.zoom = _m.zoom; + }); + }); + } + }); + + google.maps.event.addListener(_m, 'center_changed', function () { + var c = _m.center; + + $timeout(function () { + scope.$apply(function (s) { + if (!_m.dragging) { + s.center.latitude = c.lat(); + s.center.longitude = c.lng(); + } + }); + }); + }); + + if (angular.isDefined(scope.events) && + scope.events !== null && + angular.isObject(scope.events)) { + + var getEventHandler = function (eventName) { + return function () { + scope.events[eventName].apply(scope, [_m, eventName, arguments ]); + }; + }; + + for (var eventName in scope.events) { + + if (scope.events.hasOwnProperty(eventName) && angular.isFunction(scope.events[eventName])) { + google.maps.event.addListener(_m, eventName, getEventHandler(eventName)); + } + } + } + + // Put the map into the scope + scope.map = _m; + + google.maps.event.trigger(_m, "resize"); + + // Check if we need to refresh the map + if (!angular.isUndefined(scope.refresh())) { + scope.$watch("refresh()", function (newValue, oldValue) { + if (newValue && !oldValue) { + // _m.draw(); + var coords = new google.maps.LatLng(newValue.latitude, newValue.longitude); + + if (isTrue(attrs.pan)) { + _m.panTo(coords); + } + else { + _m.setCenter(coords); + } + + + } + }); + } + + // Update map when center coordinates change + scope.$watch('center', function (newValue, oldValue) { + if (newValue === oldValue) { + return; + } + + if (!dragging) { + + var coords = new google.maps.LatLng(newValue.latitude, newValue.longitude); + + if (isTrue(attrs.pan)) { + _m.panTo(coords); + } + else { + _m.setCenter(coords); + } + + //_m.draw(); + } + }, true); + + scope.$watch('zoom', function (newValue, oldValue) { + if (newValue === oldValue) { + return; + } + + _m.setZoom(newValue); + + //_m.draw(); + }); + } + }; + }]); ;/**! * The MIT License * @@ -454,296 +454,356 @@ angular.module('google-maps') } }; }]); -;/**! - * The MIT License - * - * Copyright (c) 2010-2012 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 - * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 - */ - -angular.module("google-maps") - .directive("polyline", ['$log', '$timeout', function ($log, $timeout) { - - "use strict"; - - var DEFAULTS = { - - }; - - function validatePathPoints(path) { - for (var i = 0; i < path.length; i++) { - if (angular.isUndefined(path[i].latitude) || - angular.isUndefined(path[i].longitude)) { - return false; - } - } - - return true; - } - - function convertPathPoints(path) { - var result = []; - - for (var i = 0; i < path.length; i++) { - result.push(new google.maps.LatLng(path[i].latitude, path[i].longitude)); - } - - return result; - } - - function extendMapBounds(map, points) { - var bounds = new google.maps.LatLngBounds(); - - for (var i = 0; i < points.length; i++) { - bounds.extend(points[i]); - } - - map.fitBounds(bounds); - } - - /* - * Utility functions - */ - - /** - * Check if a value is true - */ - function isTrue(val) { - return angular.isDefined(val) && - val !== null && - val === true || - val === '1' || - val === 'y' || - val === 'true'; - } - - return { - restrict: 'ECA', - require: '^googleMap', - scope: { - path: '=path', - stroke: '=stroke' - }, - link: function (scope, element, attrs, mapCtrl) { - // Validate required properties - if (angular.isUndefined(scope.path) || - scope.path === null || - scope.path.length < 2 || - !validatePathPoints(scope.path)) { - - $log.error("polyline: no valid path attribute found"); - return; - } - - // Wrap polyline initialization inside a $timeout() call to make sure the map is created already - $timeout(function () { - var map = mapCtrl.getMap(); - - var pathPoints = convertPathPoints(scope.path); - - var opts = angular.extend({}, DEFAULTS, { - map: map, - path: pathPoints, - strokeColor: scope.stroke && scope.stroke.color, - strokeOpacity: scope.stroke && scope.stroke.opacity, - strokeWeight: scope.stroke && scope.stroke.weight - }); - - var polyline = new google.maps.Polyline(opts); - - if (isTrue(attrs.fit)) { - extendMapBounds(map, pathPoints); - } - - scope.$watch('path', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - var newPathPoints = convertPathPoints(newValue); - - polyline.setMap(map); - polyline.setPath(newPathPoints); - - if (isTrue(attrs.fit)) { - extendMapBounds(map, newPathPoints); - } - } - else { - // Remove polyline - polyline.setMap(null); - } - } - }, true); - - // Remove polyline on scope $destroy - scope.$on("$destroy", function () { - polyline.setMap(null); - }); - }); - } - }; - }]); -;/**! - * The MIT License - * - * Copyright (c) 2010-2012 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 - * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 - */ - -/** - * Map info window directive - * - * This directive is used to create an info window on an existing map. - * This directive creates a new scope. - * - * {attribute coords required} object containing latitude and longitude properties - * {attribute show optional} map will show when this expression returns true - */ - -angular.module("google-maps"). - directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { - - "use strict"; - - var DEFAULTS = { - - }; - - return { - restrict: 'ECMA', - template: '', - transclude: true, - priority: -100, - require: ['^googleMap', '^?marker'], - scope: { - coords: '=coords', - show: '&show', - templateUrl: '=templateurl', - templateParameter: '=templateparameter', - isIconVisibleOnClick: '=isiconvisibleonclick', - closeClick: '&closeclick' //scope glue to gmap InfoWindow closeclick - }, - link: function (scope, element, attrs, ctrls) { - $timeout(function () { - - var isIconVisibleOnClick = true; - - if (angular.isDefined(attrs.isiconvisibleonclick)) - isIconVisibleOnClick = scope.isIconVisibleOnClick; - - var mapCtrl = ctrls[0], - markerCtrl = ctrls.length > 1 ? ctrls[1] : null; - - var opts = angular.extend({}, DEFAULTS, { - content: element.html(), - position: angular.isDefined(markerCtrl) ? markerCtrl.getMarker().getPosition() : - new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) - }); - - var win = new google.maps.InfoWindow(opts); - - if (angular.isDefined(markerCtrl)) { - // Open window on click - var markerInstance = markerCtrl.getMarker(); - - markerInstance.setClickable(true); - - // Show the window and hide the marker on click - var initialMarkerVisibility; - google.maps.event.addListener(markerInstance, 'click', function () { - win.setPosition(markerInstance.getPosition()); - win.open(mapCtrl.getMap()); - - initialMarkerVisibility = markerInstance.getVisible(); - - markerInstance.setVisible(isIconVisibleOnClick); - }); - - // Set visibility of marker back to what it was before opening the window - google.maps.event.addListener(win, 'closeclick', function () { - markerInstance.setVisible(initialMarkerVisibility); - scope.closeClick(); - }); - } - - function showWindow() { - if (scope.templateUrl) { - $http.get(scope.templateUrl, { cache: $templateCache }) - .then(function (content) { - var templateScope = scope.$new(); - if (angular.isDefined(scope.templateParameter)) { - templateScope.parameter = scope.templateParameter; - } - var compiled = $compile(content.data)(templateScope); - win.setContent(compiled.get(0)); - win.open(mapCtrl.getMap()); - }); - } else { - win.open(mapCtrl.getMap()); - } - } - - function hideWindow() { - win.close(); - } - - scope.$watch('show()', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - showWindow(); - } - else { - hideWindow(); - } - } else if (newValue && !win.getMap()) { - // If we're initially showing the marker and it's not yet visible, show it. - showWindow(); - } - },true); - }, 50); - } - }; - }]); +;/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + */ + +angular.module("google-maps") + .directive("polyline", ['$log', '$timeout', function ($log, $timeout) { + + "use strict"; + + var DEFAULTS = { + + }; + + function validatePathPoints(path) { + for (var i = 0; i < path.length; i++) { + if (angular.isUndefined(path[i].latitude) || + angular.isUndefined(path[i].longitude)) { + return false; + } + } + + return true; + } + + function convertPathPoints(path) { + var result = []; + + for (var i = 0; i < path.length; i++) { + result.push(new google.maps.LatLng(path[i].latitude, path[i].longitude)); + } + + return result; + } + + function extendMapBounds(map, points) { + var bounds = new google.maps.LatLngBounds(); + + for (var i = 0; i < points.length; i++) { + bounds.extend(points[i]); + } + + map.fitBounds(bounds); + } + + /* + * Utility functions + */ + + /** + * Check if a value is true + */ + function isTrue(val) { + return angular.isDefined(val) && + val !== null && + val === true || + val === '1' || + val === 'y' || + val === 'true'; + } + + return { + restrict: 'ECA', + require: '^googleMap', + scope: { + path: '=path', + stroke: '=stroke' + }, + link: function (scope, element, attrs, mapCtrl) { + // Validate required properties + if (angular.isUndefined(scope.path) || + scope.path === null || + scope.path.length < 2 || + !validatePathPoints(scope.path)) { + + $log.error("polyline: no valid path attribute found"); + return; + } + + // Wrap polyline initialization inside a $timeout() call to make sure the map is created already + $timeout(function () { + var map = mapCtrl.getMap(); + + var pathPoints = convertPathPoints(scope.path); + + var opts = angular.extend({}, DEFAULTS, { + map: map, + path: pathPoints, + strokeColor: scope.stroke && scope.stroke.color, + strokeOpacity: scope.stroke && scope.stroke.opacity, + strokeWeight: scope.stroke && scope.stroke.weight + }); + + var polyline = new google.maps.Polyline(opts); + + if (isTrue(attrs.fit)) { + extendMapBounds(map, pathPoints); + } + + scope.$watch('path', function (newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + var newPathPoints = convertPathPoints(newValue); + + polyline.setMap(map); + polyline.setPath(newPathPoints); + + if (isTrue(attrs.fit)) { + extendMapBounds(map, newPathPoints); + } + } + else { + // Remove polyline + polyline.setMap(null); + } + } + }, true); + + // Remove polyline on scope $destroy + scope.$on("$destroy", function () { + polyline.setMap(null); + }); + }); + } + }; + }]); +;/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + */ + +/** + * Map info window directive + * + * This directive is used to create an info window on an existing map. + * This directive creates a new scope. + * + * {attribute coords required} object containing latitude and longitude properties + * {attribute show optional} map will show when this expression returns true + */ + +angular.module("google-maps"). + directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { + + "use strict"; + + var DEFAULTS = { + + }; + + return { + restrict: 'ECMA', + template: '', + transclude: true, + priority: -100, + require: ['^googleMap', '^?marker'], + scope: { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' //scope glue to gmap InfoWindow closeclick + }, + link: function (scope, element, attrs, ctrls) { + $timeout(function () { + + var isIconVisibleOnClick = true; + + if (angular.isDefined(attrs.isiconvisibleonclick)) + isIconVisibleOnClick = scope.isIconVisibleOnClick; + + var mapCtrl = ctrls[0], + markerCtrl = ctrls.length > 1 ? ctrls[1] : null; + + var opts = angular.extend({}, DEFAULTS, { + content: element.html(), + position: angular.isDefined(markerCtrl) ? markerCtrl.getMarker().getPosition() : + new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) + }); + + var win = new google.maps.InfoWindow(opts); + + if (angular.isDefined(markerCtrl)) { + // Open window on click + var markerInstance = markerCtrl.getMarker(); + + markerInstance.setClickable(true); + + // Show the window and hide the marker on click + var initialMarkerVisibility; + google.maps.event.addListener(markerInstance, 'click', function () { + win.setPosition(markerInstance.getPosition()); + win.open(mapCtrl.getMap()); + + initialMarkerVisibility = markerInstance.getVisible(); + + markerInstance.setVisible(isIconVisibleOnClick); + }); + + // Set visibility of marker back to what it was before opening the window + google.maps.event.addListener(win, 'closeclick', function () { + markerInstance.setVisible(initialMarkerVisibility); + scope.closeClick(); + }); + } + + function showWindow() { + if (scope.templateUrl) { + $http.get(scope.templateUrl, { cache: $templateCache }) + .then(function (content) { + var templateScope = scope.$new(); + if (angular.isDefined(scope.templateParameter)) { + templateScope.parameter = scope.templateParameter; + } + var compiled = $compile(content.data)(templateScope); + win.setContent(compiled.get(0)); + win.open(mapCtrl.getMap()); + }); + } else { + win.open(mapCtrl.getMap()); + } + } + + function hideWindow() { + win.close(); + } + + scope.$watch('show()', function (newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + showWindow(); + } + else { + hideWindow(); + } + } else if (newValue && !win.getMap()) { + // If we're initially showing the marker and it's not yet visible, show it. + showWindow(); + } + },true); + }, 50); + } + }; + }]); +;(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; }; + + this.module("oo", function() { + var baseObjectKeywords; + baseObjectKeywords = ['extended', 'included']; + return this.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(0); + } + 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(0); + } + return this; + }; + + return BaseObject; + + })(); + }); + +}).call(this); + +(function() { + this.module = function(names, fn) { + var space, _name; + if (typeof names === 'string') { + names = names.split('.'); + } + space = this[_name = names.shift()] || (this[_name] = {}); + space.module || (space.module = this.module); + if (names.length) { + return space.module(names, fn); + } else { + return fn.call(space); + } + }; + +}).call(this); diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 3f625c7f2..6339d421c 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -1,5 +1,5 @@ -/*! angular-google-maps 0.0.0 2013-07-19 - * AngularJS directives for Google Maps - * git: https://github.com/nlaplante/angular-google-maps.git - */ -angular.module("google-maps",[]),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){"use strict";function c(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)}var d={animation:google.maps.Animation.DROP};return{restrict:"ECMA",require:"^googleMap",priority:-1,transclude:!0,template:'',replace:!0,scope:{coords:"=coords",icon:"=icon",click:"&click"},controller:function(a,b){this.getMarker=function(){return b.data("instance")}},link:function(e,f,g,h){return angular.isUndefined(e.coords)||null===e.coords||angular.isUndefined(e.coords.latitude)||angular.isUndefined(e.coords.longitude)?(a.error("marker: no valid coords attribute found"),void 0):(b(function(){var a=angular.extend({},d,{position:new google.maps.LatLng(e.coords.latitude,e.coords.longitude),map:h.getMap(),icon:e.icon,visible:null!==e.coords.latitude&&null!==e.coords.longitude});angular.isDefined(g.animate)&&c(g.animate)&&delete a.animation;var b=new google.maps.Marker(a);f.data("instance",b),google.maps.event.addListener(b,"click",function(){angular.isDefined(g.click)&&null!==e.click&&e.click()}),e.$watch("coords",function(a,c){a!==c&&(a?(b.setMap(h.getMap()),b.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.setVisible(null!==a.latitude&&null!==a.longitude)):b.setMap(null))},!0),e.$watch("icon",function(a,c){a!==c&&(b.icon=a,b.setMap(null),b.setMap(h.getMap()),b.setPosition(new google.maps.LatLng(e.coords.latitude,e.coords.longitude)),b.setVisible(null!==e.coords.latitude&&null!==e.coords.longitude))},!0),e.$on("$destroy",function(){b.setMap(null)})}),void 0)}}}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +/*! angular-google-maps 0.0.0 2013-07-23 + * AngularJS directives for Google Maps + * git: https://github.com/nlaplante/angular-google-maps.git + */ +angular.module("google-maps",[]),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){"use strict";function c(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)}var d={animation:google.maps.Animation.DROP};return{restrict:"ECMA",require:"^googleMap",priority:-1,transclude:!0,template:'',replace:!0,scope:{coords:"=coords",icon:"=icon",click:"&click"},controller:function(a,b){this.getMarker=function(){return b.data("instance")}},link:function(e,f,g,h){return angular.isUndefined(e.coords)||null===e.coords||angular.isUndefined(e.coords.latitude)||angular.isUndefined(e.coords.longitude)?(a.error("marker: no valid coords attribute found"),void 0):(b(function(){var a=angular.extend({},d,{position:new google.maps.LatLng(e.coords.latitude,e.coords.longitude),map:h.getMap(),icon:e.icon,visible:null!==e.coords.latitude&&null!==e.coords.longitude});angular.isDefined(g.animate)&&c(g.animate)&&delete a.animation;var b=new google.maps.Marker(a);f.data("instance",b),google.maps.event.addListener(b,"click",function(){angular.isDefined(g.click)&&null!==e.click&&e.click()}),e.$watch("coords",function(a,c){a!==c&&(a?(b.setMap(h.getMap()),b.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.setVisible(null!==a.latitude&&null!==a.longitude)):b.setMap(null))},!0),e.$watch("icon",function(a,c){a!==c&&(b.icon=a,b.setMap(null),b.setMap(h.getMap()),b.setPosition(new google.maps.LatLng(e.coords.latitude,e.coords.longitude)),b.setVisible(null!==e.coords.latitude&&null!==e.coords.longitude))},!0),e.$on("$destroy",function(){b.setMap(null)})}),void 0)}}}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this); \ No newline at end of file diff --git a/package.json b/package.json index 40f3b65e4..8de859088 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "grunt-mkdir": "~0.1.1", "grunt-contrib-connect": "~0.3.0", "grunt-open": "~0.2.0", - "grunt-contrib-watch": "~0.4.4" + "grunt-contrib-watch": "~0.4.4", + "grunt-contrib-coffee": "~0.7.0" }, "dependencies": { "grunt-cli": "~0.1.9", diff --git a/src/coffee/oo/base_object.coffee b/src/coffee/oo/base_object.coffee new file mode 100644 index 000000000..f414f7fcf --- /dev/null +++ b/src/coffee/oo/base_object.coffee @@ -0,0 +1,15 @@ +@module "oo", -> + baseObjectKeywords = ['extended', 'included'] + + class @BaseObject + @extend: (obj) -> + for key, value of obj when key not in baseObjectKeywords + @[key] = value + obj.extended?.apply(0) + this + @include: (obj) -> + for key, value of obj when key not in baseObjectKeywords + #Assign properties to the prototype + @::[key] = value + obj.included?.apply(0) + this \ No newline at end of file diff --git a/src/coffee/oo/module.coffee b/src/coffee/oo/module.coffee new file mode 100644 index 000000000..a3ac1ce1c --- /dev/null +++ b/src/coffee/oo/module.coffee @@ -0,0 +1,8 @@ +@module = (names, fn) -> + names = names.split '.' if typeof names is 'string' + space = @[names.shift()] ||= {} + space.module ||= @module + if names.length + space.module names, fn + else + fn.call space \ No newline at end of file diff --git a/src/directives/map.js b/src/js/directives/map.js similarity index 100% rename from src/directives/map.js rename to src/js/directives/map.js diff --git a/src/directives/marker.js b/src/js/directives/marker.js similarity index 100% rename from src/directives/marker.js rename to src/js/directives/marker.js diff --git a/src/directives/polyline.js b/src/js/directives/polyline.js similarity index 100% rename from src/directives/polyline.js rename to src/js/directives/polyline.js diff --git a/src/directives/window.js b/src/js/directives/window.js similarity index 100% rename from src/directives/window.js rename to src/js/directives/window.js diff --git a/src/module.js b/src/js/module.js similarity index 100% rename from src/module.js rename to src/js/module.js From 012aba516272a202513fc7d36b39d3f0471bcd94 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Tue, 23 Jul 2013 13:03:17 -0400 Subject: [PATCH 02/41] - coffeescript directives.api is running with same functionality that the js only had prior --- Gruntfile.js | 15 +- dist/angular-google-maps.js | 353 ++++++++++-------- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/i-marker.coffee | 85 +++++ src/coffee/directives/api/marker.coffee | 6 + src/coffee/directives/api/markers.coffee | 0 ...{base_object.coffee => base-object.coffee} | 0 src/js/directives/marker copy.js | 142 +++++++ src/js/directives/marker.js | 104 +----- 9 files changed, 436 insertions(+), 271 deletions(-) create mode 100644 src/coffee/directives/api/i-marker.coffee create mode 100644 src/coffee/directives/api/marker.coffee create mode 100644 src/coffee/directives/api/markers.coffee rename src/coffee/oo/{base_object.coffee => base-object.coffee} (100%) create mode 100644 src/js/directives/marker copy.js diff --git a/Gruntfile.js b/Gruntfile.js index 79f1d9234..1a73cd49a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -36,7 +36,12 @@ module.exports = function(grunt) { coffee: { compile: { files: { - 'tmp/output_coffee.js': ['src/coffee/*.coffee','src/coffee/oo/*.coffee'] // concat then compile into single file + 'tmp/output_coffee.js': + ['src/coffee/*.coffee', + 'src/coffee/oo/module.coffee', + 'src/coffee/oo/base-object.coffee', + 'src/coffee/directives/api/*.coffee', + 'src/coffee/directives/*.coffee'] // concat then compile into single file } } }, @@ -47,20 +52,20 @@ module.exports = function(grunt) { }, dist: { src: ['src/js/module.js', + 'tmp/output_coffee.js', 'src/js/directives/map.js', 'src/js/directives/marker.js', 'src/js/directives/polyline.js', - 'src/js/directives/window.js', - 'tmp/output_coffee.js'], + 'src/js/directives/window.js'], dest: 'tmp/output.js' }, example: { src: ['src/js/module.js', + 'tmp/output_coffee.js', 'src/js/directives/map.js', 'src/js/directives/marker.js', 'src/js/directives/polyline.js', - 'src/js/directives/window.js', - 'tmp/output_coffee.js'], + 'src/js/directives/window.js'], dest: 'example/<%= pkg.name %>.js' } }, diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 728efc291..a195ff471 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -27,7 +27,194 @@ * @author Nicolas Laplante https://plus.google.com/108189012221374960701 */ -angular.module('google-maps', []);;/**! +angular.module('google-maps', []);;(function() { + this.module = function(names, fn) { + var space, _name; + if (typeof names === 'string') { + names = names.split('.'); + } + space = this[_name = names.shift()] || (this[_name] = {}); + space.module || (space.module = this.module); + if (names.length) { + return space.module(names, fn); + } else { + return fn.call(space); + } + }; + +}).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; }; + + this.module("oo", function() { + var baseObjectKeywords; + baseObjectKeywords = ['extended', 'included']; + return this.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(0); + } + 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(0); + } + return this; + }; + + return BaseObject; + + })(); + }); + +}).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; }; + + this.module("directives.api", function() { + return this.IMarker = (function(_super) { + __extends(IMarker, _super); + + function IMarker($log, $timeout) { + this.link = __bind(this.link, this); + var self; + self = this; + this.$log = $log; + this.$timeout = $timeout; + this.restrict = 'ECMA'; + this.require = '^googleMap'; + this.priority = -1; + this.transclude = true; + this.template = ''; + this.replace = true; + this.scope = { + coords: '=coords', + icon: '=icon', + click: '&click' + }; + $log.info(self); + } + + IMarker.prototype.controller = function($scope, $element) { + return this.getMarker = function() { + return $element.data('instance'); + }; + }; + + IMarker.prototype.link = function(scope, element, attrs, mapCtrl) { + var _this = this; + if (angular.isUndefined(scope.coords) || scope.coords === void 0 || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude)) { + $log.error("marker: no valid coords attribute found"); + return; + } + return this.$timeout(function() { + var marker, opts; + opts = angular.extend({}, _this.DEFAULTS, { + position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), + map: mapCtrl.getMap(), + icon: scope.icon, + visible: (scope.coords.latitude != null) && (scope.coords.longitude != null) + }); + if (angular.isDefined(attrs.animate) && _this.isFalse(attrs.animate)) { + delete opts.animation; + } + marker = new google.maps.Marker(opts); + element.data('instance', marker); + google.maps.event.addListener(marker, 'click', function() { + if (angular.isDefined(attrs.click) && (scope.click != null)) { + return scope.click(); + } + }); + scope.$watch('coords', function(newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + marker.setMap(mapCtrl.getMap()); + marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + return marker.setVisible((newValue.latitude != null) && (newValue.longitude != null)); + } else { + return marker.setMap(void 0); + } + } + }, true); + scope.$watch('icon', function(newValue, oldValue) { + if (newValue !== oldValue) { + marker.icon = newValue; + marker.setMap(void 0); + marker.setMap(mapCtrl.getMap()); + marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); + return marker.setVisible(scope.coords.latitude && (scope.coords.longitude != null)); + } + }, true); + return scope.$on("$destroy", function() { + return marker.setMap(null); + }); + }); + }; + + IMarker.prototype.DEFAULTS = { + animation: google.maps.Animation.DROP + }; + + IMarker.prototype.isFalse = function(value) { + return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) !== -1; + }; + + return IMarker; + + })(oo.BaseObject); + }); + +}).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; }; + + this.module("directives.api", function() { + return this.Marker = (function(_super) { + __extends(Marker, _super); + + function Marker($log, $timeout) { + var self; + Marker.__super__.constructor.call(this, $log, $timeout); + self = this; + $log.info(this); + } + + return Marker; + + })(directives.api.IMarker); + }); + +}).call(this); + +(function() { + + +}).call(this); +;/**! * The MIT License * * Copyright (c) 2010-2012 Google, Inc. http://angularjs.org @@ -352,108 +539,8 @@ angular.module('google-maps') * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps') - .directive('marker', ['$log', '$timeout', function ($log, $timeout) { - - "use strict"; - - var DEFAULTS = { - // Animation is enabled by default - animation: google.maps.Animation.DROP - }; - - /** - * Check if a value is literally false - * @param value the value to test - * @returns {boolean} true if value is literally false, false otherwise - */ - function isFalse(value) { - return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value ) !== -1; - } - - return { - restrict: 'ECMA', - require: '^googleMap', - priority: -1, - transclude: true, - template: '', - replace: true, - scope: { - coords: '=coords', - icon: '=icon', - click: '&click' - }, - controller: function ($scope, $element) { - this.getMarker = function () { - return $element.data('instance'); - }; - }, - link: function (scope, element, attrs, mapCtrl) { - - // Validate required properties - if (angular.isUndefined(scope.coords) || - scope.coords === null || - angular.isUndefined(scope.coords.latitude) || - angular.isUndefined(scope.coords.longitude)) { - - $log.error("marker: no valid coords attribute found"); - return; - } - - // Wrap marker initialization inside a $timeout() call to make sure the map is created already - $timeout(function () { - var opts = angular.extend({}, DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: scope.coords.latitude !== null && scope.coords.longitude !== null - }); - - // Disable animations - if (angular.isDefined(attrs.animate) && isFalse(attrs.animate)) { - delete opts.animation; - } - - var marker = new google.maps.Marker(opts); - element.data('instance', marker); - - google.maps.event.addListener(marker, 'click', function () { - if (angular.isDefined(attrs.click) && scope.click !== null) - scope.click(); - }); - - scope.$watch('coords', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - marker.setVisible(newValue.latitude !== null && newValue.longitude !== null); - } - else { - // Remove marker - marker.setMap(null); - } - } - }, true); - - scope.$watch('icon', function (newValue, oldValue) { - if (newValue !== oldValue) { - marker.icon = newValue; - marker.setMap(null); - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); - marker.setVisible(scope.coords.latitude !== null && scope.coords.longitude !== null); - } - }, true); - - // remove marker on scope $destroy - scope.$on("$destroy", function () { - marker.setMap(null); - }); - }); - } - }; - }]); +angular.module('google-maps').directive('marker', ['$log', '$timeout', function($log,$timeout){ + return new directves.api.Marker($log,$timeout);}]); ;/**! * The MIT License * @@ -747,63 +834,3 @@ angular.module("google-maps"). } }; }]); -;(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; }; - - this.module("oo", function() { - var baseObjectKeywords; - baseObjectKeywords = ['extended', 'included']; - return this.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(0); - } - 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(0); - } - return this; - }; - - return BaseObject; - - })(); - }); - -}).call(this); - -(function() { - this.module = function(names, fn) { - var space, _name; - if (typeof names === 'string') { - names = names.split('.'); - } - space = this[_name = names.shift()] || (this[_name] = {}); - space.module || (space.module = this.module); - if (names.length) { - return space.module(names, fn); - } else { - return fn.call(space); - } - }; - -}).call(this); diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 6339d421c..7c83934bf 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){"use strict";function c(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)}var d={animation:google.maps.Animation.DROP};return{restrict:"ECMA",require:"^googleMap",priority:-1,transclude:!0,template:'',replace:!0,scope:{coords:"=coords",icon:"=icon",click:"&click"},controller:function(a,b){this.getMarker=function(){return b.data("instance")}},link:function(e,f,g,h){return angular.isUndefined(e.coords)||null===e.coords||angular.isUndefined(e.coords.latitude)||angular.isUndefined(e.coords.longitude)?(a.error("marker: no valid coords attribute found"),void 0):(b(function(){var a=angular.extend({},d,{position:new google.maps.LatLng(e.coords.latitude,e.coords.longitude),map:h.getMap(),icon:e.icon,visible:null!==e.coords.latitude&&null!==e.coords.longitude});angular.isDefined(g.animate)&&c(g.animate)&&delete a.animation;var b=new google.maps.Marker(a);f.data("instance",b),google.maps.event.addListener(b,"click",function(){angular.isDefined(g.click)&&null!==e.click&&e.click()}),e.$watch("coords",function(a,c){a!==c&&(a?(b.setMap(h.getMap()),b.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.setVisible(null!==a.latitude&&null!==a.longitude)):b.setMap(null))},!0),e.$watch("icon",function(a,c){a!==c&&(b.icon=a,b.setMap(null),b.setMap(h.getMap()),b.setPosition(new google.maps.LatLng(e.coords.latitude,e.coords.longitude)),b.setVisible(null!==e.coords.latitude&&null!==e.coords.longitude))},!0),e.$on("$destroy",function(){b.setMap(null)})}),void 0)}}}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.link=a(this.link,this);var d;d=this,this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){var e=this;return angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)?($log.error("marker: no valid coords attribute found"),void 0):this.$timeout(function(){var f,g;return g=angular.extend({},e.DEFAULTS,{position:new google.maps.LatLng(a.coords.latitude,a.coords.longitude),map:d.getMap(),icon:a.icon,visible:null!=a.coords.latitude&&null!=a.coords.longitude}),angular.isDefined(c.animate)&&e.isFalse(c.animate)&&delete g.animation,f=new google.maps.Marker(g),b.data("instance",f),google.maps.event.addListener(f,"click",function(){return angular.isDefined(c.click)&&null!=a.click?a.click():void 0}),a.$watch("coords",function(a,b){return a!==b?a?(f.setMap(d.getMap()),f.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),f.setVisible(null!=a.latitude&&null!=a.longitude)):f.setMap(void 0):void 0},!0),a.$watch("icon",function(b,c){return b!==c?(f.icon=b,f.setMap(void 0),f.setMap(d.getMap()),f.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),f.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},!0),a.$on("$destroy",function(){return f.setMap(null)})})},d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api",function(){return this.Marker=function(a){function c(a,b){var d;c.__super__.constructor.call(this,a,b),d=this,a.info(this)}return b(c,a),c}(directives.api.IMarker)})}.call(this),function(){}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directves.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee new file mode 100644 index 000000000..f11b32633 --- /dev/null +++ b/src/coffee/directives/api/i-marker.coffee @@ -0,0 +1,85 @@ +# simple module of functions to be overriden / mixed in +@module "directives.api", -> + class @IMarker extends oo.BaseObject + constructor: ($log, $timeout) -> + self = @ + @$log = $log + @$timeout = $timeout + @restrict = 'ECMA' + @require = '^googleMap' + @priority = -1 + @transclude = true + @template = '' + @replace = true + @scope = { + coords: '=coords', + icon: '=icon', + click: '&click' + } + + $log.info(self) + + controller: ($scope, $element) -> + @.getMarker = -> + $element.data('instance') + + link: (scope, element, attrs, mapCtrl) => + # Validate required properties + if (angular.isUndefined(scope.coords) or + scope.coords == undefined or + angular.isUndefined(scope.coords.latitude) or + angular.isUndefined(scope.coords.longitude)) + $log.error("marker: no valid coords attribute found") + return + # Wrap marker initialization inside a $timeout() call to make sure the map is created already + @$timeout( => + opts = angular.extend({}, @DEFAULTS, { + position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), + map: mapCtrl.getMap(), + icon: scope.icon, + visible: scope.coords.latitude? and scope.coords.longitude? + }) + + # Disable animations + if (angular.isDefined(attrs.animate) and @isFalse(attrs.animate)) + delete opts.animation; + + marker = new google.maps.Marker(opts) + element.data('instance', marker) + + google.maps.event.addListener(marker, 'click', -> + if (angular.isDefined(attrs.click) and scope.click?) + scope.click() + ) + + scope.$watch('coords', (newValue, oldValue) => + if (newValue != oldValue) + if (newValue) + marker.setMap(mapCtrl.getMap()) + marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + marker.setVisible(newValue.latitude? and newValue.longitude?) + else + # Remove marker + marker.setMap(undefined); + , true) + + scope.$watch('icon', (newValue, oldValue) => + if (newValue != oldValue) + marker.icon = newValue + marker.setMap(undefined) + marker.setMap(mapCtrl.getMap()) + marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) + marker.setVisible(scope.coords.latitude and scope.coords.longitude?); + , true) + + # remove marker on scope $destroy + scope.$on("$destroy", -> marker.setMap(null)) + ) + # Animation is enabled by default + DEFAULTS: { animation: google.maps.Animation.DROP } + + # Check if a value is literally false + # @param value the value to test + # @returns {boolean} true if value is literally false, false otherwise + isFalse: (value) -> + ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) != -1 \ No newline at end of file diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee new file mode 100644 index 000000000..7112aa3c7 --- /dev/null +++ b/src/coffee/directives/api/marker.coffee @@ -0,0 +1,6 @@ +@module "directives.api", -> + class @Marker extends directives.api.IMarker + constructor: ($log, $timeout) -> + super($log,$timeout) + self = @ + $log.info(@) \ No newline at end of file diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee new file mode 100644 index 000000000..e69de29bb diff --git a/src/coffee/oo/base_object.coffee b/src/coffee/oo/base-object.coffee similarity index 100% rename from src/coffee/oo/base_object.coffee rename to src/coffee/oo/base-object.coffee diff --git a/src/js/directives/marker copy.js b/src/js/directives/marker copy.js new file mode 100644 index 000000000..825ac42b9 --- /dev/null +++ b/src/js/directives/marker copy.js @@ -0,0 +1,142 @@ +/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + */ + +/** + * Map marker directive + * + * This directive is used to create a marker on an existing map. + * This directive creates a new scope. + * + * {attribute coords required} object containing latitude and longitude properties + * {attribute icon optional} string url to image used for marker icon + * {attribute animate optional} if set to false, the marker won't be animated (on by default) + */ + +angular.module('google-maps') + .directive('marker', ['$log', '$timeout', function ($log, $timeout) { + + "use strict"; + + var DEFAULTS = { + // Animation is enabled by default + animation: google.maps.Animation.DROP + }; + + /** + * Check if a value is literally false + * @param value the value to test + * @returns {boolean} true if value is literally false, false otherwise + */ + function isFalse(value) { + return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value ) !== -1; + } + + return { + restrict: 'ECMA', + require: '^googleMap', + priority: -1, + transclude: true, + template: '', + replace: true, + scope: { + coords: '=coords', + icon: '=icon', + click: '&click' + }, + controller: function ($scope, $element) { + this.getMarker = function () { + return $element.data('instance'); + }; + }, + link: function (scope, element, attrs, mapCtrl) { + + // Validate required properties + if (angular.isUndefined(scope.coords) || + scope.coords === null || + angular.isUndefined(scope.coords.latitude) || + angular.isUndefined(scope.coords.longitude)) { + + $log.error("marker: no valid coords attribute found"); + return; + } + + // Wrap marker initialization inside a $timeout() call to make sure the map is created already + $timeout(function () { + var opts = angular.extend({}, DEFAULTS, { + position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), + map: mapCtrl.getMap(), + icon: scope.icon, + visible: scope.coords.latitude !== null && scope.coords.longitude !== null + }); + + // Disable animations + if (angular.isDefined(attrs.animate) && isFalse(attrs.animate)) { + delete opts.animation; + } + + var marker = new google.maps.Marker(opts); + element.data('instance', marker); + + google.maps.event.addListener(marker, 'click', function () { + if (angular.isDefined(attrs.click) && scope.click !== null) + scope.click(); + }); + + scope.$watch('coords', function (newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + marker.setMap(mapCtrl.getMap()); + marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + marker.setVisible(newValue.latitude !== null && newValue.longitude !== null); + } + else { + // Remove marker + marker.setMap(null); + } + } + }, true); + + scope.$watch('icon', function (newValue, oldValue) { + if (newValue !== oldValue) { + marker.icon = newValue; + marker.setMap(null); + marker.setMap(mapCtrl.getMap()); + marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); + marker.setVisible(scope.coords.latitude !== null && scope.coords.longitude !== null); + } + }, true); + + // remove marker on scope $destroy + scope.$on("$destroy", function () { + marker.setMap(null); + }); + }); + } + }; + }]); diff --git a/src/js/directives/marker.js b/src/js/directives/marker.js index 825ac42b9..35b82eab5 100644 --- a/src/js/directives/marker.js +++ b/src/js/directives/marker.js @@ -38,105 +38,5 @@ * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps') - .directive('marker', ['$log', '$timeout', function ($log, $timeout) { - - "use strict"; - - var DEFAULTS = { - // Animation is enabled by default - animation: google.maps.Animation.DROP - }; - - /** - * Check if a value is literally false - * @param value the value to test - * @returns {boolean} true if value is literally false, false otherwise - */ - function isFalse(value) { - return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value ) !== -1; - } - - return { - restrict: 'ECMA', - require: '^googleMap', - priority: -1, - transclude: true, - template: '', - replace: true, - scope: { - coords: '=coords', - icon: '=icon', - click: '&click' - }, - controller: function ($scope, $element) { - this.getMarker = function () { - return $element.data('instance'); - }; - }, - link: function (scope, element, attrs, mapCtrl) { - - // Validate required properties - if (angular.isUndefined(scope.coords) || - scope.coords === null || - angular.isUndefined(scope.coords.latitude) || - angular.isUndefined(scope.coords.longitude)) { - - $log.error("marker: no valid coords attribute found"); - return; - } - - // Wrap marker initialization inside a $timeout() call to make sure the map is created already - $timeout(function () { - var opts = angular.extend({}, DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: scope.coords.latitude !== null && scope.coords.longitude !== null - }); - - // Disable animations - if (angular.isDefined(attrs.animate) && isFalse(attrs.animate)) { - delete opts.animation; - } - - var marker = new google.maps.Marker(opts); - element.data('instance', marker); - - google.maps.event.addListener(marker, 'click', function () { - if (angular.isDefined(attrs.click) && scope.click !== null) - scope.click(); - }); - - scope.$watch('coords', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - marker.setVisible(newValue.latitude !== null && newValue.longitude !== null); - } - else { - // Remove marker - marker.setMap(null); - } - } - }, true); - - scope.$watch('icon', function (newValue, oldValue) { - if (newValue !== oldValue) { - marker.icon = newValue; - marker.setMap(null); - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); - marker.setVisible(scope.coords.latitude !== null && scope.coords.longitude !== null); - } - }, true); - - // remove marker on scope $destroy - scope.$on("$destroy", function () { - marker.setMap(null); - }); - }); - } - }; - }]); +angular.module('google-maps').directive('marker', ['$log', '$timeout', function($log,$timeout){ + return new directives.api.Marker($log,$timeout);}]); From 0c07d5ebc46e1bb6c26fc3e70a8da066ed98345c Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Tue, 23 Jul 2013 14:23:47 -0400 Subject: [PATCH 03/41] -seperating functionality of a normal Marker to be inside Marker.coffee - it is following the Interface IMarker --- dist/angular-google-maps.js | 134 +++++++++++++++------- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/i-marker.coffee | 69 +++++------ src/coffee/directives/api/marker.coffee | 45 +++++++- 4 files changed, 162 insertions(+), 88 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index a195ff471..50a7f65e0 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -97,8 +97,20 @@ angular.module('google-maps', []);;(function() { return this.IMarker = (function(_super) { __extends(IMarker, _super); + IMarker.prototype.DEFAULTS = { + animation: google.maps.Animation.DROP + }; + + IMarker.prototype.isFalse = function(value) { + return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) !== -1; + }; + function IMarker($log, $timeout) { this.link = __bind(this.link, this); + this.linkInit = __bind(this.linkInit, this); + this.onDestroy = __bind(this.onDestroy, this); + this.onIconChanged = __bind(this.onIconChanged, this); + this.onCordsChanged = __bind(this.onCordsChanged, this); var self; self = this; this.$log = $log; @@ -117,6 +129,22 @@ angular.module('google-maps', []);;(function() { $log.info(self); } + IMarker.prototype.onCordsChanged = function(newValue, oldValue, id) { + throw new Exception("Not Implemented!!"); + }; + + IMarker.prototype.onIconChanged = function(newValue, oldValue, id, coords) { + throw new Exception("Not Implemented!!"); + }; + + IMarker.prototype.onDestroy = function(id) { + throw new Exception("Not Implemented!!"); + }; + + IMarker.prototype.linkInit = function(element, mapCtrl, scope, animate) { + throw new Exception("Not Implemented!!"); + }; + IMarker.prototype.controller = function($scope, $element) { return this.getMarker = function() { return $element.data('instance'); @@ -130,57 +158,21 @@ angular.module('google-maps', []);;(function() { return; } return this.$timeout(function() { - var marker, opts; - opts = angular.extend({}, _this.DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: (scope.coords.latitude != null) && (scope.coords.longitude != null) - }); - if (angular.isDefined(attrs.animate) && _this.isFalse(attrs.animate)) { - delete opts.animation; - } - marker = new google.maps.Marker(opts); - element.data('instance', marker); - google.maps.event.addListener(marker, 'click', function() { - if (angular.isDefined(attrs.click) && (scope.click != null)) { - return scope.click(); - } - }); + var animate; + animate = angular.isDefined(attrs.animate) && _this.isFalse(attrs.animate); + _this.linkInit(element, mapCtrl, scope, animate, angular.isDefined(attrs.click)); scope.$watch('coords', function(newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - return marker.setVisible((newValue.latitude != null) && (newValue.longitude != null)); - } else { - return marker.setMap(void 0); - } - } + return _this.onCordsChanged(newValue, oldValue, scope.$id); }, true); scope.$watch('icon', function(newValue, oldValue) { - if (newValue !== oldValue) { - marker.icon = newValue; - marker.setMap(void 0); - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); - return marker.setVisible(scope.coords.latitude && (scope.coords.longitude != null)); - } + return _this.onIconChanged(newValue, oldValue, scope.$id, scope.coords); }, true); return scope.$on("$destroy", function() { - return marker.setMap(null); + return onDestroy(scope.$id); }); }); }; - IMarker.prototype.DEFAULTS = { - animation: google.maps.Animation.DROP - }; - - IMarker.prototype.isFalse = function(value) { - return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) !== -1; - }; - return IMarker; })(oo.BaseObject); @@ -189,7 +181,8 @@ angular.module('google-maps', []);;(function() { }).call(this); (function() { - var __hasProp = {}.hasOwnProperty, + 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; }; this.module("directives.api", function() { @@ -197,12 +190,65 @@ angular.module('google-maps', []);;(function() { __extends(Marker, _super); function Marker($log, $timeout) { + this.linkInit = __bind(this.linkInit, this); + this.onDestroy = __bind(this.onDestroy, this); + this.onIconChanged = __bind(this.onIconChanged, this); + this.onCordsChanged = __bind(this.onCordsChanged, this); var self; Marker.__super__.constructor.call(this, $log, $timeout); self = this; $log.info(this); + this.marker = {}; + this.mapCtrl = void 0; } + Marker.prototype.onCordsChanged = function(newValue, oldValue, id) { + if (newValue !== oldValue) { + if (newValue) { + this.marker[id].setMap(this.mapCtrl.getMap()); + this.marker[id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + return this.marker[id].setVisible((newValue.latitude != null) && (newValue.longitude != null)); + } else { + return this.marker[id].setMap(void 0); + } + } + }; + + Marker.prototype.onIconChanged = function(newValue, oldValue, id, coords) { + if (newValue !== oldValue) { + this.marker[id].icon = newValue; + this.marker[id].setMap(void 0); + this.marker[id].setMap(this.mapCtrl.getMap()); + this.marker[id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); + return this.marker[id].setVisible(coords.latitude && (coords.longitude != null)); + } + }; + + Marker.prototype.onDestroy = function(id) { + return this.marker[id].setMap(null); + }; + + Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { + var opts; + this.mapCtrl = mapCtrl; + opts = angular.extend({}, this.DEFAULTS, { + position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), + map: mapCtrl.getMap(), + icon: scope.icon, + visible: (scope.coords.latitude != null) && (scope.coords.longitude != null) + }); + if (!animate) { + delete opts.animation; + } + this.marker[scope.$id] = new google.maps.Marker(opts); + element.data('instance', this.marker[scope.$id]); + return google.maps.event.addListener(this.marker[scope.$id], 'click', function() { + if (doClick && (scope.click != null)) { + return scope.click(); + } + }); + }; + return Marker; })(directives.api.IMarker); @@ -540,7 +586,7 @@ angular.module('google-maps') */ angular.module('google-maps').directive('marker', ['$log', '$timeout', function($log,$timeout){ - return new directves.api.Marker($log,$timeout);}]); + return new directives.api.Marker($log,$timeout);}]); ;/**! * The MIT License * diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 7c83934bf..3aafe3e16 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.link=a(this.link,this);var d;d=this,this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){var e=this;return angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)?($log.error("marker: no valid coords attribute found"),void 0):this.$timeout(function(){var f,g;return g=angular.extend({},e.DEFAULTS,{position:new google.maps.LatLng(a.coords.latitude,a.coords.longitude),map:d.getMap(),icon:a.icon,visible:null!=a.coords.latitude&&null!=a.coords.longitude}),angular.isDefined(c.animate)&&e.isFalse(c.animate)&&delete g.animation,f=new google.maps.Marker(g),b.data("instance",f),google.maps.event.addListener(f,"click",function(){return angular.isDefined(c.click)&&null!=a.click?a.click():void 0}),a.$watch("coords",function(a,b){return a!==b?a?(f.setMap(d.getMap()),f.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),f.setVisible(null!=a.latitude&&null!=a.longitude)):f.setMap(void 0):void 0},!0),a.$watch("icon",function(b,c){return b!==c?(f.icon=b,f.setMap(void 0),f.setMap(d.getMap()),f.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),f.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},!0),a.$on("$destroy",function(){return f.setMap(null)})})},d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api",function(){return this.Marker=function(a){function c(a,b){var d;c.__super__.constructor.call(this,a,b),d=this,a.info(this)}return b(c,a),c}(directives.api.IMarker)})}.call(this),function(){}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directves.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.link=a(this.link,this),this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onIconChanged=a(this.onIconChanged,this),this.onCordsChanged=a(this.onCordsChanged,this);var d;d=this,this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onCordsChanged=function(){throw new Exception("Not Implemented!!")},d.prototype.onIconChanged=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){var e=this;return angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)?($log.error("marker: no valid coords attribute found"),void 0):this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),a.$watch("coords",function(b,c){return e.onCordsChanged(b,c,a.$id)},!0),a.$watch("icon",function(b,c){return e.onIconChanged(b,c,a.$id,a.coords)},!0),a.$on("$destroy",function(){return onDestroy(a.$id)})})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onIconChanged=a(this.onIconChanged,this),this.onCordsChanged=a(this.onCordsChanged,this);var e;d.__super__.constructor.call(this,b,c),e=this,b.info(this),this.marker={},this.mapCtrl=void 0}return c(d,b),d.prototype.onCordsChanged=function(a,b,c){return a!==b?a?(this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(a.latitude,a.longitude)),this.marker[c].setVisible(null!=a.latitude&&null!=a.longitude)):this.marker[c].setMap(void 0):void 0},d.prototype.onIconChanged=function(a,b,c,d){return a!==b?(this.marker[c].icon=a,this.marker[c].setMap(void 0),this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(d.latitude,d.longitude)),this.marker[c].setVisible(d.latitude&&null!=d.longitude)):void 0},d.prototype.onDestroy=function(a){return this.marker[a].setMap(null)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.marker[c.$id]=new google.maps.Marker(f),a.data("instance",this.marker[c.$id]),google.maps.event.addListener(this.marker[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d}(directives.api.IMarker)})}.call(this),function(){}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index f11b32633..e6c83d425 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -1,6 +1,15 @@ # simple module of functions to be overriden / mixed in @module "directives.api", -> class @IMarker extends oo.BaseObject + # Animation is enabled by default + DEFAULTS: { animation: google.maps.Animation.DROP } + + # Check if a value is literally false + # @param value the value to test + # @returns {boolean} true if value is literally false, false otherwise + isFalse: (value) -> + ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) != -1 + constructor: ($log, $timeout) -> self = @ @$log = $log @@ -19,8 +28,19 @@ $log.info(self) + onCordsChanged:(newValue,oldValue,id) => + throw new Exception("Not Implemented!!") + + onIconChanged:(newValue,oldValue,id,coords) => + throw new Exception("Not Implemented!!") + onDestroy:(id) => + throw new Exception("Not Implemented!!") + + linkInit:(element,mapCtrl,scope,animate)=> + throw new Exception("Not Implemented!!") + controller: ($scope, $element) -> - @.getMarker = -> + @getMarker = -> $element.data('instance') link: (scope, element, attrs, mapCtrl) => @@ -33,53 +53,18 @@ return # Wrap marker initialization inside a $timeout() call to make sure the map is created already @$timeout( => - opts = angular.extend({}, @DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: scope.coords.latitude? and scope.coords.longitude? - }) - - # Disable animations - if (angular.isDefined(attrs.animate) and @isFalse(attrs.animate)) - delete opts.animation; - - marker = new google.maps.Marker(opts) - element.data('instance', marker) + animate = angular.isDefined(attrs.animate) and @isFalse(attrs.animate) - google.maps.event.addListener(marker, 'click', -> - if (angular.isDefined(attrs.click) and scope.click?) - scope.click() - ) + @linkInit(element,mapCtrl,scope,animate,angular.isDefined(attrs.click)) scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - if (newValue) - marker.setMap(mapCtrl.getMap()) - marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - marker.setVisible(newValue.latitude? and newValue.longitude?) - else - # Remove marker - marker.setMap(undefined); + @onCordsChanged(newValue,oldValue,scope.$id) , true) scope.$watch('icon', (newValue, oldValue) => - if (newValue != oldValue) - marker.icon = newValue - marker.setMap(undefined) - marker.setMap(mapCtrl.getMap()) - marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) - marker.setVisible(scope.coords.latitude and scope.coords.longitude?); + @onIconChanged(newValue,oldValue,scope.$id,scope.coords) , true) # remove marker on scope $destroy - scope.$on("$destroy", -> marker.setMap(null)) - ) - # Animation is enabled by default - DEFAULTS: { animation: google.maps.Animation.DROP } - - # Check if a value is literally false - # @param value the value to test - # @returns {boolean} true if value is literally false, false otherwise - isFalse: (value) -> - ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) != -1 \ No newline at end of file + scope.$on("$destroy", -> onDestroy(scope.$id)) + ) \ No newline at end of file diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index 7112aa3c7..3408b5b90 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -3,4 +3,47 @@ constructor: ($log, $timeout) -> super($log,$timeout) self = @ - $log.info(@) \ No newline at end of file + $log.info(@) + @marker = {} + @mapCtrl = undefined + + onCordsChanged:(newValue,oldValue,id) => + if (newValue != oldValue) + if (newValue) + @marker[id].setMap(@mapCtrl.getMap()) + @marker[id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + @marker[id].setVisible(newValue.latitude? and newValue.longitude?) + else + # Remove marker + @marker[id].setMap(undefined); + + onIconChanged:(newValue,oldValue,id,coords) => + if (newValue != oldValue) + @marker[id].icon = newValue + @marker[id].setMap(undefined) + @marker[id].setMap(@mapCtrl.getMap()) + @marker[id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) + @marker[id].setVisible(coords.latitude and coords.longitude?); + + onDestroy:(id)=> + @marker[id].setMap(null) + + linkInit:(element,mapCtrl,scope,animate,doClick) => + @mapCtrl = mapCtrl + opts = angular.extend({}, @DEFAULTS, { + position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), + map: mapCtrl.getMap(), + icon: scope.icon, + visible: scope.coords.latitude? and scope.coords.longitude? + }) + + if !animate + delete opts.animation; + + @marker[scope.$id] = new google.maps.Marker(opts) + element.data('instance', @marker[scope.$id]) + + google.maps.event.addListener(@marker[scope.$id], 'click', -> + if doClick and scope.click? + scope.click() + ) \ No newline at end of file From 84a33584cdcc9cd9b4bc4854cfebe7ba8ef02220 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 08:39:53 -0400 Subject: [PATCH 04/41] making the interface less restrictive, and allowing flexibility in how a marker defines watches. However certain watches are enforced, along with required properties. --- dist/angular-google-maps.js | 172 ++++++++++++++++++---- dist/angular-google-maps.min.js | 4 +- example/example.html | 8 + src/coffee/directives/api/i-marker.coffee | 36 ++--- src/coffee/directives/api/marker.coffee | 51 ++++--- src/coffee/directives/api/markers.coffee | 73 +++++++++ 6 files changed, 270 insertions(+), 74 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 50a7f65e0..9dc96c0ee 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -107,12 +107,14 @@ angular.module('google-maps', []);;(function() { function IMarker($log, $timeout) { this.link = __bind(this.link, this); + this.validateLinkedScope = __bind(this.validateLinkedScope, this); this.linkInit = __bind(this.linkInit, this); - this.onDestroy = __bind(this.onDestroy, this); - this.onIconChanged = __bind(this.onIconChanged, this); - this.onCordsChanged = __bind(this.onCordsChanged, this); + this.watchDestroy = __bind(this.watchDestroy, this); + this.watchIcon = __bind(this.watchIcon, this); + this.watchCoords = __bind(this.watchCoords, this); var self; self = this; + this.clsName = "IMarker"; this.$log = $log; this.$timeout = $timeout; this.restrict = 'ECMA'; @@ -129,15 +131,15 @@ angular.module('google-maps', []);;(function() { $log.info(self); } - IMarker.prototype.onCordsChanged = function(newValue, oldValue, id) { + IMarker.prototype.watchCoords = function(scope) { throw new Exception("Not Implemented!!"); }; - IMarker.prototype.onIconChanged = function(newValue, oldValue, id, coords) { + IMarker.prototype.watchIcon = function(scope) { throw new Exception("Not Implemented!!"); }; - IMarker.prototype.onDestroy = function(id) { + IMarker.prototype.watchDestroy = function(scope) { throw new Exception("Not Implemented!!"); }; @@ -151,25 +153,27 @@ angular.module('google-maps', []);;(function() { }; }; + IMarker.prototype.validateLinkedScope = function(scope) { + var ret; + ret = angular.isUndefined(scope.coords) || scope.coords === void 0 || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude); + if (ret) { + $log.error(this.clsName + ": no valid coords attribute found"); + } + return ret; + }; + IMarker.prototype.link = function(scope, element, attrs, mapCtrl) { var _this = this; - if (angular.isUndefined(scope.coords) || scope.coords === void 0 || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude)) { - $log.error("marker: no valid coords attribute found"); + if (this.validateLinkedScope(scope)) { return; } return this.$timeout(function() { var animate; animate = angular.isDefined(attrs.animate) && _this.isFalse(attrs.animate); _this.linkInit(element, mapCtrl, scope, animate, angular.isDefined(attrs.click)); - scope.$watch('coords', function(newValue, oldValue) { - return _this.onCordsChanged(newValue, oldValue, scope.$id); - }, true); - scope.$watch('icon', function(newValue, oldValue) { - return _this.onIconChanged(newValue, oldValue, scope.$id, scope.coords); - }, true); - return scope.$on("$destroy", function() { - return onDestroy(scope.$id); - }); + _this.watchCoords(scope); + _this.watchIcon(scope); + return _this.watchDestroy(scope); }); }; @@ -190,19 +194,123 @@ angular.module('google-maps', []);;(function() { __extends(Marker, _super); function Marker($log, $timeout) { + this.linkInit = __bind(this.linkInit, this); + this.watchDestroy = __bind(this.watchDestroy, this); + this.watchIcon = __bind(this.watchIcon, this); + this.watchCoords = __bind(this.watchCoords, this); + var self; + Marker.__super__.constructor.call(this, $log, $timeout); + self = this; + this.clsName = "Marker"; + $log.info(this); + this.markers = {}; + this.mapCtrl = void 0; + } + + Marker.prototype.watchCoords = function(scope) { + var _this = this; + return scope.$watch('coords', function(newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); + _this.markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + return _this.markers[scope.$id].setVisible((newValue.latitude != null) && (newValue.longitude != null)); + } else { + return _this.markers[scope.$id].setMap(void 0); + } + } + }, true); + }; + + Marker.prototype.watchIcon = function(scope) { + var _this = this; + return scope.$watch('icon', function(newValue, oldValue) { + if (newValue !== oldValue) { + _this.markers[scope.$id].icon = newValue; + _this.markers[scope.$id].setMap(void 0); + _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); + _this.markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); + return _this.markers[scope.$id].setVisible(coords.latitude && (coords.longitude != null)); + } + }, true); + }; + + Marker.prototype.watchDestroy = function(scope) { + return scope.$on("$destroy", function() { + return this.markers[scope.$id].setMap(null); + }); + }; + + Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { + var opts; + this.mapCtrl = mapCtrl; + opts = angular.extend({}, this.DEFAULTS, { + position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), + map: mapCtrl.getMap(), + icon: scope.icon, + visible: (scope.coords.latitude != null) && (scope.coords.longitude != null) + }); + if (!animate) { + delete opts.animation; + } + this.markers[scope.$id] = new google.maps.Marker(opts); + element.data('instance', this.markers[scope.$id]); + return google.maps.event.addListener(this.markers[scope.$id], 'click', function() { + if (doClick && (scope.click != null)) { + return scope.click(); + } + }); + }; + + return Marker; + + })(directives.api.IMarker); + }); + +}).call(this); + + +/* +Markers will map icon and coords differently as there us not 1:1 Scope to marker +icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] +coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] + +property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself + +Coords and icons need to be rewatched within Markers linked scope +*/ + +(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; }; + + this.module("directives.api", function() { + return this.Markers = (function(_super) { + __extends(Markers, _super); + + function Markers($log, $timeout) { this.linkInit = __bind(this.linkInit, this); this.onDestroy = __bind(this.onDestroy, this); this.onIconChanged = __bind(this.onIconChanged, this); this.onCordsChanged = __bind(this.onCordsChanged, this); var self; - Marker.__super__.constructor.call(this, $log, $timeout); + Markers.__super__.constructor.call(this, $log, $timeout); self = this; - $log.info(this); - this.marker = {}; + this.clsName = "Markers"; + this.scope.markers = '=markers'; + this.markers = []; this.mapCtrl = void 0; + this.iconKey = void 0; + this.coordsKey = void 0; + $log.info(this); } - Marker.prototype.onCordsChanged = function(newValue, oldValue, id) { + Markers.prototype.getMarkerProperty = function(marker, property) { + return marker[property]; + }; + + Markers.prototype.onCordsChanged = function(newValue, oldValue, id) { if (newValue !== oldValue) { if (newValue) { this.marker[id].setMap(this.mapCtrl.getMap()); @@ -214,7 +322,7 @@ angular.module('google-maps', []);;(function() { } }; - Marker.prototype.onIconChanged = function(newValue, oldValue, id, coords) { + Markers.prototype.onIconChanged = function(newValue, oldValue, id, coords) { if (newValue !== oldValue) { this.marker[id].icon = newValue; this.marker[id].setMap(void 0); @@ -224,11 +332,20 @@ angular.module('google-maps', []);;(function() { } }; - Marker.prototype.onDestroy = function(id) { + Markers.prototype.onDestroy = function(id) { return this.marker[id].setMap(null); }; - Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { + Markers.prototype.validateLinkedScope = function(scope) { + var markerNotDefined; + markerNotDefined = angular.isUndefined(scope.markers) || scope.markers === void 0; + if (markerNotDefined) { + $log.error(this.clsName + ": no valid markers attribute found"); + } + return Markers.__super__.validateLinkedScope.apply(this, arguments).validateLinkedScope(scope) || markerNotDefined; + }; + + Markers.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { var opts; this.mapCtrl = mapCtrl; opts = angular.extend({}, this.DEFAULTS, { @@ -249,16 +366,11 @@ angular.module('google-maps', []);;(function() { }); }; - return Marker; + return Markers; })(directives.api.IMarker); }); -}).call(this); - -(function() { - - }).call(this); ;/**! * The MIT License diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 3aafe3e16..aa136a9f5 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -1,5 +1,5 @@ -/*! angular-google-maps 0.0.0 2013-07-23 +/*! angular-google-maps 0.0.0 2013-07-24 * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.link=a(this.link,this),this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onIconChanged=a(this.onIconChanged,this),this.onCordsChanged=a(this.onCordsChanged,this);var d;d=this,this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onCordsChanged=function(){throw new Exception("Not Implemented!!")},d.prototype.onIconChanged=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){var e=this;return angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)?($log.error("marker: no valid coords attribute found"),void 0):this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),a.$watch("coords",function(b,c){return e.onCordsChanged(b,c,a.$id)},!0),a.$watch("icon",function(b,c){return e.onIconChanged(b,c,a.$id,a.coords)},!0),a.$on("$destroy",function(){return onDestroy(a.$id)})})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onIconChanged=a(this.onIconChanged,this),this.onCordsChanged=a(this.onCordsChanged,this);var e;d.__super__.constructor.call(this,b,c),e=this,b.info(this),this.marker={},this.mapCtrl=void 0}return c(d,b),d.prototype.onCordsChanged=function(a,b,c){return a!==b?a?(this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(a.latitude,a.longitude)),this.marker[c].setVisible(null!=a.latitude&&null!=a.longitude)):this.marker[c].setMap(void 0):void 0},d.prototype.onIconChanged=function(a,b,c,d){return a!==b?(this.marker[c].icon=a,this.marker[c].setMap(void 0),this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(d.latitude,d.longitude)),this.marker[c].setVisible(d.latitude&&null!=d.longitude)):void 0},d.prototype.onDestroy=function(a){return this.marker[a].setMap(null)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.marker[c.$id]=new google.maps.Marker(f),a.data("instance",this.marker[c.$id]),google.maps.event.addListener(this.marker[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d}(directives.api.IMarker)})}.call(this),function(){}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this),this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){return a.$on("$destroy",function(){return this.markers[a.$id].setMap(null)})},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onIconChanged=a(this.onIconChanged,this),this.onCordsChanged=a(this.onCordsChanged,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Markers",this.scope.markers="=markers",this.markers=[],this.mapCtrl=void 0,this.iconKey=void 0,this.coordsKey=void 0,b.info(this)}return c(d,b),d.prototype.getMarkerProperty=function(a,b){return a[b]},d.prototype.onCordsChanged=function(a,b,c){return a!==b?a?(this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(a.latitude,a.longitude)),this.marker[c].setVisible(null!=a.latitude&&null!=a.longitude)):this.marker[c].setMap(void 0):void 0},d.prototype.onIconChanged=function(a,b,c,d){return a!==b?(this.marker[c].icon=a,this.marker[c].setMap(void 0),this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(d.latitude,d.longitude)),this.marker[c].setVisible(d.latitude&&null!=d.longitude)):void 0},d.prototype.onDestroy=function(a){return this.marker[a].setMap(null)},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.markers)||void 0===a.markers,b&&$log.error(this.clsName+": no valid markers attribute found"),d.__super__.validateLinkedScope.apply(this,arguments).validateLinkedScope(a)||b},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.marker[c.$id]=new google.maps.Marker(f),a.data("instance",this.marker[c.$id]),google.maps.event.addListener(this.marker[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/example/example.html b/example/example.html index ad8e26772..dbe273709 100644 --- a/example/example.html +++ b/example/example.html @@ -48,6 +48,14 @@

angular-google-maps example

draggable="true" dragging="map.dragging" events="map.events"> + + + diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index e6c83d425..8998b4e48 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -12,6 +12,7 @@ constructor: ($log, $timeout) -> self = @ + @clsName = "IMarker" @$log = $log @$timeout = $timeout @restrict = 'ECMA' @@ -28,12 +29,12 @@ $log.info(self) - onCordsChanged:(newValue,oldValue,id) => + watchCoords:(scope) => throw new Exception("Not Implemented!!") - onIconChanged:(newValue,oldValue,id,coords) => + watchIcon:(scope) => throw new Exception("Not Implemented!!") - onDestroy:(id) => + watchDestroy:(scope) => throw new Exception("Not Implemented!!") linkInit:(element,mapCtrl,scope,animate)=> @@ -43,28 +44,23 @@ @getMarker = -> $element.data('instance') - link: (scope, element, attrs, mapCtrl) => - # Validate required properties - if (angular.isUndefined(scope.coords) or + validateLinkedScope:(scope)=> + ret = angular.isUndefined(scope.coords) or scope.coords == undefined or angular.isUndefined(scope.coords.latitude) or - angular.isUndefined(scope.coords.longitude)) - $log.error("marker: no valid coords attribute found") + angular.isUndefined(scope.coords.longitude) + if(ret) + $log.error(@clsName + ": no valid coords attribute found") + ret + link: (scope, element, attrs, mapCtrl) => + # Validate required properties + if (@validateLinkedScope(scope)) return # Wrap marker initialization inside a $timeout() call to make sure the map is created already @$timeout( => animate = angular.isDefined(attrs.animate) and @isFalse(attrs.animate) - @linkInit(element,mapCtrl,scope,animate,angular.isDefined(attrs.click)) - - scope.$watch('coords', (newValue, oldValue) => - @onCordsChanged(newValue,oldValue,scope.$id) - , true) - - scope.$watch('icon', (newValue, oldValue) => - @onIconChanged(newValue,oldValue,scope.$id,scope.coords) - , true) - - # remove marker on scope $destroy - scope.$on("$destroy", -> onDestroy(scope.$id)) + @watchCoords(scope) + @watchIcon(scope) + @watchDestroy(scope) ) \ No newline at end of file diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index 3408b5b90..d88f80f68 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -3,32 +3,38 @@ constructor: ($log, $timeout) -> super($log,$timeout) self = @ + @clsName = "Marker" $log.info(@) - @marker = {} + @markers = {} @mapCtrl = undefined - onCordsChanged:(newValue,oldValue,id) => - if (newValue != oldValue) - if (newValue) - @marker[id].setMap(@mapCtrl.getMap()) - @marker[id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - @marker[id].setVisible(newValue.latitude? and newValue.longitude?) - else - # Remove marker - @marker[id].setMap(undefined); + watchCoords:(scope) => + scope.$watch('coords', (newValue, oldValue) => + if (newValue != oldValue) + if (newValue) + @markers[scope.$id].setMap(@mapCtrl.getMap()) + @markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + @markers[scope.$id].setVisible(newValue.latitude? and newValue.longitude?) + else + # Remove marker + @markers[scope.$id].setMap(undefined) + , true) - onIconChanged:(newValue,oldValue,id,coords) => - if (newValue != oldValue) - @marker[id].icon = newValue - @marker[id].setMap(undefined) - @marker[id].setMap(@mapCtrl.getMap()) - @marker[id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) - @marker[id].setVisible(coords.latitude and coords.longitude?); + watchIcon:(scope) => + scope.$watch('icon', (newValue, oldValue) => + if (newValue != oldValue) + @markers[scope.$id].icon = newValue + @markers[scope.$id].setMap(undefined) + @markers[scope.$id].setMap(@mapCtrl.getMap()) + @markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) + @markers[scope.$id].setVisible(coords.latitude and coords.longitude?) + , true) - onDestroy:(id)=> - @marker[id].setMap(null) + watchDestroy:(scope)=> + scope.$on("$destroy", -> @markers[scope.$id].setMap(null)) linkInit:(element,mapCtrl,scope,animate,doClick) => + #linked scope is 1:1 per marker @mapCtrl = mapCtrl opts = angular.extend({}, @DEFAULTS, { position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), @@ -40,10 +46,11 @@ if !animate delete opts.animation; - @marker[scope.$id] = new google.maps.Marker(opts) - element.data('instance', @marker[scope.$id]) + #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the indec) + @markers[scope.$id] = new google.maps.Marker(opts) + element.data('instance', @markers[scope.$id]) - google.maps.event.addListener(@marker[scope.$id], 'click', -> + google.maps.event.addListener(@markers[scope.$id], 'click', -> if doClick and scope.click? scope.click() ) \ No newline at end of file diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index e69de29bb..6b97ce48c 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -0,0 +1,73 @@ +### +Markers will map icon and coords differently as there us not 1:1 Scope to marker +icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] +coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] + +property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself + +Coords and icons need to be rewatched within Markers linked scope +### +@module "directives.api", -> + class @Markers extends directives.api.IMarker + constructor: ($log, $timeout) -> + super($log,$timeout) + self = @ + @clsName = "Markers" + @scope.markers = '=markers' + @markers = [] + @mapCtrl = undefined + @iconKey = undefined + @coordsKey = undefined + $log.info(@) + + getMarkerProperty:(marker,property) -> + marker[property] + + onCordsChanged:(newValue,oldValue,id) => + if (newValue != oldValue) + if (newValue) + @marker[id].setMap(@mapCtrl.getMap()) + @marker[id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + @marker[id].setVisible(newValue.latitude? and newValue.longitude?) + else + # Remove marker + @marker[id].setMap(undefined); + + onIconChanged:(newValue,oldValue,id,coords) => + if (newValue != oldValue) + @marker[id].icon = newValue + @marker[id].setMap(undefined) + @marker[id].setMap(@mapCtrl.getMap()) + @marker[id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) + @marker[id].setVisible(coords.latitude and coords.longitude?); + + onDestroy:(id)=> + @marker[id].setMap(null) + + validateLinkedScope:(scope)-> + markerNotDefined = angular.isUndefined(scope.markers) or scope.markers == undefined + if(markerNotDefined) + $log.error(@clsName + ": no valid markers attribute found") + + super.validateLinkedScope(scope) or markerNotDefined + + + linkInit:(element,mapCtrl,scope,animate,doClick) => + @mapCtrl = mapCtrl + opts = angular.extend({}, @DEFAULTS, { + position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), + map: mapCtrl.getMap(), + icon: scope.icon, + visible: scope.coords.latitude? and scope.coords.longitude? + }) + + if !animate + delete opts.animation; + + @marker[scope.$id] = new google.maps.Marker(opts) + element.data('instance', @marker[scope.$id]) + + google.maps.event.addListener(@marker[scope.$id], 'click', -> + if doClick and scope.click? + scope.click() + ) \ No newline at end of file From 97c52aea485e4e653a853bbbd71586bd90e0e348 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 08:59:10 -0400 Subject: [PATCH 05/41] - moved marker options creation to i-marker - fixed destroy bug in marker.coffee --- dist/angular-google-maps.js | 160 ++++++++++++---------- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/i-marker.coffee | 36 +++-- src/coffee/directives/api/marker.coffee | 39 +++--- src/coffee/directives/api/markers.coffee | 53 +++---- 5 files changed, 154 insertions(+), 136 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 9dc96c0ee..00f8bc330 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -106,12 +106,12 @@ angular.module('google-maps', []);;(function() { }; function IMarker($log, $timeout) { - this.link = __bind(this.link, this); - this.validateLinkedScope = __bind(this.validateLinkedScope, this); this.linkInit = __bind(this.linkInit, this); this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); + this.link = __bind(this.link, this); + this.validateLinkedScope = __bind(this.validateLinkedScope, this); var self; self = this; this.clsName = "IMarker"; @@ -131,22 +131,6 @@ angular.module('google-maps', []);;(function() { $log.info(self); } - IMarker.prototype.watchCoords = function(scope) { - throw new Exception("Not Implemented!!"); - }; - - IMarker.prototype.watchIcon = function(scope) { - throw new Exception("Not Implemented!!"); - }; - - IMarker.prototype.watchDestroy = function(scope) { - throw new Exception("Not Implemented!!"); - }; - - IMarker.prototype.linkInit = function(element, mapCtrl, scope, animate) { - throw new Exception("Not Implemented!!"); - }; - IMarker.prototype.controller = function($scope, $element) { return this.getMarker = function() { return $element.data('instance'); @@ -177,6 +161,36 @@ angular.module('google-maps', []);;(function() { }); }; + IMarker.prototype.createMarkerOptions = function(map, coords, icon, animate) { + var opts; + opts = angular.extend({}, this.DEFAULTS, { + position: new google.maps.LatLng(coords.latitude, coords.longitude), + map: map.getMap(), + icon: icon, + visible: (coords.latitude != null) && (coords.longitude != null) + }); + if (!animate) { + delete opts.animation; + } + return opts; + }; + + IMarker.prototype.watchCoords = function(scope) { + throw new Exception("Not Implemented!!"); + }; + + IMarker.prototype.watchIcon = function(scope) { + throw new Exception("Not Implemented!!"); + }; + + IMarker.prototype.watchDestroy = function(scope) { + throw new Exception("Not Implemented!!"); + }; + + IMarker.prototype.linkInit = function(element, mapCtrl, scope, animate) { + throw new Exception("Not Implemented!!"); + }; + return IMarker; })(oo.BaseObject); @@ -194,10 +208,10 @@ angular.module('google-maps', []);;(function() { __extends(Marker, _super); function Marker($log, $timeout) { - this.linkInit = __bind(this.linkInit, this); this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); + this.linkInit = __bind(this.linkInit, this); var self; Marker.__super__.constructor.call(this, $log, $timeout); self = this; @@ -207,6 +221,19 @@ angular.module('google-maps', []);;(function() { this.mapCtrl = void 0; } + Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { + var opts; + this.mapCtrl = mapCtrl; + opts = this.createMarkerOptions(mapCtrl, scope.coords, scope.icon, animate); + this.markers[scope.$id] = new google.maps.Marker(opts); + element.data('instance', this.markers[scope.$id]); + return google.maps.event.addListener(this.markers[scope.$id], 'click', function() { + if (doClick && (scope.click != null)) { + return scope.click(); + } + }); + }; + Marker.prototype.watchCoords = function(scope) { var _this = this; return scope.$watch('coords', function(newValue, oldValue) { @@ -236,29 +263,9 @@ angular.module('google-maps', []);;(function() { }; Marker.prototype.watchDestroy = function(scope) { + var _this = this; return scope.$on("$destroy", function() { - return this.markers[scope.$id].setMap(null); - }); - }; - - Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { - var opts; - this.mapCtrl = mapCtrl; - opts = angular.extend({}, this.DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: (scope.coords.latitude != null) && (scope.coords.longitude != null) - }); - if (!animate) { - delete opts.animation; - } - this.markers[scope.$id] = new google.maps.Marker(opts); - element.data('instance', this.markers[scope.$id]); - return google.maps.event.addListener(this.markers[scope.$id], 'click', function() { - if (doClick && (scope.click != null)) { - return scope.click(); - } + return _this.markers[scope.$id].setMap(null); }); }; @@ -290,10 +297,10 @@ Coords and icons need to be rewatched within Markers linked scope __extends(Markers, _super); function Markers($log, $timeout) { + this.watchDestroy = __bind(this.watchDestroy, this); + this.watchIcon = __bind(this.watchIcon, this); + this.watchCoords = __bind(this.watchCoords, this); this.linkInit = __bind(this.linkInit, this); - this.onDestroy = __bind(this.onDestroy, this); - this.onIconChanged = __bind(this.onIconChanged, this); - this.onCordsChanged = __bind(this.onCordsChanged, this); var self; Markers.__super__.constructor.call(this, $log, $timeout); self = this; @@ -306,36 +313,6 @@ Coords and icons need to be rewatched within Markers linked scope $log.info(this); } - Markers.prototype.getMarkerProperty = function(marker, property) { - return marker[property]; - }; - - Markers.prototype.onCordsChanged = function(newValue, oldValue, id) { - if (newValue !== oldValue) { - if (newValue) { - this.marker[id].setMap(this.mapCtrl.getMap()); - this.marker[id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - return this.marker[id].setVisible((newValue.latitude != null) && (newValue.longitude != null)); - } else { - return this.marker[id].setMap(void 0); - } - } - }; - - Markers.prototype.onIconChanged = function(newValue, oldValue, id, coords) { - if (newValue !== oldValue) { - this.marker[id].icon = newValue; - this.marker[id].setMap(void 0); - this.marker[id].setMap(this.mapCtrl.getMap()); - this.marker[id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); - return this.marker[id].setVisible(coords.latitude && (coords.longitude != null)); - } - }; - - Markers.prototype.onDestroy = function(id) { - return this.marker[id].setMap(null); - }; - Markers.prototype.validateLinkedScope = function(scope) { var markerNotDefined; markerNotDefined = angular.isUndefined(scope.markers) || scope.markers === void 0; @@ -366,6 +343,41 @@ Coords and icons need to be rewatched within Markers linked scope }); }; + Markers.prototype.watchCoords = function(scope) { + var _this = this; + return scope.$watch('coords', function(newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); + _this.markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + return _this.markers[scope.$id].setVisible((newValue.latitude != null) && (newValue.longitude != null)); + } else { + return _this.markers[scope.$id].setMap(void 0); + } + } + }, true); + }; + + Markers.prototype.watchIcon = function(scope) { + var _this = this; + return scope.$watch('icon', function(newValue, oldValue) { + if (newValue !== oldValue) { + _this.markers[scope.$id].icon = newValue; + _this.markers[scope.$id].setMap(void 0); + _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); + _this.markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); + return _this.markers[scope.$id].setVisible(coords.latitude && (coords.longitude != null)); + } + }, true); + }; + + Markers.prototype.watchDestroy = function(scope) { + var _this = this; + return scope.$on("$destroy", function() { + return _this.markers[scope.$id].setMap(null); + }); + }; + return Markers; })(directives.api.IMarker); diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index aa136a9f5..6d797275d 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this),this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){return a.$on("$destroy",function(){return this.markers[a.$id].setMap(null)})},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onIconChanged=a(this.onIconChanged,this),this.onCordsChanged=a(this.onCordsChanged,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Markers",this.scope.markers="=markers",this.markers=[],this.mapCtrl=void 0,this.iconKey=void 0,this.coordsKey=void 0,b.info(this)}return c(d,b),d.prototype.getMarkerProperty=function(a,b){return a[b]},d.prototype.onCordsChanged=function(a,b,c){return a!==b?a?(this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(a.latitude,a.longitude)),this.marker[c].setVisible(null!=a.latitude&&null!=a.longitude)):this.marker[c].setMap(void 0):void 0},d.prototype.onIconChanged=function(a,b,c,d){return a!==b?(this.marker[c].icon=a,this.marker[c].setMap(void 0),this.marker[c].setMap(this.mapCtrl.getMap()),this.marker[c].setPosition(new google.maps.LatLng(d.latitude,d.longitude)),this.marker[c].setVisible(d.latitude&&null!=d.longitude)):void 0},d.prototype.onDestroy=function(a){return this.marker[a].setMap(null)},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.markers)||void 0===a.markers,b&&$log.error(this.clsName+": no valid markers attribute found"),d.__super__.validateLinkedScope.apply(this,arguments).validateLinkedScope(a)||b},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.marker[c.$id]=new google.maps.Marker(f),a.data("instance",this.marker[c.$id]),google.maps.event.addListener(this.marker[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.createMarkerOptions=function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null)})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Markers",this.scope.markers="=markers",this.markers=[],this.mapCtrl=void 0,this.iconKey=void 0,this.coordsKey=void 0,b.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.markers)||void 0===a.markers,b&&$log.error(this.clsName+": no valid markers attribute found"),d.__super__.validateLinkedScope.apply(this,arguments).validateLinkedScope(a)||b},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.marker[c.$id]=new google.maps.Marker(f),a.data("instance",this.marker[c.$id]),google.maps.event.addListener(this.marker[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null)})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index 8998b4e48..62ad064ca 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -29,17 +29,6 @@ $log.info(self) - watchCoords:(scope) => - throw new Exception("Not Implemented!!") - - watchIcon:(scope) => - throw new Exception("Not Implemented!!") - watchDestroy:(scope) => - throw new Exception("Not Implemented!!") - - linkInit:(element,mapCtrl,scope,animate)=> - throw new Exception("Not Implemented!!") - controller: ($scope, $element) -> @getMarker = -> $element.data('instance') @@ -52,6 +41,7 @@ if(ret) $log.error(@clsName + ": no valid coords attribute found") ret + link: (scope, element, attrs, mapCtrl) => # Validate required properties if (@validateLinkedScope(scope)) @@ -63,4 +53,26 @@ @watchCoords(scope) @watchIcon(scope) @watchDestroy(scope) - ) \ No newline at end of file + ) + + createMarkerOptions:(map,coords,icon,animate) -> + opts = angular.extend({}, @DEFAULTS, { + position: new google.maps.LatLng(coords.latitude, coords.longitude), + map: map.getMap(), + icon: icon, + visible: coords.latitude? and coords.longitude? + }) + if !animate + delete opts.animation; + opts + + watchCoords:(scope) => + throw new Exception("Not Implemented!!") + + watchIcon:(scope) => + throw new Exception("Not Implemented!!") + watchDestroy:(scope) => + throw new Exception("Not Implemented!!") + + linkInit:(element,mapCtrl,scope,animate)=> + throw new Exception("Not Implemented!!") \ No newline at end of file diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index d88f80f68..5a710512e 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -8,6 +8,21 @@ @markers = {} @mapCtrl = undefined + # if we have made it here all attributes are valid so we can initialize and glue things together + linkInit:(element,mapCtrl,scope,animate,doClick) => + #linked scope is 1:1 per marker + @mapCtrl = mapCtrl + opts = @createMarkerOptions(mapCtrl,scope.coords,scope.icon,animate) + + #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the indec) + @markers[scope.$id] = new google.maps.Marker(opts) + element.data('instance', @markers[scope.$id]) + + google.maps.event.addListener(@markers[scope.$id], 'click', -> + if doClick and scope.click? + scope.click() + ) + watchCoords:(scope) => scope.$watch('coords', (newValue, oldValue) => if (newValue != oldValue) @@ -31,26 +46,4 @@ , true) watchDestroy:(scope)=> - scope.$on("$destroy", -> @markers[scope.$id].setMap(null)) - - linkInit:(element,mapCtrl,scope,animate,doClick) => - #linked scope is 1:1 per marker - @mapCtrl = mapCtrl - opts = angular.extend({}, @DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: scope.coords.latitude? and scope.coords.longitude? - }) - - if !animate - delete opts.animation; - - #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the indec) - @markers[scope.$id] = new google.maps.Marker(opts) - element.data('instance', @markers[scope.$id]) - - google.maps.event.addListener(@markers[scope.$id], 'click', -> - if doClick and scope.click? - scope.click() - ) \ No newline at end of file + scope.$on("$destroy", => @markers[scope.$id].setMap(null)) diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index 6b97ce48c..08916b4e9 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -20,30 +20,6 @@ Coords and icons need to be rewatched within Markers linked scope @coordsKey = undefined $log.info(@) - getMarkerProperty:(marker,property) -> - marker[property] - - onCordsChanged:(newValue,oldValue,id) => - if (newValue != oldValue) - if (newValue) - @marker[id].setMap(@mapCtrl.getMap()) - @marker[id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - @marker[id].setVisible(newValue.latitude? and newValue.longitude?) - else - # Remove marker - @marker[id].setMap(undefined); - - onIconChanged:(newValue,oldValue,id,coords) => - if (newValue != oldValue) - @marker[id].icon = newValue - @marker[id].setMap(undefined) - @marker[id].setMap(@mapCtrl.getMap()) - @marker[id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) - @marker[id].setVisible(coords.latitude and coords.longitude?); - - onDestroy:(id)=> - @marker[id].setMap(null) - validateLinkedScope:(scope)-> markerNotDefined = angular.isUndefined(scope.markers) or scope.markers == undefined if(markerNotDefined) @@ -51,7 +27,7 @@ Coords and icons need to be rewatched within Markers linked scope super.validateLinkedScope(scope) or markerNotDefined - + # if we have made it here all attributes are valid so we can initialize and glue things together linkInit:(element,mapCtrl,scope,animate,doClick) => @mapCtrl = mapCtrl opts = angular.extend({}, @DEFAULTS, { @@ -70,4 +46,29 @@ Coords and icons need to be rewatched within Markers linked scope google.maps.event.addListener(@marker[scope.$id], 'click', -> if doClick and scope.click? scope.click() - ) \ No newline at end of file + ) + + watchCoords:(scope) => + scope.$watch('coords', (newValue, oldValue) => + if (newValue != oldValue) + if (newValue) + @markers[scope.$id].setMap(@mapCtrl.getMap()) + @markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + @markers[scope.$id].setVisible(newValue.latitude? and newValue.longitude?) + else + # Remove marker + @markers[scope.$id].setMap(undefined) + , true) + + watchIcon:(scope) => + scope.$watch('icon', (newValue, oldValue) => + if (newValue != oldValue) + @markers[scope.$id].icon = newValue + @markers[scope.$id].setMap(undefined) + @markers[scope.$id].setMap(@mapCtrl.getMap()) + @markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) + @markers[scope.$id].setVisible(coords.latitude and coords.longitude?) + , true) + + watchDestroy:(scope)=> + scope.$on("$destroy", => @markers[scope.$id].setMap(null)) From 46e834a2b5691961bbe4c95a9e7d347742ac44b6 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 10:22:02 -0400 Subject: [PATCH 06/41] - extracted some functionality from IMarker to MarkerUtil - hashing out Markers some more with MarkerModel, commented out as there is a bug currently --- dist/angular-google-maps.js | 144 +++------------ dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/i-marker.coffee | 13 +- src/coffee/directives/api/marker-util.coffee | 12 ++ src/coffee/directives/api/marker.coffee | 8 +- src/coffee/directives/api/markers.coffee | 173 ++++++++++++------- 6 files changed, 156 insertions(+), 196 deletions(-) create mode 100644 src/coffee/directives/api/marker-util.coffee diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 00f8bc330..90d3ed979 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -161,20 +161,6 @@ angular.module('google-maps', []);;(function() { }); }; - IMarker.prototype.createMarkerOptions = function(map, coords, icon, animate) { - var opts; - opts = angular.extend({}, this.DEFAULTS, { - position: new google.maps.LatLng(coords.latitude, coords.longitude), - map: map.getMap(), - icon: icon, - visible: (coords.latitude != null) && (coords.longitude != null) - }); - if (!animate) { - delete opts.animation; - } - return opts; - }; - IMarker.prototype.watchCoords = function(scope) { throw new Exception("Not Implemented!!"); }; @@ -198,6 +184,27 @@ angular.module('google-maps', []);;(function() { }).call(this); +(function() { + this.module("directives.api", function() { + return this.MarkerUtil = { + createMarkerOptions: function(map, coords, icon, animate) { + var opts; + opts = angular.extend({}, this.DEFAULTS, { + position: new google.maps.LatLng(coords.latitude, coords.longitude), + map: map.getMap(), + icon: icon, + visible: (coords.latitude != null) && (coords.longitude != null) + }); + if (!animate) { + delete opts.animation; + } + return opts; + } + }; + }); + +}).call(this); + (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -207,6 +214,8 @@ angular.module('google-maps', []);;(function() { return this.Marker = (function(_super) { __extends(Marker, _super); + Marker.include(directives.api.MarkerUtil); + function Marker($log, $timeout) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); @@ -265,7 +274,8 @@ angular.module('google-maps', []);;(function() { Marker.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { - return _this.markers[scope.$id].setMap(null); + _this.markers[scope.$id].setMap(null); + return delete _this.markers[scope.$id]; }); }; @@ -276,112 +286,8 @@ angular.module('google-maps', []);;(function() { }).call(this); - -/* -Markers will map icon and coords differently as there us not 1:1 Scope to marker -icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] -coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] - -property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself - -Coords and icons need to be rewatched within Markers linked scope -*/ - (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; }; - - this.module("directives.api", function() { - return this.Markers = (function(_super) { - __extends(Markers, _super); - - function Markers($log, $timeout) { - this.watchDestroy = __bind(this.watchDestroy, this); - this.watchIcon = __bind(this.watchIcon, this); - this.watchCoords = __bind(this.watchCoords, this); - this.linkInit = __bind(this.linkInit, this); - var self; - Markers.__super__.constructor.call(this, $log, $timeout); - self = this; - this.clsName = "Markers"; - this.scope.markers = '=markers'; - this.markers = []; - this.mapCtrl = void 0; - this.iconKey = void 0; - this.coordsKey = void 0; - $log.info(this); - } - Markers.prototype.validateLinkedScope = function(scope) { - var markerNotDefined; - markerNotDefined = angular.isUndefined(scope.markers) || scope.markers === void 0; - if (markerNotDefined) { - $log.error(this.clsName + ": no valid markers attribute found"); - } - return Markers.__super__.validateLinkedScope.apply(this, arguments).validateLinkedScope(scope) || markerNotDefined; - }; - - Markers.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { - var opts; - this.mapCtrl = mapCtrl; - opts = angular.extend({}, this.DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: (scope.coords.latitude != null) && (scope.coords.longitude != null) - }); - if (!animate) { - delete opts.animation; - } - this.marker[scope.$id] = new google.maps.Marker(opts); - element.data('instance', this.marker[scope.$id]); - return google.maps.event.addListener(this.marker[scope.$id], 'click', function() { - if (doClick && (scope.click != null)) { - return scope.click(); - } - }); - }; - - Markers.prototype.watchCoords = function(scope) { - var _this = this; - return scope.$watch('coords', function(newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); - _this.markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - return _this.markers[scope.$id].setVisible((newValue.latitude != null) && (newValue.longitude != null)); - } else { - return _this.markers[scope.$id].setMap(void 0); - } - } - }, true); - }; - - Markers.prototype.watchIcon = function(scope) { - var _this = this; - return scope.$watch('icon', function(newValue, oldValue) { - if (newValue !== oldValue) { - _this.markers[scope.$id].icon = newValue; - _this.markers[scope.$id].setMap(void 0); - _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); - _this.markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); - return _this.markers[scope.$id].setVisible(coords.latitude && (coords.longitude != null)); - } - }, true); - }; - - Markers.prototype.watchDestroy = function(scope) { - var _this = this; - return scope.$on("$destroy", function() { - return _this.markers[scope.$id].setMap(null); - }); - }; - - return Markers; - - })(directives.api.IMarker); - }); }).call(this); ;/**! diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 6d797275d..b32e6b241 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.createMarkerOptions=function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null)})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Markers",this.scope.markers="=markers",this.markers=[],this.mapCtrl=void 0,this.iconKey=void 0,this.coordsKey=void 0,b.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.markers)||void 0===a.markers,b&&$log.error(this.clsName+": no valid markers attribute found"),d.__super__.validateLinkedScope.apply(this,arguments).validateLinkedScope(a)||b},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(c.coords.latitude,c.coords.longitude),map:b.getMap(),icon:c.icon,visible:null!=c.coords.latitude&&null!=c.coords.longitude}),d||delete f.animation,this.marker[c.$id]=new google.maps.Marker(f),a.data("instance",this.marker[c.$id]),google.maps.event.addListener(this.marker[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null)})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api",function(){return this.MarkerUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.MarkerUtil),d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index 62ad064ca..444eaa070 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -54,18 +54,7 @@ @watchIcon(scope) @watchDestroy(scope) ) - - createMarkerOptions:(map,coords,icon,animate) -> - opts = angular.extend({}, @DEFAULTS, { - position: new google.maps.LatLng(coords.latitude, coords.longitude), - map: map.getMap(), - icon: icon, - visible: coords.latitude? and coords.longitude? - }) - if !animate - delete opts.animation; - opts - + watchCoords:(scope) => throw new Exception("Not Implemented!!") diff --git a/src/coffee/directives/api/marker-util.coffee b/src/coffee/directives/api/marker-util.coffee new file mode 100644 index 000000000..c57b45b67 --- /dev/null +++ b/src/coffee/directives/api/marker-util.coffee @@ -0,0 +1,12 @@ +@module "directives.api", -> + @MarkerUtil = + createMarkerOptions:(map,coords,icon,animate) -> + opts = angular.extend({}, @DEFAULTS, { + position: new google.maps.LatLng(coords.latitude, coords.longitude), + map: map.getMap(), + icon: icon, + visible: coords.latitude? and coords.longitude? + }) + if !animate + delete opts.animation; + opts diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index 5a710512e..88782201c 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -1,5 +1,7 @@ @module "directives.api", -> class @Marker extends directives.api.IMarker + @include directives.api.MarkerUtil + constructor: ($log, $timeout) -> super($log,$timeout) self = @ @@ -46,4 +48,8 @@ , true) watchDestroy:(scope)=> - scope.$on("$destroy", => @markers[scope.$id].setMap(null)) + scope.$on("$destroy", => + #remove from gMaps and then free resources + @markers[scope.$id].setMap(null) + delete @markers[scope.$id] + ) diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index 08916b4e9..9916e7a2e 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -1,74 +1,121 @@ -### -Markers will map icon and coords differently as there us not 1:1 Scope to marker -icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] -coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] +# ### +# Markers will map icon and coords differently as there us not 1:1 Scope to marker +# icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] +# coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] -property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself +# property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself -Coords and icons need to be rewatched within Markers linked scope -### -@module "directives.api", -> - class @Markers extends directives.api.IMarker - constructor: ($log, $timeout) -> - super($log,$timeout) - self = @ - @clsName = "Markers" - @scope.markers = '=markers' - @markers = [] - @mapCtrl = undefined - @iconKey = undefined - @coordsKey = undefined - $log.info(@) +# Coords and icons need to be rewatched within Markers linked scope +# ### +# @module "directives.api", -> +# class @Markers extends directives.api.IMarker +# constructor: ($log, $timeout) -> +# super($log,$timeout) +# self = @ +# @clsName = "Markers" +# @scope.markers = '=markers' +# @markers = {} +# @markersIndex = 0 +# @mapCtrl = undefined +# @$timeout = $timeout +# @$log = $log +# $log.info(@) - validateLinkedScope:(scope)-> - markerNotDefined = angular.isUndefined(scope.markers) or scope.markers == undefined - if(markerNotDefined) - $log.error(@clsName + ": no valid markers attribute found") +# validateLinkedScope:(scope)-> +# markerNotDefined = angular.isUndefined(scope.markers) or scope.markers == undefined +# if(markerNotDefined) +# $log.error(@clsName + ": no valid markers attribute found") - super.validateLinkedScope(scope) or markerNotDefined +# super.validateLinkedScope(scope) or markerNotDefined - # if we have made it here all attributes are valid so we can initialize and glue things together - linkInit:(element,mapCtrl,scope,animate,doClick) => - @mapCtrl = mapCtrl - opts = angular.extend({}, @DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: scope.coords.latitude? and scope.coords.longitude? - }) +# # if we have made it here all attributes are valid so we can initialize and glue things together +# linkInit:(element,mapCtrl,scope,animate,doClick) => +# @mapCtrl = mapCtrl +# @createMarkers(element,scope,animate,doClick) - if !animate - delete opts.animation; +# createMarkers:(element,scope,animate,doClick) => +# for model in scope.markers +# do(model) => +# @markers[@markersIndex] = +# new directives.api.models.MarkerModel(index,model,scope,@$timeout,@$log, (index) => +# delete @markers[index] +# ) - @marker[scope.$id] = new google.maps.Marker(opts) - element.data('instance', @marker[scope.$id]) +# @markersIndex++ +# element.data('instance', @markers) - google.maps.event.addListener(@marker[scope.$id], 'click', -> - if doClick and scope.click? - scope.click() - ) +# watchCoords:(scope) => +# scope.$watch('coords', (newValue, oldValue) => +# if (newValue != oldValue) +# model.coordsKey = newValue for model in @markers +# , true) + +# watchIcon:(scope) => +# scope.$watch('icon', (newValue, oldValue) => +# if (newValue != oldValue) +# model.iconKey = newValue for model in @markers +# , true) + +# watchDestroy:(scope)=> +# #need to figure out how to handle individual destroys +# #slap index to the external model so that when they pass external back +# #for destroy we have a lookup? +# #this will require another attribute for destroySingle(marker) +# scope.$on("$destroy", => +# model.destroy() for model in @markers +# ) + + +# @module "directives.api.models", -> +# class @MarkerModel extends oo.BasicObject +# @include directives.api.MarkerUtil +# constructor:(index,model,parentScope,$timeout,$log,notifyLocalDestroy)-> +# @index = index +# @iconKey = scope.icon +# @coordsKey = scope.coords +# @opts = createMarkerOptions(@mapCtrl,model[@coordsKey],model[@iconKey]) +# @gMarker = new google.maps.Marker(opts) +# google.maps.event.addListener(@gMarker, 'click', -> +# #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ +# if doClick and scope.click? +# scope.click() +# ) +# @myScope = parentScope.$new(false) +# @myScope.icon = model[@iconKey] +# @myScope.coords = model[@coordsKey] + +# @$timeout( => +# @watchCoords(@myScope) +# @watchIcon(@myScope) +# @watchDestroy(@myScope) +# ) +# destroy:() => +# @myScope.$destroy() - watchCoords:(scope) => - scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - if (newValue) - @markers[scope.$id].setMap(@mapCtrl.getMap()) - @markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - @markers[scope.$id].setVisible(newValue.latitude? and newValue.longitude?) - else - # Remove marker - @markers[scope.$id].setMap(undefined) - , true) +# watchCoords:(scope) => +# scope.$watch('coords', (newValue, oldValue) => +# if (newValue != oldValue) +# if (newValue) +# @gmap.setMap(@mapCtrl.getMap()) +# @gmap.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) +# @gmap.setVisible(newValue.latitude? and newValue.longitude?) +# else +# # Remove marker +# @gmap.setMap(undefined) +# , true) - watchIcon:(scope) => - scope.$watch('icon', (newValue, oldValue) => - if (newValue != oldValue) - @markers[scope.$id].icon = newValue - @markers[scope.$id].setMap(undefined) - @markers[scope.$id].setMap(@mapCtrl.getMap()) - @markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) - @markers[scope.$id].setVisible(coords.latitude and coords.longitude?) - , true) +# watchIcon:(scope) => +# scope.$watch('icon', (newValue, oldValue) => +# if (newValue != oldValue) +# @gmap.icon = newValue +# @gmap.setMap(undefined) +# @gmap.setMap(@mapCtrl.getMap()) +# @gmap.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) +# @gmap.setVisible(coords.latitude and coords.longitude?) +# , true) - watchDestroy:(scope)=> - scope.$on("$destroy", => @markers[scope.$id].setMap(null)) +# watchDestroy:(scope)=> +# scope.$on("$destroy", => +# @gmap.setMap(null) +# notifyLocalDestroy(@index) if notifyLocalDestroy? +# ) \ No newline at end of file From 41787c6cb35eba65aca87a7563d57a1cf8b439e3 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 10:35:59 -0400 Subject: [PATCH 07/41] markers is compiling \ runnable again --- Gruntfile.js | 2 + dist/angular-google-maps.js | 249 ++++++++++++++++-- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/marker.coffee | 2 +- src/coffee/directives/api/markers.coffee | 167 ++++-------- .../directives/api/models/marker-model.coffee | 53 ++++ .../gmap-util.coffee} | 4 +- 7 files changed, 342 insertions(+), 137 deletions(-) create mode 100644 src/coffee/directives/api/models/marker-model.coffee rename src/coffee/directives/api/{marker-util.coffee => utils/gmap-util.coffee} (86%) diff --git a/Gruntfile.js b/Gruntfile.js index 1a73cd49a..376428d0a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -40,6 +40,8 @@ module.exports = function(grunt) { ['src/coffee/*.coffee', 'src/coffee/oo/module.coffee', 'src/coffee/oo/base-object.coffee', + 'src/coffee/directives/api/utils/*.coffee', + 'src/coffee/directives/api/models/*.coffee', 'src/coffee/directives/api/*.coffee', 'src/coffee/directives/*.coffee'] // concat then compile into single file } diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 90d3ed979..3a74a09c2 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -88,6 +88,113 @@ angular.module('google-maps', []);;(function() { }).call(this); +(function() { + this.module("directives.api.utils", function() { + return this.GmapUtil = { + createMarkerOptions: function(map, coords, icon, animate) { + var opts; + opts = angular.extend({}, this.DEFAULTS, { + position: new google.maps.LatLng(coords.latitude, coords.longitude), + map: map.getMap(), + icon: icon, + visible: (coords.latitude != null) && (coords.longitude != null) + }); + if (!animate) { + delete opts.animation; + } + return opts; + } + }; + }); + +}).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; }; + + this.module("directives.api.models", function() { + return this.MarkerModel = (function(_super) { + __extends(MarkerModel, _super); + + MarkerModel.include(directives.api.utils.GmapUtil); + + function MarkerModel(index, model, parentScope, $timeout, $log, notifyLocalDestroy) { + this.watchDestroy = __bind(this.watchDestroy, this); + this.watchIcon = __bind(this.watchIcon, this); + this.watchCoords = __bind(this.watchCoords, this); + this.destroy = __bind(this.destroy, this); + var _this = this; + this.index = index; + this.iconKey = scope.icon; + this.coordsKey = scope.coords; + this.opts = createMarkerOptions(this.mapCtrl, model[this.coordsKey], model[this.iconKey]); + this.gMarker = new google.maps.Marker(opts); + google.maps.event.addListener(this.gMarker, 'click', function() { + if (doClick && (scope.click != null)) { + return scope.click(); + } + }); + this.myScope = parentScope.$new(false); + this.myScope.icon = model[this.iconKey]; + this.myScope.coords = model[this.coordsKey]; + this.$timeout(function() { + _this.watchCoords(_this.myScope); + _this.watchIcon(_this.myScope); + return _this.watchDestroy(_this.myScope); + }); + } + + MarkerModel.prototype.destroy = function() { + return this.myScope.$destroy(); + }; + + MarkerModel.prototype.watchCoords = function(scope) { + var _this = this; + return scope.$watch('coords', function(newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + _this.gmap.setMap(_this.mapCtrl.getMap()); + _this.gmap.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + return _this.gmap.setVisible((newValue.latitude != null) && (newValue.longitude != null)); + } else { + return _this.gmap.setMap(void 0); + } + } + }, true); + }; + + MarkerModel.prototype.watchIcon = function(scope) { + var _this = this; + return scope.$watch('icon', function(newValue, oldValue) { + if (newValue !== oldValue) { + _this.gmap.icon = newValue; + _this.gmap.setMap(void 0); + _this.gmap.setMap(_this.mapCtrl.getMap()); + _this.gmap.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); + return _this.gmap.setVisible(coords.latitude && (coords.longitude != null)); + } + }, true); + }; + + MarkerModel.prototype.watchDestroy = function(scope) { + var _this = this; + return scope.$on("$destroy", function() { + _this.gmap.setMap(null); + if (typeof notifyLocalDestroy !== "undefined" && notifyLocalDestroy !== null) { + return notifyLocalDestroy(_this.index); + } + }); + }; + + return MarkerModel; + + })(oo.BaseObject); + }); + +}).call(this); + (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -184,27 +291,6 @@ angular.module('google-maps', []);;(function() { }).call(this); -(function() { - this.module("directives.api", function() { - return this.MarkerUtil = { - createMarkerOptions: function(map, coords, icon, animate) { - var opts; - opts = angular.extend({}, this.DEFAULTS, { - position: new google.maps.LatLng(coords.latitude, coords.longitude), - map: map.getMap(), - icon: icon, - visible: (coords.latitude != null) && (coords.longitude != null) - }); - if (!animate) { - delete opts.animation; - } - return opts; - } - }; - }); - -}).call(this); - (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -214,7 +300,7 @@ angular.module('google-maps', []);;(function() { return this.Marker = (function(_super) { __extends(Marker, _super); - Marker.include(directives.api.MarkerUtil); + Marker.include(directives.api.utils.GmapUtil); function Marker($log, $timeout) { this.watchDestroy = __bind(this.watchDestroy, this); @@ -286,8 +372,127 @@ angular.module('google-maps', []);;(function() { }).call(this); + +/* +Markers will map icon and coords differently as there us not 1:1 Scope to marker +icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] +coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] + +property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself + +Coords and icons need to be rewatched within Markers linked scope +*/ + (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; }; + + this.module("directives.api", function() { + return this.Markers = (function(_super) { + __extends(Markers, _super); + + function Markers($log, $timeout) { + this.watchDestroy = __bind(this.watchDestroy, this); + this.watchIcon = __bind(this.watchIcon, this); + this.watchCoords = __bind(this.watchCoords, this); + this.createMarkers = __bind(this.createMarkers, this); + this.linkInit = __bind(this.linkInit, this); + var self; + Markers.__super__.constructor.call(this, $log, $timeout); + self = this; + this.clsName = "Markers"; + this.scope.markers = '=markers'; + this.markers = {}; + this.markersIndex = 0; + this.mapCtrl = void 0; + this.$timeout = $timeout; + this.$log = $log; + $log.info(this); + } + + Markers.prototype.validateLinkedScope = function(scope) { + var markerNotDefined; + markerNotDefined = angular.isUndefined(scope.markers) || scope.markers === void 0; + if (markerNotDefined) { + $log.error(this.clsName + ": no valid markers attribute found"); + } + return Markers.__super__.validateLinkedScope.apply(this, arguments).validateLinkedScope(scope) || markerNotDefined; + }; + + Markers.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { + this.mapCtrl = mapCtrl; + return this.createMarkers(element, scope, animate, doClick); + }; + + Markers.prototype.createMarkers = function(element, scope, animate, doClick) { + var model, _i, _len, _ref, _results, + _this = this; + _ref = scope.markers; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push((function(model) { + _this.markers[_this.markersIndex] = new directives.api.models.MarkerModel(index, model, scope, _this.$timeout, _this.$log, function(index) { + return delete _this.markers[index]; + }); + _this.markersIndex++; + return element.data('instance', _this.markers); + })(model)); + } + return _results; + }; + + Markers.prototype.watchCoords = function(scope) { + var _this = this; + return scope.$watch('coords', function(newValue, oldValue) { + var model, _i, _len, _ref, _results; + if (newValue !== oldValue) { + _ref = _this.markers; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push(model.coordsKey = newValue); + } + return _results; + } + }, true); + }; + + Markers.prototype.watchIcon = function(scope) { + var _this = this; + return scope.$watch('icon', function(newValue, oldValue) { + var model, _i, _len, _ref, _results; + if (newValue !== oldValue) { + _ref = _this.markers; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push(model.iconKey = newValue); + } + return _results; + } + }, true); + }; + Markers.prototype.watchDestroy = function(scope) { + var _this = this; + return scope.$on("$destroy", function() { + var model, _i, _len, _ref, _results; + _ref = _this.markers; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push(model.destroy()); + } + return _results; + }); + }; + + return Markers; + + })(directives.api.IMarker); + }); }).call(this); ;/**! diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index b32e6b241..b88bed19d 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api",function(){return this.MarkerUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.MarkerUtil),d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var e=this;this.index=b,this.iconKey=scope.icon,this.coordsKey=scope.coords,this.opts=createMarkerOptions(this.mapCtrl,c[this.coordsKey],c[this.iconKey]),this.gMarker=new google.maps.Marker(opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=scope.click?scope.click():void 0}),this.myScope=d.$new(!1),this.myScope.icon=c[this.iconKey],this.myScope.coords=c[this.coordsKey],this.$timeout(function(){return e.watchCoords(e.myScope),e.watchIcon(e.myScope),e.watchDestroy(e.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Markers",this.scope.markers="=markers",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log=b,b.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.markers)||void 0===a.markers,b&&$log.error(this.clsName+": no valid markers attribute found"),d.__super__.validateLinkedScope.apply(this,arguments).validateLinkedScope(a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.markers,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(index,c,b,h.$timeout,h.$log,function(a){return delete h.markers[a]}),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index 88782201c..28c883df1 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -1,6 +1,6 @@ @module "directives.api", -> class @Marker extends directives.api.IMarker - @include directives.api.MarkerUtil + @include directives.api.utils.GmapUtil constructor: ($log, $timeout) -> super($log,$timeout) diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index 9916e7a2e..b260abb5f 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -1,121 +1,66 @@ -# ### -# Markers will map icon and coords differently as there us not 1:1 Scope to marker -# icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] -# coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] +### +Markers will map icon and coords differently as there us not 1:1 Scope to marker +icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] +coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] -# property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself +property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself -# Coords and icons need to be rewatched within Markers linked scope -# ### -# @module "directives.api", -> -# class @Markers extends directives.api.IMarker -# constructor: ($log, $timeout) -> -# super($log,$timeout) -# self = @ -# @clsName = "Markers" -# @scope.markers = '=markers' -# @markers = {} -# @markersIndex = 0 -# @mapCtrl = undefined -# @$timeout = $timeout -# @$log = $log -# $log.info(@) +Coords and icons need to be rewatched within Markers linked scope +### +@module "directives.api", -> + class @Markers extends directives.api.IMarker + constructor: ($log, $timeout) -> + super($log,$timeout) + self = @ + @clsName = "Markers" + @scope.markers = '=markers' + @markers = {} + @markersIndex = 0 + @mapCtrl = undefined + @$timeout = $timeout + @$log = $log + $log.info(@) -# validateLinkedScope:(scope)-> -# markerNotDefined = angular.isUndefined(scope.markers) or scope.markers == undefined -# if(markerNotDefined) -# $log.error(@clsName + ": no valid markers attribute found") + validateLinkedScope:(scope)-> + markerNotDefined = angular.isUndefined(scope.markers) or scope.markers == undefined + if(markerNotDefined) + $log.error(@clsName + ": no valid markers attribute found") -# super.validateLinkedScope(scope) or markerNotDefined + super.validateLinkedScope(scope) or markerNotDefined -# # if we have made it here all attributes are valid so we can initialize and glue things together -# linkInit:(element,mapCtrl,scope,animate,doClick) => -# @mapCtrl = mapCtrl -# @createMarkers(element,scope,animate,doClick) + # if we have made it here all attributes are valid so we can initialize and glue things together + linkInit:(element,mapCtrl,scope,animate,doClick) => + @mapCtrl = mapCtrl + @createMarkers(element,scope,animate,doClick) -# createMarkers:(element,scope,animate,doClick) => -# for model in scope.markers -# do(model) => -# @markers[@markersIndex] = -# new directives.api.models.MarkerModel(index,model,scope,@$timeout,@$log, (index) => -# delete @markers[index] -# ) + createMarkers:(element,scope,animate,doClick) => + for model in scope.markers + do(model) => + @markers[@markersIndex] = + new directives.api.models.MarkerModel(index,model,scope,@$timeout,@$log, (index) => + delete @markers[index] + ) -# @markersIndex++ -# element.data('instance', @markers) + @markersIndex++ + element.data('instance', @markers) -# watchCoords:(scope) => -# scope.$watch('coords', (newValue, oldValue) => -# if (newValue != oldValue) -# model.coordsKey = newValue for model in @markers -# , true) + watchCoords:(scope) => + scope.$watch('coords', (newValue, oldValue) => + if (newValue != oldValue) + model.coordsKey = newValue for model in @markers + , true) -# watchIcon:(scope) => -# scope.$watch('icon', (newValue, oldValue) => -# if (newValue != oldValue) -# model.iconKey = newValue for model in @markers -# , true) + watchIcon:(scope) => + scope.$watch('icon', (newValue, oldValue) => + if (newValue != oldValue) + model.iconKey = newValue for model in @markers + , true) -# watchDestroy:(scope)=> -# #need to figure out how to handle individual destroys -# #slap index to the external model so that when they pass external back -# #for destroy we have a lookup? -# #this will require another attribute for destroySingle(marker) -# scope.$on("$destroy", => -# model.destroy() for model in @markers -# ) - - -# @module "directives.api.models", -> -# class @MarkerModel extends oo.BasicObject -# @include directives.api.MarkerUtil -# constructor:(index,model,parentScope,$timeout,$log,notifyLocalDestroy)-> -# @index = index -# @iconKey = scope.icon -# @coordsKey = scope.coords -# @opts = createMarkerOptions(@mapCtrl,model[@coordsKey],model[@iconKey]) -# @gMarker = new google.maps.Marker(opts) -# google.maps.event.addListener(@gMarker, 'click', -> -# #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ -# if doClick and scope.click? -# scope.click() -# ) -# @myScope = parentScope.$new(false) -# @myScope.icon = model[@iconKey] -# @myScope.coords = model[@coordsKey] - -# @$timeout( => -# @watchCoords(@myScope) -# @watchIcon(@myScope) -# @watchDestroy(@myScope) -# ) -# destroy:() => -# @myScope.$destroy() - -# watchCoords:(scope) => -# scope.$watch('coords', (newValue, oldValue) => -# if (newValue != oldValue) -# if (newValue) -# @gmap.setMap(@mapCtrl.getMap()) -# @gmap.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) -# @gmap.setVisible(newValue.latitude? and newValue.longitude?) -# else -# # Remove marker -# @gmap.setMap(undefined) -# , true) - -# watchIcon:(scope) => -# scope.$watch('icon', (newValue, oldValue) => -# if (newValue != oldValue) -# @gmap.icon = newValue -# @gmap.setMap(undefined) -# @gmap.setMap(@mapCtrl.getMap()) -# @gmap.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) -# @gmap.setVisible(coords.latitude and coords.longitude?) -# , true) - -# watchDestroy:(scope)=> -# scope.$on("$destroy", => -# @gmap.setMap(null) -# notifyLocalDestroy(@index) if notifyLocalDestroy? -# ) \ No newline at end of file + watchDestroy:(scope)=> + #need to figure out how to handle individual destroys + #slap index to the external model so that when they pass external back + #for destroy we have a lookup? + #this will require another attribute for destroySingle(marker) + scope.$on("$destroy", => + model.destroy() for model in @markers + ) \ No newline at end of file diff --git a/src/coffee/directives/api/models/marker-model.coffee b/src/coffee/directives/api/models/marker-model.coffee new file mode 100644 index 000000000..f415584e8 --- /dev/null +++ b/src/coffee/directives/api/models/marker-model.coffee @@ -0,0 +1,53 @@ +@module "directives.api.models", -> + class @MarkerModel extends oo.BaseObject + @include directives.api.utils.GmapUtil + constructor:(index,model,parentScope,$timeout,$log,notifyLocalDestroy)-> + @index = index + @iconKey = scope.icon + @coordsKey = scope.coords + @opts = createMarkerOptions(@mapCtrl,model[@coordsKey],model[@iconKey]) + @gMarker = new google.maps.Marker(opts) + google.maps.event.addListener(@gMarker, 'click', -> + #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ + if doClick and scope.click? + scope.click() + ) + @myScope = parentScope.$new(false) + @myScope.icon = model[@iconKey] + @myScope.coords = model[@coordsKey] + + @$timeout( => + @watchCoords(@myScope) + @watchIcon(@myScope) + @watchDestroy(@myScope) + ) + destroy:() => + @myScope.$destroy() + + watchCoords:(scope) => + scope.$watch('coords', (newValue, oldValue) => + if (newValue != oldValue) + if (newValue) + @gmap.setMap(@mapCtrl.getMap()) + @gmap.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + @gmap.setVisible(newValue.latitude? and newValue.longitude?) + else + # Remove marker + @gmap.setMap(undefined) + , true) + + watchIcon:(scope) => + scope.$watch('icon', (newValue, oldValue) => + if (newValue != oldValue) + @gmap.icon = newValue + @gmap.setMap(undefined) + @gmap.setMap(@mapCtrl.getMap()) + @gmap.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) + @gmap.setVisible(coords.latitude and coords.longitude?) + , true) + + watchDestroy:(scope)=> + scope.$on("$destroy", => + @gmap.setMap(null) + notifyLocalDestroy(@index) if notifyLocalDestroy? + ) \ No newline at end of file diff --git a/src/coffee/directives/api/marker-util.coffee b/src/coffee/directives/api/utils/gmap-util.coffee similarity index 86% rename from src/coffee/directives/api/marker-util.coffee rename to src/coffee/directives/api/utils/gmap-util.coffee index c57b45b67..7e61404d8 100644 --- a/src/coffee/directives/api/marker-util.coffee +++ b/src/coffee/directives/api/utils/gmap-util.coffee @@ -1,5 +1,5 @@ -@module "directives.api", -> - @MarkerUtil = +@module "directives.api.utils", -> + @GmapUtil = createMarkerOptions:(map,coords,icon,animate) -> opts = angular.extend({}, @DEFAULTS, { position: new google.maps.LatLng(coords.latitude, coords.longitude), From 72f75faeef90f9661b10a916aa89077bc1efecf6 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 11:58:36 -0400 Subject: [PATCH 08/41] Markers directive functioning without InfoWindow!! --- Gruntfile.js | 6 +- dist/angular-google-maps.js | 94 +++++++++--- dist/angular-google-maps.min.js | 2 +- example/example.html | 12 +- src/coffee/directives/api/i-marker.coffee | 11 +- src/coffee/directives/api/marker.coffee | 8 +- src/coffee/directives/api/markers.coffee | 20 +-- .../directives/api/models/marker-model.coffee | 24 +-- src/js/directives/marker copy.js | 142 ------------------ src/js/directives/marker.js | 2 +- src/js/directives/markers.js | 42 ++++++ 11 files changed, 158 insertions(+), 205 deletions(-) delete mode 100644 src/js/directives/marker copy.js create mode 100644 src/js/directives/markers.js diff --git a/Gruntfile.js b/Gruntfile.js index 376428d0a..d8f04a912 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -57,6 +57,7 @@ module.exports = function(grunt) { 'tmp/output_coffee.js', 'src/js/directives/map.js', 'src/js/directives/marker.js', + 'src/js/directives/markers.js', 'src/js/directives/polyline.js', 'src/js/directives/window.js'], dest: 'tmp/output.js' @@ -66,6 +67,7 @@ module.exports = function(grunt) { 'tmp/output_coffee.js', 'src/js/directives/map.js', 'src/js/directives/marker.js', + 'src/js/directives/markers.js', 'src/js/directives/polyline.js', 'src/js/directives/window.js'], dest: 'example/<%= pkg.name %>.js' @@ -104,8 +106,8 @@ module.exports = function(grunt) { watch: { all: { options: { livereload: true }, - files: ['src/js/**/*.js'], - tasks: ['clean:example', 'concat:example'], + files: ['src/js/**/*.js','src/coffee/**/*.coffee','src/coffee/*.coffee'], + tasks: ['clean:example','coffee','concat:example'], }, }, diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 3a74a09c2..4a56dcbf2 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -127,18 +127,18 @@ angular.module('google-maps', []);;(function() { this.destroy = __bind(this.destroy, this); var _this = this; this.index = index; - this.iconKey = scope.icon; - this.coordsKey = scope.coords; - this.opts = createMarkerOptions(this.mapCtrl, model[this.coordsKey], model[this.iconKey]); + this.iconKey = parentScope.icon; + this.coordsKey = parentScope.coords; + this.myScope = parentScope.$new(false); + this.myScope.icon = this.iconKey === 'self' ? model : model[this.iconKey]; + this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; + this.opts = this.createMarkerOptions(this.mapCtrl, this.myScope.coords, this.myScope.icon); this.gMarker = new google.maps.Marker(opts); google.maps.event.addListener(this.gMarker, 'click', function() { - if (doClick && (scope.click != null)) { - return scope.click(); + if (doClick && (this.myScope.click != null)) { + return this.myScope.click(); } }); - this.myScope = parentScope.$new(false); - this.myScope.icon = model[this.iconKey]; - this.myScope.coords = model[this.coordsKey]; this.$timeout(function() { _this.watchCoords(_this.myScope); _this.watchIcon(_this.myScope); @@ -228,14 +228,13 @@ angular.module('google-maps', []);;(function() { this.require = '^googleMap'; this.priority = -1; this.transclude = true; - this.template = ''; this.replace = true; this.scope = { coords: '=coords', icon: '=icon', click: '&click' }; - $log.info(self); + this.$log.info(self); } IMarker.prototype.controller = function($scope, $element) { @@ -246,9 +245,9 @@ angular.module('google-maps', []);;(function() { IMarker.prototype.validateLinkedScope = function(scope) { var ret; - ret = angular.isUndefined(scope.coords) || scope.coords === void 0 || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude); + ret = angular.isUndefined(scope.coords) || scope.coords === void 0; if (ret) { - $log.error(this.clsName + ": no valid coords attribute found"); + this.$log.error(this.clsName + ": no valid coords attribute found"); } return ret; }; @@ -307,15 +306,21 @@ angular.module('google-maps', []);;(function() { this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); this.linkInit = __bind(this.linkInit, this); + this.validateLinkedScope = __bind(this.validateLinkedScope, this); var self; Marker.__super__.constructor.call(this, $log, $timeout); self = this; + this.template = ''; this.clsName = "Marker"; $log.info(this); this.markers = {}; this.mapCtrl = void 0; } + Marker.prototype.validateLinkedScope = function(scope) { + return Marker.__super__.validateLinkedScope.call(this, scope) || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude); + }; + Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { var opts; this.mapCtrl = mapCtrl; @@ -398,26 +403,27 @@ Coords and icons need to be rewatched within Markers linked scope this.watchCoords = __bind(this.watchCoords, this); this.createMarkers = __bind(this.createMarkers, this); this.linkInit = __bind(this.linkInit, this); + this.validateLinkedScope = __bind(this.validateLinkedScope, this); var self; Markers.__super__.constructor.call(this, $log, $timeout); self = this; + this.template = ''; this.clsName = "Markers"; - this.scope.markers = '=markers'; + this.scope.models = '=models'; this.markers = {}; this.markersIndex = 0; this.mapCtrl = void 0; this.$timeout = $timeout; - this.$log = $log; - $log.info(this); + this.$log.info(this); } Markers.prototype.validateLinkedScope = function(scope) { - var markerNotDefined; - markerNotDefined = angular.isUndefined(scope.markers) || scope.markers === void 0; - if (markerNotDefined) { - $log.error(this.clsName + ": no valid markers attribute found"); + var modelsNotDefined; + modelsNotDefined = angular.isUndefined(scope.models) || scope.models === void 0; + if (modelsNotDefined) { + this.$log.error(this.clsName + ": no valid models attribute found"); } - return Markers.__super__.validateLinkedScope.apply(this, arguments).validateLinkedScope(scope) || markerNotDefined; + return Markers.__super__.validateLinkedScope.call(this, scope) || modelsNotDefined; }; Markers.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { @@ -428,12 +434,12 @@ Coords and icons need to be rewatched within Markers linked scope Markers.prototype.createMarkers = function(element, scope, animate, doClick) { var model, _i, _len, _ref, _results, _this = this; - _ref = scope.markers; + _ref = scope.models; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { model = _ref[_i]; _results.push((function(model) { - _this.markers[_this.markersIndex] = new directives.api.models.MarkerModel(index, model, scope, _this.$timeout, _this.$log, function(index) { + _this.markers[_this.markersIndex] = new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.$timeout, _this.$log, function(index) { return delete _this.markers[index]; }); _this.markersIndex++; @@ -806,7 +812,7 @@ angular.module('google-maps') * angular-google-maps * https://github.com/nlaplante/angular-google-maps * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + * @authors Nicolas Laplante, Nicholas McCready https://plus.google.com/108189012221374960701 */ /** @@ -822,6 +828,48 @@ angular.module('google-maps') angular.module('google-maps').directive('marker', ['$log', '$timeout', function($log,$timeout){ return new directives.api.Marker($log,$timeout);}]); +;/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante, Nicholas McCready https://plus.google.com/108189012221374960701 + */ + +/** + * Map marker directive + * + * This directive is used to create a marker on an existing map. + * This directive creates a new scope. + * + * {attribute coords required} object containing latitude and longitude properties + * {attribute icon optional} string url to image used for marker icon + * {attribute animate optional} if set to false, the marker won't be animated (on by default) + */ + +angular.module('google-maps').directive('markers', ['$log', '$timeout', function($log,$timeout){ + return new directives.api.Markers($log,$timeout);}]); ;/**! * The MIT License * diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index b88bed19d..ff5e33f6c 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var e=this;this.index=b,this.iconKey=scope.icon,this.coordsKey=scope.coords,this.opts=createMarkerOptions(this.mapCtrl,c[this.coordsKey],c[this.iconKey]),this.gMarker=new google.maps.Marker(opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=scope.click?scope.click():void 0}),this.myScope=d.$new(!1),this.myScope.icon=c[this.iconKey],this.myScope.coords=c[this.coordsKey],this.$timeout(function(){return e.watchCoords(e.myScope),e.watchIcon(e.myScope),e.watchDestroy(e.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='',this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},b.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude),b&&$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.clsName="Markers",this.scope.markers="=markers",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log=b,b.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.markers)||void 0===a.markers,b&&$log.error(this.clsName+": no valid markers attribute found"),d.__super__.validateLinkedScope.apply(this,arguments).validateLinkedScope(a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.markers,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(index,c,b,h.$timeout,h.$log,function(a){return delete h.markers[a]}),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var e=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon),this.gMarker=new google.maps.Marker(opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),this.$timeout(function(){return e.watchCoords(e.myScope),e.watchIcon(e.myScope),e.watchDestroy(e.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},this.$log.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.$timeout,h.$log,function(a){return delete h.markers[a]}),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/example/example.html b/example/example.html index dbe273709..a1cd79be4 100644 --- a/example/example.html +++ b/example/example.html @@ -49,20 +49,20 @@

angular-google-maps example

dragging="map.dragging" events="map.events"> - +
--> + - + diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index 444eaa070..735d05006 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -19,7 +19,6 @@ @require = '^googleMap' @priority = -1 @transclude = true - @template = '' @replace = true @scope = { coords: '=coords', @@ -27,7 +26,7 @@ click: '&click' } - $log.info(self) + @$log.info(self) controller: ($scope, $element) -> @getMarker = -> @@ -35,11 +34,9 @@ validateLinkedScope:(scope)=> ret = angular.isUndefined(scope.coords) or - scope.coords == undefined or - angular.isUndefined(scope.coords.latitude) or - angular.isUndefined(scope.coords.longitude) + scope.coords == undefined if(ret) - $log.error(@clsName + ": no valid coords attribute found") + @$log.error(@clsName + ": no valid coords attribute found") ret link: (scope, element, attrs, mapCtrl) => @@ -54,7 +51,7 @@ @watchIcon(scope) @watchDestroy(scope) ) - + watchCoords:(scope) => throw new Exception("Not Implemented!!") diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index 28c883df1..e4cc5a415 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -1,15 +1,21 @@ @module "directives.api", -> class @Marker extends directives.api.IMarker @include directives.api.utils.GmapUtil - + constructor: ($log, $timeout) -> super($log,$timeout) self = @ + @template = '' @clsName = "Marker" $log.info(@) @markers = {} @mapCtrl = undefined + + + validateLinkedScope:(scope)=> + super(scope) or angular.isUndefined(scope.coords.latitude) or angular.isUndefined(scope.coords.longitude) + # if we have made it here all attributes are valid so we can initialize and glue things together linkInit:(element,mapCtrl,scope,animate,doClick) => #linked scope is 1:1 per marker diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index b260abb5f..58b1524cd 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -12,21 +12,21 @@ Coords and icons need to be rewatched within Markers linked scope constructor: ($log, $timeout) -> super($log,$timeout) self = @ + @template = '' @clsName = "Markers" - @scope.markers = '=markers' + @scope.models = '=models' @markers = {} @markersIndex = 0 @mapCtrl = undefined @$timeout = $timeout - @$log = $log - $log.info(@) + @$log.info(@) - validateLinkedScope:(scope)-> - markerNotDefined = angular.isUndefined(scope.markers) or scope.markers == undefined - if(markerNotDefined) - $log.error(@clsName + ": no valid markers attribute found") + validateLinkedScope:(scope)=> + modelsNotDefined = angular.isUndefined(scope.models) or scope.models == undefined + if(modelsNotDefined) + @$log.error(@clsName + ": no valid models attribute found") - super.validateLinkedScope(scope) or markerNotDefined + super(scope) or modelsNotDefined # if we have made it here all attributes are valid so we can initialize and glue things together linkInit:(element,mapCtrl,scope,animate,doClick) => @@ -34,10 +34,10 @@ Coords and icons need to be rewatched within Markers linked scope @createMarkers(element,scope,animate,doClick) createMarkers:(element,scope,animate,doClick) => - for model in scope.markers + for model in scope.models do(model) => @markers[@markersIndex] = - new directives.api.models.MarkerModel(index,model,scope,@$timeout,@$log, (index) => + new directives.api.models.MarkerModel(@markersIndex,model,scope,@mapCtrl,@$timeout,@$log, (index) => delete @markers[index] ) diff --git a/src/coffee/directives/api/models/marker-model.coffee b/src/coffee/directives/api/models/marker-model.coffee index f415584e8..f99977d19 100644 --- a/src/coffee/directives/api/models/marker-model.coffee +++ b/src/coffee/directives/api/models/marker-model.coffee @@ -1,22 +1,22 @@ @module "directives.api.models", -> class @MarkerModel extends oo.BaseObject @include directives.api.utils.GmapUtil - constructor:(index,model,parentScope,$timeout,$log,notifyLocalDestroy)-> + constructor:(index,model,parentScope,mapCtrl,$timeout,$log,notifyLocalDestroy)-> @index = index - @iconKey = scope.icon - @coordsKey = scope.coords - @opts = createMarkerOptions(@mapCtrl,model[@coordsKey],model[@iconKey]) - @gMarker = new google.maps.Marker(opts) + @iconKey = parentScope.icon + @coordsKey = parentScope.coords + @myScope = parentScope.$new(false) + @myScope.icon = if @iconKey == 'self' then model else model[@iconKey] + @myScope.coords = if @coordsKey == 'self' then model else model[@coordsKey] + @mapCtrl = mapCtrl + @opts = @createMarkerOptions(@mapCtrl,@myScope.coords,@myScope.icon) + @gMarker = new google.maps.Marker(@opts) google.maps.event.addListener(@gMarker, 'click', -> #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ - if doClick and scope.click? - scope.click() + if doClick and @myScope.click? + @myScope.click() ) - @myScope = parentScope.$new(false) - @myScope.icon = model[@iconKey] - @myScope.coords = model[@coordsKey] - - @$timeout( => + $timeout( => @watchCoords(@myScope) @watchIcon(@myScope) @watchDestroy(@myScope) diff --git a/src/js/directives/marker copy.js b/src/js/directives/marker copy.js deleted file mode 100644 index 825ac42b9..000000000 --- a/src/js/directives/marker copy.js +++ /dev/null @@ -1,142 +0,0 @@ -/**! - * The MIT License - * - * Copyright (c) 2010-2012 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 - * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 - */ - -/** - * Map marker directive - * - * This directive is used to create a marker on an existing map. - * This directive creates a new scope. - * - * {attribute coords required} object containing latitude and longitude properties - * {attribute icon optional} string url to image used for marker icon - * {attribute animate optional} if set to false, the marker won't be animated (on by default) - */ - -angular.module('google-maps') - .directive('marker', ['$log', '$timeout', function ($log, $timeout) { - - "use strict"; - - var DEFAULTS = { - // Animation is enabled by default - animation: google.maps.Animation.DROP - }; - - /** - * Check if a value is literally false - * @param value the value to test - * @returns {boolean} true if value is literally false, false otherwise - */ - function isFalse(value) { - return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value ) !== -1; - } - - return { - restrict: 'ECMA', - require: '^googleMap', - priority: -1, - transclude: true, - template: '', - replace: true, - scope: { - coords: '=coords', - icon: '=icon', - click: '&click' - }, - controller: function ($scope, $element) { - this.getMarker = function () { - return $element.data('instance'); - }; - }, - link: function (scope, element, attrs, mapCtrl) { - - // Validate required properties - if (angular.isUndefined(scope.coords) || - scope.coords === null || - angular.isUndefined(scope.coords.latitude) || - angular.isUndefined(scope.coords.longitude)) { - - $log.error("marker: no valid coords attribute found"); - return; - } - - // Wrap marker initialization inside a $timeout() call to make sure the map is created already - $timeout(function () { - var opts = angular.extend({}, DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: scope.coords.latitude !== null && scope.coords.longitude !== null - }); - - // Disable animations - if (angular.isDefined(attrs.animate) && isFalse(attrs.animate)) { - delete opts.animation; - } - - var marker = new google.maps.Marker(opts); - element.data('instance', marker); - - google.maps.event.addListener(marker, 'click', function () { - if (angular.isDefined(attrs.click) && scope.click !== null) - scope.click(); - }); - - scope.$watch('coords', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - marker.setVisible(newValue.latitude !== null && newValue.longitude !== null); - } - else { - // Remove marker - marker.setMap(null); - } - } - }, true); - - scope.$watch('icon', function (newValue, oldValue) { - if (newValue !== oldValue) { - marker.icon = newValue; - marker.setMap(null); - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); - marker.setVisible(scope.coords.latitude !== null && scope.coords.longitude !== null); - } - }, true); - - // remove marker on scope $destroy - scope.$on("$destroy", function () { - marker.setMap(null); - }); - }); - } - }; - }]); diff --git a/src/js/directives/marker.js b/src/js/directives/marker.js index 35b82eab5..35204cef3 100644 --- a/src/js/directives/marker.js +++ b/src/js/directives/marker.js @@ -24,7 +24,7 @@ * angular-google-maps * https://github.com/nlaplante/angular-google-maps * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + * @authors Nicolas Laplante, Nicholas McCready https://plus.google.com/108189012221374960701 */ /** diff --git a/src/js/directives/markers.js b/src/js/directives/markers.js new file mode 100644 index 000000000..c1ccdaf3e --- /dev/null +++ b/src/js/directives/markers.js @@ -0,0 +1,42 @@ +/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante, Nicholas McCready https://plus.google.com/108189012221374960701 + */ + +/** + * Map marker directive + * + * This directive is used to create a marker on an existing map. + * This directive creates a new scope. + * + * {attribute coords required} object containing latitude and longitude properties + * {attribute icon optional} string url to image used for marker icon + * {attribute animate optional} if set to false, the marker won't be animated (on by default) + */ + +angular.module('google-maps').directive('markers', ['$log', '$timeout', function($log,$timeout){ + return new directives.api.Markers($log,$timeout);}]); From f500e79b9ef43b0319fcf1e4894f3c03cf2075b7 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 13:11:15 -0400 Subject: [PATCH 09/41] fixing comments, and setting default markers example back to Marker --- dist/angular-google-maps.js | 24 +++++++++++++----------- dist/angular-google-maps.min.js | 2 +- example/example.html | 13 +++++++------ src/coffee/directives/api/marker.coffee | 2 +- src/coffee/directives/api/markers.coffee | 12 +++++++----- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 4a56dcbf2..3747d6a98 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -120,7 +120,7 @@ angular.module('google-maps', []);;(function() { MarkerModel.include(directives.api.utils.GmapUtil); - function MarkerModel(index, model, parentScope, $timeout, $log, notifyLocalDestroy) { + function MarkerModel(index, model, parentScope, mapCtrl, $timeout, $log, notifyLocalDestroy) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); @@ -132,14 +132,15 @@ angular.module('google-maps', []);;(function() { this.myScope = parentScope.$new(false); this.myScope.icon = this.iconKey === 'self' ? model : model[this.iconKey]; this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; + this.mapCtrl = mapCtrl; this.opts = this.createMarkerOptions(this.mapCtrl, this.myScope.coords, this.myScope.icon); - this.gMarker = new google.maps.Marker(opts); + this.gMarker = new google.maps.Marker(this.opts); google.maps.event.addListener(this.gMarker, 'click', function() { if (doClick && (this.myScope.click != null)) { return this.myScope.click(); } }); - this.$timeout(function() { + $timeout(function() { _this.watchCoords(_this.myScope); _this.watchIcon(_this.myScope); return _this.watchDestroy(_this.myScope); @@ -379,13 +380,14 @@ angular.module('google-maps', []);;(function() { /* -Markers will map icon and coords differently as there us not 1:1 Scope to marker -icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] -coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] - -property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself - -Coords and icons need to be rewatched within Markers linked scope +Markers will map icon and coords differently than directibes.api.Marker. This is because Scope and the model marker are +not 1:1 in this setting. + + - icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] + - coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] + + - watches from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself + - actual changes to a model are tracked inside directives.api.model.MarkerModel */ (function() { @@ -439,7 +441,7 @@ Coords and icons need to be rewatched within Markers linked scope for (_i = 0, _len = _ref.length; _i < _len; _i++) { model = _ref[_i]; _results.push((function(model) { - _this.markers[_this.markersIndex] = new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.$timeout, _this.$log, function(index) { + _this.markers[_this.markersIndex] = new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, _this.$log, function(index) { return delete _this.markers[index]; }); _this.markersIndex++; diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index ff5e33f6c..26f4ed29d 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var e=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon),this.gMarker=new google.maps.Marker(opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),this.$timeout(function(){return e.watchCoords(e.myScope),e.watchIcon(e.myScope),e.watchDestroy(e.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},this.$log.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.$timeout,h.$log,function(a){return delete h.markers[a]}),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var g=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return g.watchCoords(g.myScope),g.watchIcon(g.myScope),g.watchDestroy(g.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},this.$log.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]}),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file diff --git a/example/example.html b/example/example.html index a1cd79be4..67a4ef881 100644 --- a/example/example.html +++ b/example/example.html @@ -49,20 +49,21 @@

angular-google-maps example

dragging="map.dragging" events="map.events"> - - - + + --> - +

This is an info window at {{ m.latitude | number:4 }}, {{ m.longitude | number:4 }}!

My marker will stay open when the window is popped up!

-
--> +
diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index e4cc5a415..dbe3264e6 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -22,7 +22,7 @@ @mapCtrl = mapCtrl opts = @createMarkerOptions(mapCtrl,scope.coords,scope.icon,animate) - #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the indec) + #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the index) @markers[scope.$id] = new google.maps.Marker(opts) element.data('instance', @markers[scope.$id]) diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index 58b1524cd..ba0790f2d 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -1,11 +1,13 @@ ### -Markers will map icon and coords differently as there us not 1:1 Scope to marker -icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] -coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] +Markers will map icon and coords differently than directibes.api.Marker. This is because Scope and the model marker are +not 1:1 in this setting. + + - icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] + - coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] -property changes from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself + - watches from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself + - actual changes to a model are tracked inside directives.api.model.MarkerModel -Coords and icons need to be rewatched within Markers linked scope ### @module "directives.api", -> class @Markers extends directives.api.IMarker From 96a387fd893d93d6c023064dc518f7d0114a9819 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 13:19:20 -0400 Subject: [PATCH 10/41] example with Markers and Marker --- example/example-controller.js | 19 +++++++++++++++++++ example/example.html | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/example/example-controller.js b/example/example-controller.js index d3911e1ec..9f59672e8 100644 --- a/example/example-controller.js +++ b/example/example-controller.js @@ -35,6 +35,25 @@ function ExampleController ($scope, $timeout, $log) { showWindow: false } ], + markers2: [ + { + latitude: 46, + longitude: -77, + showWindow: false + }, + { + latitude: 33, + longitude: -77, + showWindow: false + }, + { + icon: 'plane.png', + latitude: 35, + longitude: -125, + showWindow: false + } + ] + , clickedMarker: { latitude: null, longitude: null diff --git a/example/example.html b/example/example.html index 67a4ef881..47ebd4a05 100644 --- a/example/example.html +++ b/example/example.html @@ -49,12 +49,12 @@

angular-google-maps example

dragging="map.dragging" events="map.events"> - + From 780f993be55dc96a5995d07d27db373bdb17755d Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 16:15:57 -0400 Subject: [PATCH 11/41] directives.api. - IWindow - Window .models - WindowModel - WindowModelFunctions Windows to come --- dist/angular-google-maps.js | 342 ++++++++++++------ dist/angular-google-maps.min.js | 2 +- example/example.html | 6 +- src/coffee/directives/api/i-marker.coffee | 11 +- src/coffee/directives/api/i-window.coffee | 33 ++ src/coffee/directives/api/marker.coffee | 6 +- src/coffee/directives/api/markers.coffee | 2 +- .../directives/api/models/marker-model.coffee | 4 +- .../directives/api/models/window-model.coffee | 71 ++++ .../directives/api/utils/gmap-util.coffee | 14 +- src/coffee/directives/api/window.coffee | 27 ++ src/js/directives/window copy.js | 143 ++++++++ src/js/directives/window.js | 108 +----- 13 files changed, 541 insertions(+), 228 deletions(-) create mode 100644 src/coffee/directives/api/i-window.coffee create mode 100644 src/coffee/directives/api/models/window-model.coffee create mode 100644 src/coffee/directives/api/window.coffee create mode 100644 src/js/directives/window copy.js diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 3747d6a98..b4dc9b34b 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -91,9 +91,9 @@ angular.module('google-maps', []);;(function() { (function() { this.module("directives.api.utils", function() { return this.GmapUtil = { - createMarkerOptions: function(map, coords, icon, animate) { + createMarkerOptions: function(map, coords, icon, animate, defaults) { var opts; - opts = angular.extend({}, this.DEFAULTS, { + opts = angular.extend({}, defaults, { position: new google.maps.LatLng(coords.latitude, coords.longitude), map: map.getMap(), icon: icon, @@ -103,6 +103,12 @@ angular.module('google-maps', []);;(function() { delete opts.animation; } return opts; + }, + createWindowOptions: function(gMarker, scope, content) { + return angular.extend({}, DEFAULTS, { + content: content, + position: gMarker != null ? gMarker.getPosition() : new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) + }); } }; }); @@ -120,7 +126,7 @@ angular.module('google-maps', []);;(function() { MarkerModel.include(directives.api.utils.GmapUtil); - function MarkerModel(index, model, parentScope, mapCtrl, $timeout, $log, notifyLocalDestroy) { + function MarkerModel(index, model, parentScope, mapCtrl, $timeout, $log, notifyLocalDestroy, defaults) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); @@ -133,7 +139,7 @@ angular.module('google-maps', []);;(function() { this.myScope.icon = this.iconKey === 'self' ? model : model[this.iconKey]; this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; this.mapCtrl = mapCtrl; - this.opts = this.createMarkerOptions(this.mapCtrl, this.myScope.coords, this.myScope.icon); + this.opts = this.createMarkerOptions(this.mapCtrl, this.myScope.coords, this.myScope.icon, defaults); this.gMarker = new google.maps.Marker(this.opts); google.maps.event.addListener(this.gMarker, 'click', function() { if (doClick && (this.myScope.click != null)) { @@ -196,6 +202,112 @@ angular.module('google-maps', []);;(function() { }).call(this); + +/* + Functions are taking entireley local variables as to try and reuse functionality. + Hopefully this will work when an HTML Element is created or not for an InfoWindow. +*/ + +(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; }; + + this.module("directives.api.models", function() { + var _this = this; + return this.WindowModelFunctions = { + watchShow: function(scope, $http, $templateCache, $compile, gWin, showHandle, hideHandle) { + return scope.$watch('show()', function(newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + return showHandle(scope, $http, $templateCache, $compile, gWin); + } else { + return hideHandle(gWin); + } + } else { + if (newValue && !win.getMap()) { + return showHandle(scope, $http, $templateCache, $compile, gWin); + } + } + }, true); + }, + handleClick: function(scope, mapCtrl, markerInstance, gWin) { + google.maps.event.addListener(markerInstance, 'click', function() { + var initialMarkerVisibility; + gWin.setPosition(markerInstance.getPosition()); + gWin.open(mapCtrl.getMap()); + initialMarkerVisibility = markerInstance.getVisible(); + return markerInstance.setVisible(isIconVisibleOnClick); + }); + return google.maps.event.addListener(win, 'closeclick', function() { + markerInstance.setVisible(initialMarkerVisibility); + return scope.closeClick(); + }); + }, + showWindow: function(scope, $http, $templateCache, $compile, gWin) { + if (scope.templateUrl) { + return $http.get(scope.templateUrl, { + cache: $templateCache + }).then(function(content) { + var compiled, templateScope; + templateScope = scope.$new(); + if (angular.isDefined(scope.templateParameter)) { + templateScope.parameter = scope.templateParameter; + } + compiled = $compile(content.data)(templateScope); + gWin.setContent(compiled.get(0)); + return gWin.open(mapCtrl.getMap()); + }); + } else { + return _this.gWin.open(mapCtrl.getMap()); + } + }, + hideWindow: function(gWin) { + return gWin.close(); + } + }; + }); + + this.module("directives.api.models", function() { + return this.WindowModel = (function(_super) { + __extends(WindowModel, _super); + + WindowModel.include(directives.api.models.WindowModelFunctions); + + function WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $log, $http, $templateCache, $compile) { + this.scope = scope; + this.opts = opts; + this.isIconVisibleOnClick = isIconVisibleOnClick; + this.mapCtrl = mapCtrl; + this.markerCtrl = markerCtrl; + this.$log = $log; + this.$http = $http; + this.$templateCache = $templateCache; + this.$compile = $compile; + this.gWin = new google.maps.InfoWindow(opts); + this.markerInstance = markerCtrl.getMarker(); + this.markerInstance.setClickable(true); + this.handleClick(this.scope, this.mapCtrl, this.markerInstance, this.gWin); + this.watchShow(scope, $http, $templateCache, $compile, this.gWin, this.showWindow, this.hideWindow); + this.$log.info(this); + } + + return WindowModel; + + })(oo.BaseObject); + }); + +}).call(this); + + +/* + - interface for all markers to derrive from + - to enforce a minimum set of requirements + - attributes + - coords + - icon + - implementation needed on watches +*/ + (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -235,7 +347,6 @@ angular.module('google-maps', []);;(function() { icon: '=icon', click: '&click' }; - this.$log.info(self); } IMarker.prototype.controller = function($scope, $element) { @@ -291,6 +402,66 @@ angular.module('google-maps', []);;(function() { }).call(this); + +/* + - interface directive for all window(s) to derrive from +*/ + +(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; }; + + this.module("directives.api", function() { + return this.IWindow = (function(_super) { + __extends(IWindow, _super); + + IWindow.include(directives.api.utils.GmapUtil); + + IWindow.prototype.DEFAULTS = {}; + + function IWindow($log, $timeout, $compile, $http, $templateCache) { + this.link = __bind(this.link, this); + var self; + self = this; + this.clsName = "IWindow"; + this.restrict = 'ECMA'; + this.template = void 0; + this.transclude = true; + this.priority = -100; + this.require = ['^googleMap', '^?marker']; + this.scope = { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' + }; + this.$log = $log; + this.$timeout = $timeout; + this.$compile = $compile; + this.$http = $http; + this.$templateCache = $templateCache; + } + + IWindow.prototype.link = function(scope, element, attrs, ctrls) { + throw new Exception("Not Implemented!!"); + }; + + return IWindow; + + })(oo.BaseObject); + }); + +}).call(this); + + +/* + Basic Directive api for a marker. Basic in the sense that this directive contains 1:1 on scope and model. + Thus there will be one html element per marker within the directive. +*/ + (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -325,7 +496,7 @@ angular.module('google-maps', []);;(function() { Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { var opts; this.mapCtrl = mapCtrl; - opts = this.createMarkerOptions(mapCtrl, scope.coords, scope.icon, animate); + opts = this.createMarkerOptions(mapCtrl, scope.coords, scope.icon, animate, this.DEFAULTS); this.markers[scope.$id] = new google.maps.Marker(opts); element.data('instance', this.markers[scope.$id]); return google.maps.event.addListener(this.markers[scope.$id], 'click', function() { @@ -443,7 +614,7 @@ not 1:1 in this setting. _results.push((function(model) { _this.markers[_this.markersIndex] = new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, _this.$log, function(index) { return delete _this.markers[index]; - }); + }, _this.DEFAULTS); _this.markersIndex++; return element.data('instance', _this.markers); })(model)); @@ -503,6 +674,55 @@ not 1:1 in this setting. }); }).call(this); + + +/* + Window directive for GoogleMap Info Windows, where ng-repeat is being used.... + Where Html DOM element is 1:1 on Scope and a Model +*/ + +(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; }; + + this.module("directives.api", function() { + return this.Window = (function(_super) { + __extends(Window, _super); + + function Window($log, $timeout, $compile, $http, $templateCache) { + this.link = __bind(this.link, this); + var self; + Window.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); + self = this; + this.clsName = "Window"; + this.template = ''; + this.$log.info(self); + } + + Window.prototype.link = function(scope, element, attrs, ctrls) { + var _this = this; + return $timeout(function() { + var isIconVisibleOnClick, mapCtrl, markerCtrl, opts; + isIconVisibleOnClick = true; + if (angular.isDefined(attrs.isiconvisibleonclick)) { + isIconVisibleOnClick = scope.isIconVisibleOnClick; + } + mapCtrl = ctrls[0]; + markerCtrl = ctrls.length > 1 ? ctrls[1] : void 0; + opts = createOption(markerCtrl, scope, element.html()); + if ((mapCtrl != null) && (markerCtrl != null)) { + return new directives.api.models.WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$templateCache, _this.$compile); + } + }, 50); + }; + + return Window; + + })(directives.api.IWindow); + }); + +}).call(this); ;/**! * The MIT License * @@ -1061,107 +1281,7 @@ angular.module("google-maps") * {attribute show optional} map will show when this expression returns true */ -angular.module("google-maps"). - directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { - - "use strict"; - - var DEFAULTS = { - - }; - - return { - restrict: 'ECMA', - template: '', - transclude: true, - priority: -100, - require: ['^googleMap', '^?marker'], - scope: { - coords: '=coords', - show: '&show', - templateUrl: '=templateurl', - templateParameter: '=templateparameter', - isIconVisibleOnClick: '=isiconvisibleonclick', - closeClick: '&closeclick' //scope glue to gmap InfoWindow closeclick - }, - link: function (scope, element, attrs, ctrls) { - $timeout(function () { - - var isIconVisibleOnClick = true; - - if (angular.isDefined(attrs.isiconvisibleonclick)) - isIconVisibleOnClick = scope.isIconVisibleOnClick; - - var mapCtrl = ctrls[0], - markerCtrl = ctrls.length > 1 ? ctrls[1] : null; - - var opts = angular.extend({}, DEFAULTS, { - content: element.html(), - position: angular.isDefined(markerCtrl) ? markerCtrl.getMarker().getPosition() : - new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) - }); - - var win = new google.maps.InfoWindow(opts); - - if (angular.isDefined(markerCtrl)) { - // Open window on click - var markerInstance = markerCtrl.getMarker(); - - markerInstance.setClickable(true); - - // Show the window and hide the marker on click - var initialMarkerVisibility; - google.maps.event.addListener(markerInstance, 'click', function () { - win.setPosition(markerInstance.getPosition()); - win.open(mapCtrl.getMap()); - - initialMarkerVisibility = markerInstance.getVisible(); - - markerInstance.setVisible(isIconVisibleOnClick); - }); - - // Set visibility of marker back to what it was before opening the window - google.maps.event.addListener(win, 'closeclick', function () { - markerInstance.setVisible(initialMarkerVisibility); - scope.closeClick(); - }); - } - - function showWindow() { - if (scope.templateUrl) { - $http.get(scope.templateUrl, { cache: $templateCache }) - .then(function (content) { - var templateScope = scope.$new(); - if (angular.isDefined(scope.templateParameter)) { - templateScope.parameter = scope.templateParameter; - } - var compiled = $compile(content.data)(templateScope); - win.setContent(compiled.get(0)); - win.open(mapCtrl.getMap()); - }); - } else { - win.open(mapCtrl.getMap()); - } - } - - function hideWindow() { - win.close(); - } - - scope.$watch('show()', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - showWindow(); - } - else { - hideWindow(); - } - } else if (newValue && !win.getMap()) { - // If we're initially showing the marker and it's not yet visible, show it. - showWindow(); - } - },true); - }, 50); - } - }; - }]); +angular.module("google-maps").directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', + function ($log, $timeout, $compile, $http, $templateCache) { + new directives.api.Window($log, $timeout, $compile, $http, $templateCache); + }]); \ No newline at end of file diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 26f4ed29d..363822173 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d){var e;return e=angular.extend({},this.DEFAULTS,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete e.animation,e}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var g=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return g.watchCoords(g.myScope),g.watchIcon(g.myScope),g.watchDestroy(g.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"},this.$log.info(d)}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]}),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',transclude:!0,priority:-100,require:["^googleMap","^?marker"],scope:{coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},link:function(a,g,h,i){b(function(){function b(){a.templateUrl?d.get(a.templateUrl,{cache:e}).then(function(b){var d=a.$new();angular.isDefined(a.templateParameter)&&(d.parameter=a.templateParameter);var e=c(b.data)(d);o.setContent(e.get(0)),o.open(l.getMap())}):o.open(l.getMap())}function j(){o.close()}var k=!0;angular.isDefined(h.isiconvisibleonclick)&&(k=a.isIconVisibleOnClick);var l=i[0],m=i.length>1?i[1]:null,n=angular.extend({},f,{content:g.html(),position:angular.isDefined(m)?m.getMarker().getPosition():new google.maps.LatLng(a.coords.latitude,a.coords.longitude)}),o=new google.maps.InfoWindow(n);if(angular.isDefined(m)){var p=m.getMarker();p.setClickable(!0);var q;google.maps.event.addListener(p,"click",function(){o.setPosition(p.getPosition()),o.open(l.getMap()),q=p.getVisible(),p.setVisible(k)}),google.maps.event.addListener(o,"closeclick",function(){p.setVisible(q),a.closeClick()})}a.$watch("show()",function(a,c){a!==c?a?b():j():a&&!o.getMap()&&b()},!0)},50)}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c){return angular.extend({},DEFAULTS,{content:c,position:null!=a?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){var a=this;return this.WindowModelFunctions={watchShow:function(a,b,c,d,e,f,g){return a.$watch("show()",function(h,i){return h!==i?h?f(a,b,c,d,e):g(e):h&&!win.getMap()?f(a,b,c,d,e):void 0},!0)},handleClick:function(a,b,c,d){return google.maps.event.addListener(c,"click",function(){var a;return d.setPosition(c.getPosition()),d.open(b.getMap()),a=c.getVisible(),c.setVisible(isIconVisibleOnClick)}),google.maps.event.addListener(win,"closeclick",function(){return c.setVisible(initialMarkerVisibility),a.closeClick()})},showWindow:function(b,c,d,e,f){return b.templateUrl?c.get(b.templateUrl,{cache:d}).then(function(a){var c,d;return d=b.$new(),angular.isDefined(b.templateParameter)&&(d.parameter=b.templateParameter),c=e(a.data)(d),f.setContent(c.get(0)),f.open(mapCtrl.getMap())}):a.gWin.open(mapCtrl.getMap())},hideWindow:function(a){return a.close()}}}),this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.isIconVisibleOnClick=c,this.mapCtrl=d,this.markerCtrl=e,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),this.markerInstance=e.getMarker(),this.markerInstance.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerInstance,this.gWin),this.watchShow(a,g,h,i,this.gWin,this.showWindow,this.hideWindow),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowModelFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return $timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0],h=d.length>1?d[1]:void 0,i=createOption(h,a,b.html()),null!=g&&null!=h?new directives.api.models.WindowModel(a,i,f,g,h,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bangular-google-maps example draggable="true" dragging="map.dragging" events="map.events"> - + diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index 735d05006..726fd3616 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -1,4 +1,11 @@ -# simple module of functions to be overriden / mixed in +### + - interface for all markers to derrive from + - to enforce a minimum set of requirements + - attributes + - coords + - icon + - implementation needed on watches +### @module "directives.api", -> class @IMarker extends oo.BaseObject # Animation is enabled by default @@ -26,8 +33,6 @@ click: '&click' } - @$log.info(self) - controller: ($scope, $element) -> @getMarker = -> $element.data('instance') diff --git a/src/coffee/directives/api/i-window.coffee b/src/coffee/directives/api/i-window.coffee new file mode 100644 index 000000000..3af5600fe --- /dev/null +++ b/src/coffee/directives/api/i-window.coffee @@ -0,0 +1,33 @@ +### + - interface directive for all window(s) to derrive from +### +@module "directives.api", -> + class @IWindow extends oo.BaseObject + @include directives.api.utils.GmapUtil + # Animation is enabled by default + DEFAULTS: {} + + constructor: ($log, $timeout, $compile, $http, $templateCache) -> + self = @ + @clsName = "IWindow" + @restrict= 'ECMA' + @template= undefined + @transclude= true + @priority= -100 + @require= ['^googleMap', '^?marker'] + @scope= { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' #scope glue to gmap InfoWindow closeclick + } + @$log = $log + @$timeout = $timeout + @$compile = $compile + @$http = $http + @$templateCache = $templateCache + + link: (scope, element, attrs, ctrls) => + throw new Exception("Not Implemented!!") \ No newline at end of file diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index dbe3264e6..a6153ecf5 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -1,3 +1,7 @@ +### + Basic Directive api for a marker. Basic in the sense that this directive contains 1:1 on scope and model. + Thus there will be one html element per marker within the directive. +### @module "directives.api", -> class @Marker extends directives.api.IMarker @include directives.api.utils.GmapUtil @@ -20,7 +24,7 @@ linkInit:(element,mapCtrl,scope,animate,doClick) => #linked scope is 1:1 per marker @mapCtrl = mapCtrl - opts = @createMarkerOptions(mapCtrl,scope.coords,scope.icon,animate) + opts = @createMarkerOptions(mapCtrl,scope.coords,scope.icon,animate,@DEFAULTS) #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the index) @markers[scope.$id] = new google.maps.Marker(opts) diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index ba0790f2d..de7351d64 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -41,7 +41,7 @@ not 1:1 in this setting. @markers[@markersIndex] = new directives.api.models.MarkerModel(@markersIndex,model,scope,@mapCtrl,@$timeout,@$log, (index) => delete @markers[index] - ) + ,@DEFAULTS) @markersIndex++ element.data('instance', @markers) diff --git a/src/coffee/directives/api/models/marker-model.coffee b/src/coffee/directives/api/models/marker-model.coffee index f99977d19..2bf2edeb6 100644 --- a/src/coffee/directives/api/models/marker-model.coffee +++ b/src/coffee/directives/api/models/marker-model.coffee @@ -1,7 +1,7 @@ @module "directives.api.models", -> class @MarkerModel extends oo.BaseObject @include directives.api.utils.GmapUtil - constructor:(index,model,parentScope,mapCtrl,$timeout,$log,notifyLocalDestroy)-> + constructor:(index,model,parentScope,mapCtrl,$timeout,$log,notifyLocalDestroy,defaults)-> @index = index @iconKey = parentScope.icon @coordsKey = parentScope.coords @@ -9,7 +9,7 @@ @myScope.icon = if @iconKey == 'self' then model else model[@iconKey] @myScope.coords = if @coordsKey == 'self' then model else model[@coordsKey] @mapCtrl = mapCtrl - @opts = @createMarkerOptions(@mapCtrl,@myScope.coords,@myScope.icon) + @opts = @createMarkerOptions(@mapCtrl,@myScope.coords,@myScope.icon,defaults) @gMarker = new google.maps.Marker(@opts) google.maps.event.addListener(@gMarker, 'click', -> #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ diff --git a/src/coffee/directives/api/models/window-model.coffee b/src/coffee/directives/api/models/window-model.coffee new file mode 100644 index 000000000..250aa31bf --- /dev/null +++ b/src/coffee/directives/api/models/window-model.coffee @@ -0,0 +1,71 @@ +### + Functions are taking entireley local variables as to try and reuse functionality. + Hopefully this will work when an HTML Element is created or not for an InfoWindow. +### +@module "directives.api.models", -> + @WindowModelFunctions = + watchShow:(scope,$http,$templateCache,$compile,gWin,showHandle,hideHandle,mapCtrl) => + scope.$watch('show()', (newValue, oldValue) => + if (newValue != oldValue) + if (newValue) + showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) + else + hideHandle(gWin) + else + if (newValue and !win.getMap()) + # If we're initially showing the marker and it's not yet visible, show it. + showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) + ,true) + + handleClick:(scope,mapCtrl,markerInstance,gWin,isIconVisibleOnClick,initialMarkerVisibility) -> + # Show the window and hide the marker on click + google.maps.event.addListener(markerInstance, 'click', -> + gWin.setPosition(markerInstance.getPosition()) + gWin.open(mapCtrl) + markerInstance.setVisible(isIconVisibleOnClick) + ) + # Set visibility of marker back to what it was before opening the window + google.maps.event.addListener(gWin, 'closeclick', -> + markerInstance.setVisible(initialMarkerVisibility) + scope.closeClick() + ) + + showWindow:(scope,$http,$templateCache,$compile,gWin,mapCtrl) => + if scope.templateUrl + $http.get(scope.templateUrl, { cache: $templateCache }).then((content) => + templateScope = scope.$new() + if angular.isDefined(scope.templateParameter) + templateScope.parameter = scope.templateParameter + compiled = $compile(content.data)(templateScope) + gWin.setContent(compiled.get(0)) + gWin.open(mapCtrl) + ) + else + gWin.open(mapCtrl) + + hideWindow: (gWin) -> + gWin.close() + +@module "directives.api.models", -> + class @WindowModel extends oo.BaseObject + @include directives.api.models.WindowModelFunctions + constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$log,$http,$templateCache,$compile)-> + @scope = scope + @opts = opts + @mapCtrl = mapCtrl + @markerCtrl = markerCtrl + @isIconVisibleOnClick = isIconVisibleOnClick + @initialMarkerVisibility = @markerCtrl.getVisible() + @$log = $log + @$http = $http + @$templateCache = $templateCache + @$compile = $compile + @gWin = new google.maps.InfoWindow(opts) + # Open window on click + @markerCtrl.setClickable(true) + + @handleClick(@scope,@mapCtrl,@markerCtrl,@gWin,@isIconVisibleOnClick,@initialMarkerVisibility) + @watchShow(scope,$http,$templateCache,@$compile,@gWin,@showWindow,@hideWindow,@mapCtrl) + + @$log.info(@) + diff --git a/src/coffee/directives/api/utils/gmap-util.coffee b/src/coffee/directives/api/utils/gmap-util.coffee index 7e61404d8..7535fd121 100644 --- a/src/coffee/directives/api/utils/gmap-util.coffee +++ b/src/coffee/directives/api/utils/gmap-util.coffee @@ -1,7 +1,7 @@ @module "directives.api.utils", -> @GmapUtil = - createMarkerOptions:(map,coords,icon,animate) -> - opts = angular.extend({}, @DEFAULTS, { + createMarkerOptions:(map,coords,icon,animate,defaults) -> + opts = angular.extend({}, defaults, { position: new google.maps.LatLng(coords.latitude, coords.longitude), map: map.getMap(), icon: icon, @@ -10,3 +10,13 @@ if !animate delete opts.animation; opts + + createWindowOptions:(gMarker,scope,content,defaults) -> + angular.extend({}, defaults, { + content: content, + position: + if angular.isObject(gMarker) + gMarker.getPosition() + else + new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) + }) diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee new file mode 100644 index 000000000..27d0db451 --- /dev/null +++ b/src/coffee/directives/api/window.coffee @@ -0,0 +1,27 @@ +### + Window directive for GoogleMap Info Windows, where ng-repeat is being used.... + Where Html DOM element is 1:1 on Scope and a Model +### +@module "directives.api", -> + class @Window extends directives.api.IWindow + + constructor: ($log, $timeout, $compile, $http, $templateCache) -> + super($log, $timeout, $compile, $http, $templateCache) + self = @ + @clsName = "Window" + @template = '' + @$log.info(self) + + link: (scope, element, attrs, ctrls) => + @$timeout( => + isIconVisibleOnClick = true + if angular.isDefined(attrs.isiconvisibleonclick) + isIconVisibleOnClick = scope.isIconVisibleOnClick + mapCtrl = ctrls[0].getMap() + markerCtrl = if ctrls.length > 1 and ctrls[1]? then ctrls[1].getMarker() else undefined + + opts = @createWindowOptions(markerCtrl,scope,element.html(),@DEFAULTS) + + if mapCtrl? and markerCtrl? + new directives.api.models.WindowModel(scope,opts,isIconVisibleOnClick,mapCtrl,markerCtrl,@$templateCache,@$compile) + ,50) \ No newline at end of file diff --git a/src/js/directives/window copy.js b/src/js/directives/window copy.js new file mode 100644 index 000000000..2dfc80512 --- /dev/null +++ b/src/js/directives/window copy.js @@ -0,0 +1,143 @@ +/**! + * The MIT License + * + * Copyright (c) 2010-2012 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 + * + * @author Nicolas Laplante https://plus.google.com/108189012221374960701 + */ + +/** + * Map info window directive + * + * This directive is used to create an info window on an existing map. + * This directive creates a new scope. + * + * {attribute coords required} object containing latitude and longitude properties + * {attribute show optional} map will show when this expression returns true + */ + +angular.module("google-maps"). + directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { + + "use strict"; + + var DEFAULTS = { + + }; + + return { + restrict: 'ECMA', + template: '', + transclude: true, + priority: -100, + require: ['^googleMap', '^?marker'], + scope: { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' //scope glue to gmap InfoWindow closeclick + }, + link: function (scope, element, attrs, ctrls) { + $timeout(function () { + + var isIconVisibleOnClick = true; + + if (angular.isDefined(attrs.isiconvisibleonclick)) + isIconVisibleOnClick = scope.isIconVisibleOnClick; + + var mapCtrl = ctrls[0], + markerCtrl = ctrls.length > 1 ? ctrls[1] : null; + + var opts = angular.extend({}, DEFAULTS, { + content: element.html(), + position: angular.isDefined(markerCtrl) ? markerCtrl.getMarker().getPosition() : + new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) + }); + + var win = new google.maps.InfoWindow(opts); + + if (angular.isDefined(markerCtrl)) { + // Open window on click + var markerInstance = markerCtrl.getMarker(); + + markerInstance.setClickable(true); + + // Show the window and hide the marker on click + var initialMarkerVisibility; + google.maps.event.addListener(markerInstance, 'click', function () { + win.setPosition(markerInstance.getPosition()); + win.open(mapCtrl.getMap()); + + initialMarkerVisibility = markerInstance.getVisible(); + + markerInstance.setVisible(isIconVisibleOnClick); + }); + + // Set visibility of marker back to what it was before opening the window + google.maps.event.addListener(win, 'closeclick', function () { + markerInstance.setVisible(initialMarkerVisibility); + scope.closeClick(); + }); + } + + function showWindow() { + if (scope.templateUrl) { + $http.get(scope.templateUrl, { cache: $templateCache }) + .then(function (content) { + var templateScope = scope.$new(); + if (angular.isDefined(scope.templateParameter)) { + templateScope.parameter = scope.templateParameter; + } + var compiled = $compile(content.data)(templateScope); + win.setContent(compiled.get(0)); + win.open(mapCtrl.getMap()); + }); + } else { + win.open(mapCtrl.getMap()); + } + } + + function hideWindow() { + win.close(); + } + + scope.$watch('show()', function (newValue, oldValue) { + if (newValue !== oldValue) { + if (newValue) { + showWindow(); + } + else { + hideWindow(); + } + } else if (newValue && !win.getMap()) { + // If we're initially showing the marker and it's not yet visible, show it. + showWindow(); + } + },true); + }, 50); + } + }; + }]); diff --git a/src/js/directives/window.js b/src/js/directives/window.js index 2dfc80512..9777a774f 100644 --- a/src/js/directives/window.js +++ b/src/js/directives/window.js @@ -37,107 +37,7 @@ * {attribute show optional} map will show when this expression returns true */ -angular.module("google-maps"). - directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { - - "use strict"; - - var DEFAULTS = { - - }; - - return { - restrict: 'ECMA', - template: '', - transclude: true, - priority: -100, - require: ['^googleMap', '^?marker'], - scope: { - coords: '=coords', - show: '&show', - templateUrl: '=templateurl', - templateParameter: '=templateparameter', - isIconVisibleOnClick: '=isiconvisibleonclick', - closeClick: '&closeclick' //scope glue to gmap InfoWindow closeclick - }, - link: function (scope, element, attrs, ctrls) { - $timeout(function () { - - var isIconVisibleOnClick = true; - - if (angular.isDefined(attrs.isiconvisibleonclick)) - isIconVisibleOnClick = scope.isIconVisibleOnClick; - - var mapCtrl = ctrls[0], - markerCtrl = ctrls.length > 1 ? ctrls[1] : null; - - var opts = angular.extend({}, DEFAULTS, { - content: element.html(), - position: angular.isDefined(markerCtrl) ? markerCtrl.getMarker().getPosition() : - new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) - }); - - var win = new google.maps.InfoWindow(opts); - - if (angular.isDefined(markerCtrl)) { - // Open window on click - var markerInstance = markerCtrl.getMarker(); - - markerInstance.setClickable(true); - - // Show the window and hide the marker on click - var initialMarkerVisibility; - google.maps.event.addListener(markerInstance, 'click', function () { - win.setPosition(markerInstance.getPosition()); - win.open(mapCtrl.getMap()); - - initialMarkerVisibility = markerInstance.getVisible(); - - markerInstance.setVisible(isIconVisibleOnClick); - }); - - // Set visibility of marker back to what it was before opening the window - google.maps.event.addListener(win, 'closeclick', function () { - markerInstance.setVisible(initialMarkerVisibility); - scope.closeClick(); - }); - } - - function showWindow() { - if (scope.templateUrl) { - $http.get(scope.templateUrl, { cache: $templateCache }) - .then(function (content) { - var templateScope = scope.$new(); - if (angular.isDefined(scope.templateParameter)) { - templateScope.parameter = scope.templateParameter; - } - var compiled = $compile(content.data)(templateScope); - win.setContent(compiled.get(0)); - win.open(mapCtrl.getMap()); - }); - } else { - win.open(mapCtrl.getMap()); - } - } - - function hideWindow() { - win.close(); - } - - scope.$watch('show()', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - showWindow(); - } - else { - hideWindow(); - } - } else if (newValue && !win.getMap()) { - // If we're initially showing the marker and it's not yet visible, show it. - showWindow(); - } - },true); - }, 50); - } - }; - }]); +angular.module("google-maps").directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', + function ($log, $timeout, $compile, $http, $templateCache) { + return new directives.api.Window($log, $timeout, $compile, $http, $templateCache); + }]); \ No newline at end of file From e8c2dfa049efa9505a74eecad9e04a639753f70e Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 20:04:15 -0400 Subject: [PATCH 12/41] standalone window working again without templates --- dist/angular-google-maps.js | 64 ++++----- dist/angular-google-maps.min.js | 2 +- example/example.html | 129 +++++++++--------- .../directives/api/models/window-model.coffee | 27 ++-- src/coffee/directives/api/window.coffee | 2 +- 5 files changed, 114 insertions(+), 110 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index b4dc9b34b..ea4b9980f 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -104,10 +104,10 @@ angular.module('google-maps', []);;(function() { } return opts; }, - createWindowOptions: function(gMarker, scope, content) { - return angular.extend({}, DEFAULTS, { + createWindowOptions: function(gMarker, scope, content, defaults) { + return angular.extend({}, defaults, { content: content, - position: gMarker != null ? gMarker.getPosition() : new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) + position: angular.isObject(gMarker) ? gMarker.getPosition() : new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) }); } }; @@ -215,35 +215,35 @@ angular.module('google-maps', []);;(function() { this.module("directives.api.models", function() { var _this = this; return this.WindowModelFunctions = { - watchShow: function(scope, $http, $templateCache, $compile, gWin, showHandle, hideHandle) { + watchShow: function(scope, $http, $templateCache, $compile, gWin, showHandle, hideHandle, mapCtrl) { return scope.$watch('show()', function(newValue, oldValue) { if (newValue !== oldValue) { if (newValue) { - return showHandle(scope, $http, $templateCache, $compile, gWin); + return showHandle(scope, $http, $templateCache, $compile, gWin, mapCtrl); } else { return hideHandle(gWin); } } else { if (newValue && !win.getMap()) { - return showHandle(scope, $http, $templateCache, $compile, gWin); + return showHandle(scope, $http, $templateCache, $compile, gWin, mapCtrl); } } }, true); }, - handleClick: function(scope, mapCtrl, markerInstance, gWin) { - google.maps.event.addListener(markerInstance, 'click', function() { - var initialMarkerVisibility; - gWin.setPosition(markerInstance.getPosition()); - gWin.open(mapCtrl.getMap()); - initialMarkerVisibility = markerInstance.getVisible(); - return markerInstance.setVisible(isIconVisibleOnClick); - }); - return google.maps.event.addListener(win, 'closeclick', function() { - markerInstance.setVisible(initialMarkerVisibility); - return scope.closeClick(); - }); + handleClick: function(scope, mapCtrl, markerInstance, gWin, isIconVisibleOnClick, initialMarkerVisibility) { + if (markerInstance != null) { + google.maps.event.addListener(markerInstance, 'click', function() { + gWin.setPosition(markerInstance.getPosition()); + gWin.open(mapCtrl); + return markerInstance.setVisible(isIconVisibleOnClick); + }); + return google.maps.event.addListener(gWin, 'closeclick', function() { + markerInstance.setVisible(initialMarkerVisibility); + return scope.closeClick(); + }); + } }, - showWindow: function(scope, $http, $templateCache, $compile, gWin) { + showWindow: function(scope, $http, $templateCache, $compile, gWin, mapCtrl) { if (scope.templateUrl) { return $http.get(scope.templateUrl, { cache: $templateCache @@ -255,10 +255,10 @@ angular.module('google-maps', []);;(function() { } compiled = $compile(content.data)(templateScope); gWin.setContent(compiled.get(0)); - return gWin.open(mapCtrl.getMap()); + return gWin.open(mapCtrl); }); } else { - return _this.gWin.open(mapCtrl.getMap()); + return gWin.open(mapCtrl); } }, hideWindow: function(gWin) { @@ -276,18 +276,18 @@ angular.module('google-maps', []);;(function() { function WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $log, $http, $templateCache, $compile) { this.scope = scope; this.opts = opts; - this.isIconVisibleOnClick = isIconVisibleOnClick; this.mapCtrl = mapCtrl; this.markerCtrl = markerCtrl; + this.isIconVisibleOnClick = isIconVisibleOnClick; + this.initialMarkerVisibility = this.markerCtrl != null ? this.markerCtrl.getVisible() : false; this.$log = $log; this.$http = $http; this.$templateCache = $templateCache; this.$compile = $compile; this.gWin = new google.maps.InfoWindow(opts); - this.markerInstance = markerCtrl.getMarker(); - this.markerInstance.setClickable(true); - this.handleClick(this.scope, this.mapCtrl, this.markerInstance, this.gWin); - this.watchShow(scope, $http, $templateCache, $compile, this.gWin, this.showWindow, this.hideWindow); + this.markerCtrl.setClickable(true); + this.handleClick(this.scope, this.mapCtrl, this.markerCtrl, this.gWin, this.isIconVisibleOnClick, this.initialMarkerVisibility); + this.watchShow(scope, $http, $templateCache, this.$compile, this.gWin, this.showWindow, this.hideWindow, this.mapCtrl); this.$log.info(this); } @@ -702,16 +702,16 @@ not 1:1 in this setting. Window.prototype.link = function(scope, element, attrs, ctrls) { var _this = this; - return $timeout(function() { + return this.$timeout(function() { var isIconVisibleOnClick, mapCtrl, markerCtrl, opts; isIconVisibleOnClick = true; if (angular.isDefined(attrs.isiconvisibleonclick)) { isIconVisibleOnClick = scope.isIconVisibleOnClick; } - mapCtrl = ctrls[0]; - markerCtrl = ctrls.length > 1 ? ctrls[1] : void 0; - opts = createOption(markerCtrl, scope, element.html()); - if ((mapCtrl != null) && (markerCtrl != null)) { + mapCtrl = ctrls[0].getMap(); + markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarker() : void 0; + opts = _this.createWindowOptions(markerCtrl, scope, element.html(), _this.DEFAULTS); + if (mapCtrl != null) { return new directives.api.models.WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$templateCache, _this.$compile); } }, 50); @@ -1283,5 +1283,5 @@ angular.module("google-maps") angular.module("google-maps").directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { - new directives.api.Window($log, $timeout, $compile, $http, $templateCache); + return new directives.api.Window($log, $timeout, $compile, $http, $templateCache); }]); \ No newline at end of file diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 363822173..a84ba6de1 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c){return angular.extend({},DEFAULTS,{content:c,position:null!=a?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){var a=this;return this.WindowModelFunctions={watchShow:function(a,b,c,d,e,f,g){return a.$watch("show()",function(h,i){return h!==i?h?f(a,b,c,d,e):g(e):h&&!win.getMap()?f(a,b,c,d,e):void 0},!0)},handleClick:function(a,b,c,d){return google.maps.event.addListener(c,"click",function(){var a;return d.setPosition(c.getPosition()),d.open(b.getMap()),a=c.getVisible(),c.setVisible(isIconVisibleOnClick)}),google.maps.event.addListener(win,"closeclick",function(){return c.setVisible(initialMarkerVisibility),a.closeClick()})},showWindow:function(b,c,d,e,f){return b.templateUrl?c.get(b.templateUrl,{cache:d}).then(function(a){var c,d;return d=b.$new(),angular.isDefined(b.templateParameter)&&(d.parameter=b.templateParameter),c=e(a.data)(d),f.setContent(c.get(0)),f.open(mapCtrl.getMap())}):a.gWin.open(mapCtrl.getMap())},hideWindow:function(a){return a.close()}}}),this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.isIconVisibleOnClick=c,this.mapCtrl=d,this.markerCtrl=e,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),this.markerInstance=e.getMarker(),this.markerInstance.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerInstance,this.gWin),this.watchShow(a,g,h,i,this.gWin,this.showWindow,this.hideWindow),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowModelFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return $timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0],h=d.length>1?d[1]:void 0,i=createOption(h,a,b.html()),null!=g&&null!=h?new directives.api.models.WindowModel(a,i,f,g,h,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModelFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!win.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}}),this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowModelFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bangular-google-maps example - + - + + + + I should not be attached to a + marker. + - I should not be attached to a - marker. - - - + + - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - -
markers - -
center
 {{ map.center.latitude | number:4 }} lat
 {{ map.center.longitude | number:4 }} lng
zoom{{ map.zoom }}
dragging{{ map.dragging }}
clicked position -
 {{ map.clickedMarker.latitude | number:4 }} lat
 {{ map.clickedMarker.longitude | number:4 }} lng
- Click the map to see -
- -
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
markers + +
center
 {{ map.center.latitude | number:4 }} lat
 {{ map.center.longitude | number:4 }} lng
zoom{{ map.zoom }}
dragging{{ map.dragging }}
clicked position +
 {{ map.clickedMarker.latitude | number:4 }} lat
 {{ map.clickedMarker.longitude | number:4 }} lng
+ Click the map to see +
+ +
+
- - - - - - - - - + + + + + + + + + + diff --git a/src/coffee/directives/api/models/window-model.coffee b/src/coffee/directives/api/models/window-model.coffee index 250aa31bf..1f5deba36 100644 --- a/src/coffee/directives/api/models/window-model.coffee +++ b/src/coffee/directives/api/models/window-model.coffee @@ -18,17 +18,18 @@ ,true) handleClick:(scope,mapCtrl,markerInstance,gWin,isIconVisibleOnClick,initialMarkerVisibility) -> - # Show the window and hide the marker on click - google.maps.event.addListener(markerInstance, 'click', -> - gWin.setPosition(markerInstance.getPosition()) - gWin.open(mapCtrl) - markerInstance.setVisible(isIconVisibleOnClick) - ) - # Set visibility of marker back to what it was before opening the window - google.maps.event.addListener(gWin, 'closeclick', -> - markerInstance.setVisible(initialMarkerVisibility) - scope.closeClick() - ) + if markerInstance? + # Show the window and hide the marker on click + google.maps.event.addListener(markerInstance, 'click', -> + gWin.setPosition(markerInstance.getPosition()) + gWin.open(mapCtrl) + markerInstance.setVisible(isIconVisibleOnClick) + ) + # Set visibility of marker back to what it was before opening the window + google.maps.event.addListener(gWin, 'closeclick', -> + markerInstance.setVisible(initialMarkerVisibility) + scope.closeClick() + ) showWindow:(scope,$http,$templateCache,$compile,gWin,mapCtrl) => if scope.templateUrl @@ -55,14 +56,14 @@ @mapCtrl = mapCtrl @markerCtrl = markerCtrl @isIconVisibleOnClick = isIconVisibleOnClick - @initialMarkerVisibility = @markerCtrl.getVisible() + @initialMarkerVisibility = if @markerCtrl? then @markerCtrl.getVisible() else false @$log = $log @$http = $http @$templateCache = $templateCache @$compile = $compile @gWin = new google.maps.InfoWindow(opts) # Open window on click - @markerCtrl.setClickable(true) + @markerCtrl.setClickable(true) if @markerCtrl? @handleClick(@scope,@mapCtrl,@markerCtrl,@gWin,@isIconVisibleOnClick,@initialMarkerVisibility) @watchShow(scope,$http,$templateCache,@$compile,@gWin,@showWindow,@hideWindow,@mapCtrl) diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee index 27d0db451..41df15165 100644 --- a/src/coffee/directives/api/window.coffee +++ b/src/coffee/directives/api/window.coffee @@ -22,6 +22,6 @@ opts = @createWindowOptions(markerCtrl,scope,element.html(),@DEFAULTS) - if mapCtrl? and markerCtrl? + if mapCtrl? #at the very least we need a Map, the marker is optional as we can create Windows without markers new directives.api.models.WindowModel(scope,opts,isIconVisibleOnClick,mapCtrl,markerCtrl,@$templateCache,@$compile) ,50) \ No newline at end of file From 4b599b8a10698caf0834acaa0f72e4f6f9c7bdbf Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 20:16:41 -0400 Subject: [PATCH 13/41] templated Windows working again --- dist/angular-google-maps.js | 4 +++- dist/angular-google-maps.min.js | 2 +- example/example.html | 8 ++++---- example/templates/info.html | 2 +- src/coffee/directives/api/models/window-model.coffee | 2 +- src/coffee/directives/api/window.coffee | 5 ++++- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index ea4b9980f..82f2852ab 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -285,7 +285,9 @@ angular.module('google-maps', []);;(function() { this.$templateCache = $templateCache; this.$compile = $compile; this.gWin = new google.maps.InfoWindow(opts); - this.markerCtrl.setClickable(true); + if (this.markerCtrl != null) { + this.markerCtrl.setClickable(true); + } this.handleClick(this.scope, this.mapCtrl, this.markerCtrl, this.gWin, this.isIconVisibleOnClick, this.initialMarkerVisibility); this.watchShow(scope, $http, $templateCache, this.$compile, this.gWin, this.showWindow, this.hideWindow, this.mapCtrl); this.$log.info(this); diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index a84ba6de1..99379b4f7 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModelFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!win.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}}),this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowModelFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModelFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!win.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}}),this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowModelFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bangular-google-maps example - + - + I should not be attached to a diff --git a/example/templates/info.html b/example/templates/info.html index 2825dbad3..3c9fcac0e 100644 --- a/example/templates/info.html +++ b/example/templates/info.html @@ -1,4 +1,4 @@ -
+
I'm loaded from an external template, yay!
Parameter from opener: {{ parameter.message }} diff --git a/src/coffee/directives/api/models/window-model.coffee b/src/coffee/directives/api/models/window-model.coffee index 1f5deba36..3894cf45b 100644 --- a/src/coffee/directives/api/models/window-model.coffee +++ b/src/coffee/directives/api/models/window-model.coffee @@ -12,7 +12,7 @@ else hideHandle(gWin) else - if (newValue and !win.getMap()) + if (newValue and !gWin.getMap()) # If we're initially showing the marker and it's not yet visible, show it. showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) ,true) diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee index 41df15165..cce2ae8cd 100644 --- a/src/coffee/directives/api/window.coffee +++ b/src/coffee/directives/api/window.coffee @@ -23,5 +23,8 @@ opts = @createWindowOptions(markerCtrl,scope,element.html(),@DEFAULTS) if mapCtrl? #at the very least we need a Map, the marker is optional as we can create Windows without markers - new directives.api.models.WindowModel(scope,opts,isIconVisibleOnClick,mapCtrl,markerCtrl,@$templateCache,@$compile) + new directives.api.models.WindowModel( + scope,opts,isIconVisibleOnClick,mapCtrl, + markerCtrl,@$log,@$http,@$templateCache,@$compile + ) ,50) \ No newline at end of file From 72bde1aec2a8f82a8b08217cb6b223a4f31296d0 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 20:25:55 -0400 Subject: [PATCH 14/41] window template content fixed. WindowModelFunctions, function now are -> and not => as no self references needed.[C --- src/coffee/directives/api/models/window-model.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coffee/directives/api/models/window-model.coffee b/src/coffee/directives/api/models/window-model.coffee index 3894cf45b..578a47e0f 100644 --- a/src/coffee/directives/api/models/window-model.coffee +++ b/src/coffee/directives/api/models/window-model.coffee @@ -4,8 +4,8 @@ ### @module "directives.api.models", -> @WindowModelFunctions = - watchShow:(scope,$http,$templateCache,$compile,gWin,showHandle,hideHandle,mapCtrl) => - scope.$watch('show()', (newValue, oldValue) => + watchShow:(scope,$http,$templateCache,$compile,gWin,showHandle,hideHandle,mapCtrl) -> + scope.$watch('show()', (newValue, oldValue) -> if (newValue != oldValue) if (newValue) showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) @@ -31,9 +31,9 @@ scope.closeClick() ) - showWindow:(scope,$http,$templateCache,$compile,gWin,mapCtrl) => + showWindow:(scope,$http,$templateCache,$compile,gWin,mapCtrl) -> if scope.templateUrl - $http.get(scope.templateUrl, { cache: $templateCache }).then((content) => + $http.get(scope.templateUrl, { cache: $templateCache }).then((content) -> templateScope = scope.$new() if angular.isDefined(scope.templateParameter) templateScope.parameter = scope.templateParameter From c5b48989f4a4ef7eaf46b92c61f2b4920e3e8ee1 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 24 Jul 2013 22:12:42 -0400 Subject: [PATCH 15/41] save off Windows work[C --- .../api/models/window-functions.coffee | 50 +++++++++++++ .../directives/api/models/window-model.coffee | 51 +------------ src/coffee/directives/api/windows.coffee | 73 +++++++++++++++++++ 3 files changed, 124 insertions(+), 50 deletions(-) create mode 100644 src/coffee/directives/api/models/window-functions.coffee create mode 100644 src/coffee/directives/api/windows.coffee diff --git a/src/coffee/directives/api/models/window-functions.coffee b/src/coffee/directives/api/models/window-functions.coffee new file mode 100644 index 000000000..3b16f98fe --- /dev/null +++ b/src/coffee/directives/api/models/window-functions.coffee @@ -0,0 +1,50 @@ +### + Functions are using entireley local variables as to try and reuse functionality. + Hopefully this will work when an HTML Element is created or not for an InfoWindow. + + IE if another window-model needs to be derrived for Windows or other Window directives. +### +@module "directives.api.models", -> + @WindowFunctions = + watchShow:(scope,$http,$templateCache,$compile,gWin,showHandle,hideHandle,mapCtrl) -> + scope.$watch('show()', (newValue, oldValue) -> + if (newValue != oldValue) + if (newValue) + showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) + else + hideHandle(gWin) + else + if (newValue and !gWin.getMap()) + # If we're initially showing the marker and it's not yet visible, show it. + showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) + ,true) + + handleClick:(scope,mapCtrl,markerInstance,gWin,isIconVisibleOnClick,initialMarkerVisibility) -> + if markerInstance? + # Show the window and hide the marker on click + google.maps.event.addListener(markerInstance, 'click', -> + gWin.setPosition(markerInstance.getPosition()) + gWin.open(mapCtrl) + markerInstance.setVisible(isIconVisibleOnClick) + ) + # Set visibility of marker back to what it was before opening the window + google.maps.event.addListener(gWin, 'closeclick', -> + markerInstance.setVisible(initialMarkerVisibility) + scope.closeClick() + ) + + showWindow:(scope,$http,$templateCache,$compile,gWin,mapCtrl) -> + if scope.templateUrl + $http.get(scope.templateUrl, { cache: $templateCache }).then((content) -> + templateScope = scope.$new() + if angular.isDefined(scope.templateParameter) + templateScope.parameter = scope.templateParameter + compiled = $compile(content.data)(templateScope) + gWin.setContent(compiled.get(0)) + gWin.open(mapCtrl) + ) + else + gWin.open(mapCtrl) + + hideWindow: (gWin) -> + gWin.close() \ No newline at end of file diff --git a/src/coffee/directives/api/models/window-model.coffee b/src/coffee/directives/api/models/window-model.coffee index 578a47e0f..eaf680add 100644 --- a/src/coffee/directives/api/models/window-model.coffee +++ b/src/coffee/directives/api/models/window-model.coffee @@ -1,55 +1,6 @@ -### - Functions are taking entireley local variables as to try and reuse functionality. - Hopefully this will work when an HTML Element is created or not for an InfoWindow. -### -@module "directives.api.models", -> - @WindowModelFunctions = - watchShow:(scope,$http,$templateCache,$compile,gWin,showHandle,hideHandle,mapCtrl) -> - scope.$watch('show()', (newValue, oldValue) -> - if (newValue != oldValue) - if (newValue) - showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) - else - hideHandle(gWin) - else - if (newValue and !gWin.getMap()) - # If we're initially showing the marker and it's not yet visible, show it. - showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) - ,true) - - handleClick:(scope,mapCtrl,markerInstance,gWin,isIconVisibleOnClick,initialMarkerVisibility) -> - if markerInstance? - # Show the window and hide the marker on click - google.maps.event.addListener(markerInstance, 'click', -> - gWin.setPosition(markerInstance.getPosition()) - gWin.open(mapCtrl) - markerInstance.setVisible(isIconVisibleOnClick) - ) - # Set visibility of marker back to what it was before opening the window - google.maps.event.addListener(gWin, 'closeclick', -> - markerInstance.setVisible(initialMarkerVisibility) - scope.closeClick() - ) - - showWindow:(scope,$http,$templateCache,$compile,gWin,mapCtrl) -> - if scope.templateUrl - $http.get(scope.templateUrl, { cache: $templateCache }).then((content) -> - templateScope = scope.$new() - if angular.isDefined(scope.templateParameter) - templateScope.parameter = scope.templateParameter - compiled = $compile(content.data)(templateScope) - gWin.setContent(compiled.get(0)) - gWin.open(mapCtrl) - ) - else - gWin.open(mapCtrl) - - hideWindow: (gWin) -> - gWin.close() - @module "directives.api.models", -> class @WindowModel extends oo.BaseObject - @include directives.api.models.WindowModelFunctions + @include directives.api.models.WindowFunctions constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$log,$http,$templateCache,$compile)-> @scope = scope @opts = opts diff --git a/src/coffee/directives/api/windows.coffee b/src/coffee/directives/api/windows.coffee new file mode 100644 index 000000000..68d3e3dd9 --- /dev/null +++ b/src/coffee/directives/api/windows.coffee @@ -0,0 +1,73 @@ +### + Windows directive where many windows map to the models property +### +@module "directives.api", -> + class @Windows extends directives.api.IWindow + + constructor: ($log, $timeout, $compile, $http, $templateCache) -> + super($log, $timeout, $compile, $http, $templateCache) + self = @ + @clsName = "Windows" + @template = '' + @scope.models = '&models' #property can be fetched from parentScope, usually a marker scope + @windows = {} + @scopePropNames = ['show','coords','templateUrl','templateParameter', + 'isIconVisibleOnClick','closeClick'] + #setting up local references to propety keys IE: @coordsKey + @[name + 'Key'] = undefined for name in @scopePropNames + @$log.info(self) + #keep track of the property key name for what show() is defined for + watchShow:(scope) => + scope.$watch('show()', (newValue, oldValue) => + if (newValue != oldValue) + @showKey = newValue + #update all windows.show() bindings + ,true) + + link: (scope, element, attrs, ctrls) => + modelsNotDefined = angular.isUndefined(scope.models) or scope.models == undefined + if(modelsNotDefined) + @$log.error(@clsName + ": no valid models attribute found") + return + ### + being that we cannot tell the difference in Key String vs. a normal value string (TemplateUrl) + we will assume that all scope values are string expressions either pointing to a key (propName) or using + 'self' to point the model as container. + + This may force redundant information into the model, but this appears to be the most flexible approach. + ### + @[name + 'Key'] = scope[name] for name in @scopePropNames + @$timeout( => + + isIconVisibleOnClick = true + if angular.isDefined(attrs.isiconvisibleonclick) + isIconVisibleOnClick = scope.isIconVisibleOnClick + mapCtrl = ctrls[0].getMap() + markerCtrl = if ctrls.length > 1 and ctrls[1]? then ctrls[1].getMarker() else undefined + + if mapCtrl? #at the very least we need a Map, the marker is optional as we can create Windows without markers + for model in scope.models + do(model) => + opts = @createWindowOptions(markerCtrl,scope,element.html(),@DEFAULTS) + ### + Create ChildScope to Mimmick an ng-repeat created scope, must define the below scope + scope= { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' + } + ### + childScope = scope.$new(false) + for name in @scopePropNames + do (name) => + nameKey = name + 'Key' + childScope[name] = if @[nameKey] == 'self' then model else model[@[nameKey]] + @windows[@windowIndex] = + new directives.api.models.WindowModel( + childScope,opts,isIconVisibleOnClick,mapCtrl, + markerCtrl,@$log,@$http,@$templateCache,@$compile + ) + ,50) \ No newline at end of file From 9fbb99e6588c1ce67eb00fad1be218f5620e63d1 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 25 Jul 2013 14:22:52 -0400 Subject: [PATCH 16/41] Windows mostly working --- Gruntfile.js | 6 +- dist/angular-google-maps.js | 289 ++++++++++++++++-- dist/angular-google-maps.min.js | 4 +- example/example-controller.js | 8 + example/example.html | 36 ++- src/coffee/directives/api/i-marker.coffee | 3 +- src/coffee/directives/api/i-window.coffee | 2 +- src/coffee/directives/api/marker.coffee | 10 +- src/coffee/directives/api/markers.coffee | 15 +- .../directives/api/models/marker-model.coffee | 8 +- src/coffee/directives/api/utils/linked.coffee | 7 + src/coffee/directives/api/window.coffee | 1 + src/coffee/directives/api/windows.coffee | 122 +++++--- .../{window copy.js => window_orig.js} | 0 src/js/directives/windows.js | 45 +++ 15 files changed, 462 insertions(+), 94 deletions(-) create mode 100644 src/coffee/directives/api/utils/linked.coffee rename src/js/directives/{window copy.js => window_orig.js} (100%) create mode 100644 src/js/directives/windows.js diff --git a/Gruntfile.js b/Gruntfile.js index d8f04a912..bd3ce2514 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,7 +59,8 @@ module.exports = function(grunt) { 'src/js/directives/marker.js', 'src/js/directives/markers.js', 'src/js/directives/polyline.js', - 'src/js/directives/window.js'], + 'src/js/directives/window.js', + 'src/js/directives/windows.js'], dest: 'tmp/output.js' }, example: { @@ -69,7 +70,8 @@ module.exports = function(grunt) { 'src/js/directives/marker.js', 'src/js/directives/markers.js', 'src/js/directives/polyline.js', - 'src/js/directives/window.js'], + 'src/js/directives/window.js', + 'src/js/directives/windows.js'], dest: 'example/<%= pkg.name %>.js' } }, diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 82f2852ab..822671299 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -115,6 +115,28 @@ angular.module('google-maps', []);;(function() { }).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; }; + + this.module("directives.api.utils", function() { + return this.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; + + })(oo.BaseObject); + }); + +}).call(this); + (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -204,17 +226,15 @@ angular.module('google-maps', []);;(function() { /* - Functions are taking entireley local variables as to try and reuse functionality. + Functions are using entireley local variables as to try and reuse functionality. Hopefully this will work when an HTML Element is created or not for an InfoWindow. + + IE if another window-model needs to be derrived for Windows or other Window directives. */ (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; }; - this.module("directives.api.models", function() { - var _this = this; - return this.WindowModelFunctions = { + return this.WindowFunctions = { watchShow: function(scope, $http, $templateCache, $compile, gWin, showHandle, hideHandle, mapCtrl) { return scope.$watch('show()', function(newValue, oldValue) { if (newValue !== oldValue) { @@ -224,7 +244,7 @@ angular.module('google-maps', []);;(function() { return hideHandle(gWin); } } else { - if (newValue && !win.getMap()) { + if (newValue && !gWin.getMap()) { return showHandle(scope, $http, $templateCache, $compile, gWin, mapCtrl); } } @@ -267,11 +287,17 @@ angular.module('google-maps', []);;(function() { }; }); +}).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; }; + this.module("directives.api.models", function() { return this.WindowModel = (function(_super) { __extends(WindowModel, _super); - WindowModel.include(directives.api.models.WindowModelFunctions); + WindowModel.include(directives.api.models.WindowFunctions); function WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $log, $http, $templateCache, $compile) { this.scope = scope; @@ -491,6 +517,12 @@ angular.module('google-maps', []);;(function() { this.mapCtrl = void 0; } + Marker.prototype.controller = function($scope, $element) { + return this.getMarker = function() { + return $element.data('instance'); + }; + }; + Marker.prototype.validateLinkedScope = function(scope) { return Marker.__super__.validateLinkedScope.call(this, scope) || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude); }; @@ -585,13 +617,19 @@ not 1:1 in this setting. this.template = ''; this.clsName = "Markers"; this.scope.models = '=models'; - this.markers = {}; + this.markers = []; this.markersIndex = 0; this.mapCtrl = void 0; this.$timeout = $timeout; this.$log.info(this); } + Markers.prototype.controller = function($scope, $element) { + return this.getMarkers = function() { + return $element.data('instance'); + }; + }; + Markers.prototype.validateLinkedScope = function(scope) { var modelsNotDefined; modelsNotDefined = angular.isUndefined(scope.models) || scope.models === void 0; @@ -607,21 +645,20 @@ not 1:1 in this setting. }; Markers.prototype.createMarkers = function(element, scope, animate, doClick) { - var model, _i, _len, _ref, _results, + var model, _fn, _i, _len, _ref, _this = this; _ref = scope.models; - _results = []; + _fn = function(model) { + _this.markers.push(new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, _this.$log, function(index) { + return delete _this.markers[index]; + }, _this.DEFAULTS)); + return _this.markersIndex++; + }; for (_i = 0, _len = _ref.length; _i < _len; _i++) { model = _ref[_i]; - _results.push((function(model) { - _this.markers[_this.markersIndex] = new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, _this.$log, function(index) { - return delete _this.markers[index]; - }, _this.DEFAULTS); - _this.markersIndex++; - return element.data('instance', _this.markers); - })(model)); + _fn(model); } - return _results; + return element.data('instance', this.markers); }; Markers.prototype.watchCoords = function(scope) { @@ -714,7 +751,7 @@ not 1:1 in this setting. markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarker() : void 0; opts = _this.createWindowOptions(markerCtrl, scope, element.html(), _this.DEFAULTS); if (mapCtrl != null) { - return new directives.api.models.WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$templateCache, _this.$compile); + return new directives.api.models.WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$log, _this.$http, _this.$templateCache, _this.$compile); } }, 50); }; @@ -725,6 +762,174 @@ not 1:1 in this setting. }); }).call(this); + + +/* + Windows directive where many windows map to the models property +*/ + +(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; }; + + this.module("directives.api", function() { + return this.Windows = (function(_super) { + __extends(Windows, _super); + + function Windows($log, $timeout, $compile, $http, $templateCache) { + this.createWindow = __bind(this.createWindow, this); + this.createChildScopesWindows = __bind(this.createChildScopesWindows, this); + this.link = __bind(this.link, this); + this.watchOurScope = __bind(this.watchOurScope, this); + this.watch = __bind(this.watch, this); + var name, self, _i, _len, _ref; + Windows.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); + self = this; + this.clsName = "Windows"; + this.template = ''; + this.scope.models = '=models'; + this.windows = []; + this.windwsIndex = 0; + this.scopePropNames = ['show', 'coords', 'templateUrl', 'templateParameter', 'isIconVisibleOnClick', 'closeClick']; + _ref = this.scopePropNames; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + name = _ref[_i]; + this[name + 'Key'] = void 0; + } + this.linked = void 0; + this.models = void 0; + this.$log.info(self); + } + + Windows.prototype.watch = function(scope, name, nameKey) { + var _this = this; + return scope.$watch(name, function(newValue, oldValue) { + var model, _i, _len, _ref, _results; + if (newValue !== oldValue) { + _this[nameKey] = typeof newValue === 'function' ? newValue() : newValue; + _ref = _this.windows; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push((function(model) { + return model.scope[name] = _this[nameKey] === 'self' || _this[nameKey] === void 0 ? model : model[_this[nameKey]]; + })(model)); + } + return _results; + } + }, true); + }; + + Windows.prototype.watchOurScope = function(scope) { + var name, _i, _len, _ref, _results, + _this = this; + _ref = this.scopePropNames; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + name = _ref[_i]; + _results.push((function(name) { + var nameKey; + nameKey = name + 'Key'; + _this[nameKey] = typeof scope[name] === 'function' ? scope[name]() : scope[name]; + return _this.watch(scope, name, nameKey); + })(name)); + } + return _results; + }; + + Windows.prototype.link = function(scope, element, attrs, ctrls) { + var _this = this; + this.linked = new directives.api.utils.Linked(scope, element, attrs, ctrls); + this.watchOurScope(scope); + return this.$timeout(function() { + return _this.createChildScopesWindows(); + }, 50); + }; + + Windows.prototype.createChildScopesWindows = function() { + + /* + being that we cannot tell the difference in Key String vs. a normal value string (TemplateUrl) + we will assume that all scope values are string expressions either pointing to a key (propName) or using + 'self' to point the model as container/object of interest. + + This may force redundant information into the model, but this appears to be the most flexible approach. + */ + var gMap, isIconVisibleOnClick, markerModels, mm, model, modelsNotDefined, _i, _j, _len, _len1, _ref, _results, _results1, + _this = this; + isIconVisibleOnClick = true; + if (angular.isDefined(this.linked.attrs.isiconvisibleonclick)) { + isIconVisibleOnClick = this.linked.scope.isIconVisibleOnClick; + } + gMap = this.linked.ctrls[0].getMap(); + markerModels = this.linked.ctrls.length > 1 && (this.linked.ctrls[1] != null) ? this.linked.ctrls[1].getMarkers() : void 0; + modelsNotDefined = angular.isUndefined(this.linked.scope.models) || scope.models === void 0; + if (modelsNotDefined && (markerModels != null)) { + this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"); + return; + } + if (gMap != null) { + if (this.linked.scope.models != null) { + this.models = this.linked.scope.models; + _ref = this.linked.scope.models; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push(this.createWindow(model, void 0, gMap)); + } + return _results; + } else { + this.models = []; + _results1 = []; + for (_j = 0, _len1 = markerModels.length; _j < _len1; _j++) { + mm = markerModels[_j]; + _results1.push((function(mm) { + _this.models.push(mm.model); + return _this.createWindow(mm.model, mm.gMarker, gMap); + })(mm)); + } + return _results1; + } + } + }; + + Windows.prototype.createWindow = function(model, gMarker, gMap) { + + /* + Create ChildScope to Mimmick an ng-repeat created scope, must define the below scope + scope= { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' + } + */ + var childScope, name, opts, _fn, _i, _len, _ref, + _this = this; + childScope = this.linked.scope.$new(false); + _ref = this.scopePropNames; + _fn = function(name) { + var nameKey; + nameKey = name + 'Key'; + return childScope[name] = _this[nameKey] === 'self' || _this[nameKey] === void 0 ? model : model[_this[nameKey]]; + }; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + name = _ref[_i]; + _fn(name); + } + opts = this.createWindowOptions(gMarker, childScope, this.linked.element.html(), this.DEFAULTS); + return this.windows.push(new directives.api.models.WindowModel(childScope, opts, isIconVisibleOnClick, gMap, gMarker, this.$log, this.$http, this.$templateCache, this.$compile)); + }; + + return Windows; + + })(directives.api.IWindow); + }); + +}).call(this); ;/**! * The MIT License * @@ -1286,4 +1491,48 @@ angular.module("google-maps") angular.module("google-maps").directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { return new directives.api.Window($log, $timeout, $compile, $http, $templateCache); + }]);;/**! + * The MIT License + * + * Copyright (c) 2010-2012 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://plus.google.com/112199819969944829348 + */ + +/** + * Map info window directive + * + * This directive is used to create an info window on an existing map. + * This directive creates a new scope. + * + * {attribute coords required} object containing latitude and longitude properties + * {attribute show optional} map will show when this expression returns true + */ + +angular.module("google-maps").directive("windows", ['$log', '$timeout','$compile', '$http', '$templateCache', + function ($log, $timeout, $compile, $http, $templateCache) { + return new directives.api.Windows($log, $timeout, $compile, $http, $templateCache); }]); \ No newline at end of file diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 99379b4f7..3f069e25f 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -1,5 +1,5 @@ -/*! angular-google-maps 0.0.0 2013-07-24 +/*! angular-google-maps 0.0.0 2013-07-25 * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModelFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!win.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}}),this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowModelFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers={},this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(f=b.models,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(function(c){return h.markers[h.markersIndex]=new directives.api.models.MarkerModel(h.markersIndex,c,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS),h.markersIndex++,a.data("instance",h.markers)}(c));return g},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarkers=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(g=b.models,d=function(a){return h.markers.push(new directives.api.models.MarkerModel(h.markersIndex,a,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS)),h.markersIndex++},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.data("instance",this.markers)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(b=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&null!=c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bangular-google-maps example draggable="true" dragging="map.dragging" events="map.events"> - + + - + - + - +
@@ -104,6 +104,22 @@

angular-google-maps example

+ + markers2 + + + + center
 {{ map.center.latitude | number:4 }} lat
 {{ map.center.longitude | number:4 }} lng
diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index 726fd3616..9c1236506 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -34,8 +34,7 @@ } controller: ($scope, $element) -> - @getMarker = -> - $element.data('instance') + throw new Exception("Not Implemented!!") validateLinkedScope:(scope)=> ret = angular.isUndefined(scope.coords) or diff --git a/src/coffee/directives/api/i-window.coffee b/src/coffee/directives/api/i-window.coffee index 3af5600fe..56064f6d7 100644 --- a/src/coffee/directives/api/i-window.coffee +++ b/src/coffee/directives/api/i-window.coffee @@ -14,7 +14,7 @@ @template= undefined @transclude= true @priority= -100 - @require= ['^googleMap', '^?marker'] + @require = undefined @scope= { coords: '=coords', show: '&show', diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index a6153ecf5..9170869d9 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -16,6 +16,9 @@ @mapCtrl = undefined + controller:($scope, $element) -> + @getMarker = -> + $element.data('instance') validateLinkedScope:(scope)=> super(scope) or angular.isUndefined(scope.coords.latitude) or angular.isUndefined(scope.coords.longitude) @@ -27,10 +30,11 @@ opts = @createMarkerOptions(mapCtrl,scope.coords,scope.icon,animate,@DEFAULTS) #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the index) - @markers[scope.$id] = new google.maps.Marker(opts) - element.data('instance', @markers[scope.$id]) + gMarker = new google.maps.Marker(opts) + @markers[scope.$id] = gMarker + element.data('instance', gMarker) - google.maps.event.addListener(@markers[scope.$id], 'click', -> + google.maps.event.addListener(gMarker, 'click', -> if doClick and scope.click? scope.click() ) diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index de7351d64..c9d4bb653 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -17,12 +17,16 @@ not 1:1 in this setting. @template = '' @clsName = "Markers" @scope.models = '=models' - @markers = {} + @markers = [] @markersIndex = 0 @mapCtrl = undefined @$timeout = $timeout @$log.info(@) + controller:($scope, $element) -> + @getMarkers = -> + $scope.markers + validateLinkedScope:(scope)=> modelsNotDefined = angular.isUndefined(scope.models) or scope.models == undefined if(modelsNotDefined) @@ -38,13 +42,14 @@ not 1:1 in this setting. createMarkers:(element,scope,animate,doClick) => for model in scope.models do(model) => - @markers[@markersIndex] = + @markers.push( new directives.api.models.MarkerModel(@markersIndex,model,scope,@mapCtrl,@$timeout,@$log, (index) => delete @markers[index] - ,@DEFAULTS) - + ,@DEFAULTS,doClick) + ) @markersIndex++ - element.data('instance', @markers) + #put MarkerModels into local scope + scope.markers = @markers watchCoords:(scope) => scope.$watch('coords', (newValue, oldValue) => diff --git a/src/coffee/directives/api/models/marker-model.coffee b/src/coffee/directives/api/models/marker-model.coffee index 2bf2edeb6..351d5360f 100644 --- a/src/coffee/directives/api/models/marker-model.coffee +++ b/src/coffee/directives/api/models/marker-model.coffee @@ -1,8 +1,9 @@ @module "directives.api.models", -> class @MarkerModel extends oo.BaseObject @include directives.api.utils.GmapUtil - constructor:(index,model,parentScope,mapCtrl,$timeout,$log,notifyLocalDestroy,defaults)-> + constructor:(index,model,parentScope,mapCtrl,$timeout,$log,notifyLocalDestroy,defaults,doClick)-> @index = index + @model = model @iconKey = parentScope.icon @coordsKey = parentScope.coords @myScope = parentScope.$new(false) @@ -11,9 +12,10 @@ @mapCtrl = mapCtrl @opts = @createMarkerOptions(@mapCtrl,@myScope.coords,@myScope.icon,defaults) @gMarker = new google.maps.Marker(@opts) - google.maps.event.addListener(@gMarker, 'click', -> + @doClick = doClick + google.maps.event.addListener(@gMarker, 'click', => #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ - if doClick and @myScope.click? + if @doClick and @myScope.click? @myScope.click() ) $timeout( => diff --git a/src/coffee/directives/api/utils/linked.coffee b/src/coffee/directives/api/utils/linked.coffee new file mode 100644 index 000000000..d840d3aab --- /dev/null +++ b/src/coffee/directives/api/utils/linked.coffee @@ -0,0 +1,7 @@ +@module "directives.api.utils", -> + class @Linked extends oo.BaseObject + constructor:(scope, element, attrs, ctrls)-> + @scope = scope + @element = element + @attrs = attrs + @ctrls = ctrls \ No newline at end of file diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee index cce2ae8cd..2c34e6498 100644 --- a/src/coffee/directives/api/window.coffee +++ b/src/coffee/directives/api/window.coffee @@ -9,6 +9,7 @@ super($log, $timeout, $compile, $http, $templateCache) self = @ @clsName = "Window" + @require= ['^googleMap', '^?marker'] @template = '' @$log.info(self) diff --git a/src/coffee/directives/api/windows.coffee b/src/coffee/directives/api/windows.coffee index 68d3e3dd9..edbd04a5e 100644 --- a/src/coffee/directives/api/windows.coffee +++ b/src/coffee/directives/api/windows.coffee @@ -8,66 +8,96 @@ super($log, $timeout, $compile, $http, $templateCache) self = @ @clsName = "Windows" + @require= ['^googleMap', '^?markers'] @template = '' - @scope.models = '&models' #property can be fetched from parentScope, usually a marker scope - @windows = {} + @scope.models = '=models' #if undefined it will try get a markers models + @windows = [] + @windwsIndex = 0 @scopePropNames = ['show','coords','templateUrl','templateParameter', 'isIconVisibleOnClick','closeClick'] #setting up local references to propety keys IE: @coordsKey @[name + 'Key'] = undefined for name in @scopePropNames + @linked = undefined + @models = undefined + @isIconVisibleOnClick = undefined @$log.info(self) - #keep track of the property key name for what show() is defined for - watchShow:(scope) => - scope.$watch('show()', (newValue, oldValue) => + + #watch this scope(Parent to all WindowModels), these updates reflect expression / Key changes + #thus they need to be pushed to all the children models so that they are bound to the correct objects / keys + watch:(scope,name,nameKey) => + scope.$watch(name, (newValue, oldValue) => if (newValue != oldValue) - @showKey = newValue - #update all windows.show() bindings + @[nameKey] = if typeof newValue == 'function' then newValue() else newValue + for model in @windows + do(model) => + model.scope[name] = if (@[nameKey] == 'self' or @[nameKey] == undefined) then model else model[@[nameKey]] ,true) + watchOurScope:(scope) => + for name in @scopePropNames + do(name) => + nameKey = name + 'Key' + @[nameKey] = if typeof scope[name] == 'function' then scope[name]() else scope[name] + @watch(scope,name,nameKey) + link: (scope, element, attrs, ctrls) => - modelsNotDefined = angular.isUndefined(scope.models) or scope.models == undefined - if(modelsNotDefined) - @$log.error(@clsName + ": no valid models attribute found") - return + @linked = new directives.api.utils.Linked(scope,element,attrs,ctrls) + @watchOurScope(scope) + @$timeout( => + @createChildScopesWindows() + ,50) + + createChildScopesWindows: => ### being that we cannot tell the difference in Key String vs. a normal value string (TemplateUrl) we will assume that all scope values are string expressions either pointing to a key (propName) or using - 'self' to point the model as container. + 'self' to point the model as container/object of interest. This may force redundant information into the model, but this appears to be the most flexible approach. ### - @[name + 'Key'] = scope[name] for name in @scopePropNames - @$timeout( => + @isIconVisibleOnClick = true + if angular.isDefined(@linked.attrs.isiconvisibleonclick) + isIconVisibleOnClick = @linked.scope.isIconVisibleOnClick + gMap = @linked.ctrls[0].getMap() + markerModels = if @linked.ctrls.length > 1 and @linked.ctrls[1]? then @linked.ctrls[1].getMarkers() else undefined - isIconVisibleOnClick = true - if angular.isDefined(attrs.isiconvisibleonclick) - isIconVisibleOnClick = scope.isIconVisibleOnClick - mapCtrl = ctrls[0].getMap() - markerCtrl = if ctrls.length > 1 and ctrls[1]? then ctrls[1].getMarker() else undefined - - if mapCtrl? #at the very least we need a Map, the marker is optional as we can create Windows without markers - for model in scope.models - do(model) => - opts = @createWindowOptions(markerCtrl,scope,element.html(),@DEFAULTS) - ### - Create ChildScope to Mimmick an ng-repeat created scope, must define the below scope - scope= { - coords: '=coords', - show: '&show', - templateUrl: '=templateurl', - templateParameter: '=templateparameter', - isIconVisibleOnClick: '=isiconvisibleonclick', - closeClick: '&closeclick' - } - ### - childScope = scope.$new(false) - for name in @scopePropNames - do (name) => - nameKey = name + 'Key' - childScope[name] = if @[nameKey] == 'self' then model else model[@[nameKey]] - @windows[@windowIndex] = - new directives.api.models.WindowModel( - childScope,opts,isIconVisibleOnClick,mapCtrl, - markerCtrl,@$log,@$http,@$templateCache,@$compile - ) - ,50) \ No newline at end of file + modelsNotDefined = angular.isUndefined(@linked.scope.models) or scope.models == undefined + + if(modelsNotDefined and markerModels == undefined) + @$log.info("No models to create windows from! Need direct models or models derrived from markers!") + return + if gMap? + #at the very least we need a Map, the marker is optional as we can create Windows without markers + if @linked.scope.models? + #we are creating windows with no markers + @models = @linked.scope.models + @createWindow(model,undefined,gMap) for model in @linked.scope.models + else + #creating windows with parent markers + @models = [] + for mm in markerModels + do(mm) => + @models.push(mm.model) + @createWindow(mm.model,mm.gMarker,gMap) + + createWindow: (model,gMarker,gMap)=> + ### + Create ChildScope to Mimmick an ng-repeat created scope, must define the below scope + scope= { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' + } + ### + childScope = @linked.scope.$new(false) + for name in @scopePropNames + do (name) => + nameKey = name + 'Key' + childScope[name] = if (@[nameKey] == 'self' or @[nameKey] == undefined) then model else model[@[nameKey]] + opts = @createWindowOptions(gMarker,childScope,@linked.element.html(),@DEFAULTS) + @windows.push( + new directives.api.models.WindowModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$log,@$http,@$templateCache,@$compile) + ) \ No newline at end of file diff --git a/src/js/directives/window copy.js b/src/js/directives/window_orig.js similarity index 100% rename from src/js/directives/window copy.js rename to src/js/directives/window_orig.js diff --git a/src/js/directives/windows.js b/src/js/directives/windows.js new file mode 100644 index 000000000..cfe4aa61e --- /dev/null +++ b/src/js/directives/windows.js @@ -0,0 +1,45 @@ +/**! + * The MIT License + * + * Copyright (c) 2010-2012 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://plus.google.com/112199819969944829348 + */ + +/** + * Map info window directive + * + * This directive is used to create an info window on an existing map. + * This directive creates a new scope. + * + * {attribute coords required} object containing latitude and longitude properties + * {attribute show optional} map will show when this expression returns true + */ + +angular.module("google-maps").directive("windows", ['$log', '$timeout','$compile', '$http', '$templateCache', + function ($log, $timeout, $compile, $http, $templateCache) { + return new directives.api.Windows($log, $timeout, $compile, $http, $templateCache); + }]); \ No newline at end of file From 6b843b79b65520b23975caf8de91ae22fc16fdf4 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 25 Jul 2013 15:02:22 -0400 Subject: [PATCH 17/41] watching models for dynamic updates to recreate markers on the map --- dist/angular-google-maps.js | 68 +++++++++++++++++------- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/markers.coffee | 23 ++++++-- 3 files changed, 70 insertions(+), 23 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 822671299..f5b03c8a1 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -148,13 +148,14 @@ angular.module('google-maps', []);;(function() { MarkerModel.include(directives.api.utils.GmapUtil); - function MarkerModel(index, model, parentScope, mapCtrl, $timeout, $log, notifyLocalDestroy, defaults) { + function MarkerModel(index, model, parentScope, mapCtrl, $timeout, $log, notifyLocalDestroy, defaults, doClick) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); this.destroy = __bind(this.destroy, this); var _this = this; this.index = index; + this.model = model; this.iconKey = parentScope.icon; this.coordsKey = parentScope.coords; this.myScope = parentScope.$new(false); @@ -163,9 +164,10 @@ angular.module('google-maps', []);;(function() { this.mapCtrl = mapCtrl; this.opts = this.createMarkerOptions(this.mapCtrl, this.myScope.coords, this.myScope.icon, defaults); this.gMarker = new google.maps.Marker(this.opts); + this.doClick = doClick; google.maps.event.addListener(this.gMarker, 'click', function() { - if (doClick && (this.myScope.click != null)) { - return this.myScope.click(); + if (_this.doClick && (_this.myScope.click != null)) { + return _this.myScope.click(); } }); $timeout(function() { @@ -378,9 +380,7 @@ angular.module('google-maps', []);;(function() { } IMarker.prototype.controller = function($scope, $element) { - return this.getMarker = function() { - return $element.data('instance'); - }; + throw new Exception("Not Implemented!!"); }; IMarker.prototype.validateLinkedScope = function(scope) { @@ -457,7 +457,7 @@ angular.module('google-maps', []);;(function() { this.template = void 0; this.transclude = true; this.priority = -100; - this.require = ['^googleMap', '^?marker']; + this.require = void 0; this.scope = { coords: '=coords', show: '&show', @@ -528,12 +528,13 @@ angular.module('google-maps', []);;(function() { }; Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { - var opts; + var gMarker, opts; this.mapCtrl = mapCtrl; opts = this.createMarkerOptions(mapCtrl, scope.coords, scope.icon, animate, this.DEFAULTS); - this.markers[scope.$id] = new google.maps.Marker(opts); - element.data('instance', this.markers[scope.$id]); - return google.maps.event.addListener(this.markers[scope.$id], 'click', function() { + gMarker = new google.maps.Marker(opts); + this.markers[scope.$id] = gMarker; + element.data('instance', gMarker); + return google.maps.event.addListener(gMarker, 'click', function() { if (doClick && (scope.click != null)) { return scope.click(); } @@ -608,6 +609,7 @@ not 1:1 in this setting. this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); + this.watchModels = __bind(this.watchModels, this); this.createMarkers = __bind(this.createMarkers, this); this.linkInit = __bind(this.linkInit, this); this.validateLinkedScope = __bind(this.validateLinkedScope, this); @@ -621,12 +623,14 @@ not 1:1 in this setting. this.markersIndex = 0; this.mapCtrl = void 0; this.$timeout = $timeout; + this.doClick = void 0; + this.animate = void 0; this.$log.info(this); } Markers.prototype.controller = function($scope, $element) { return this.getMarkers = function() { - return $element.data('instance'); + return $scope.markers; }; }; @@ -641,24 +645,47 @@ not 1:1 in this setting. Markers.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { this.mapCtrl = mapCtrl; - return this.createMarkers(element, scope, animate, doClick); + this.doClick = doClick; + this.animate = animate; + return this.createMarkers(element, scope, animate); }; - Markers.prototype.createMarkers = function(element, scope, animate, doClick) { + Markers.prototype.createMarkers = function(scope) { var model, _fn, _i, _len, _ref, _this = this; _ref = scope.models; _fn = function(model) { _this.markers.push(new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, _this.$log, function(index) { return delete _this.markers[index]; - }, _this.DEFAULTS)); + }, _this.DEFAULTS, _this.doClick)); return _this.markersIndex++; }; for (_i = 0, _len = _ref.length; _i < _len; _i++) { model = _ref[_i]; _fn(model); } - return element.data('instance', this.markers); + return scope.markers = this.markers; + }; + + Markers.prototype.watchModels = function(scope) { + var _this = this; + return scope.$watch('models', function(newValue, oldValue) { + var oldM, _fn, _i, _len, _ref; + if (newValue !== oldValue) { + _ref = _this.markers; + _fn = function(oldM) { + return oldM.destroy(); + }; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + oldM = _ref[_i]; + _fn(oldM); + } + delete _this.markers; + _this.markers = []; + _this.markersIndex = 0; + return _this.createMarkers(scope); + } + }, true); }; Markers.prototype.watchCoords = function(scope) { @@ -735,6 +762,7 @@ not 1:1 in this setting. Window.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); self = this; this.clsName = "Window"; + this.require = ['^googleMap', '^?marker']; this.template = ''; this.$log.info(self); } @@ -787,6 +815,7 @@ not 1:1 in this setting. Windows.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); self = this; this.clsName = "Windows"; + this.require = ['^googleMap', '^?markers']; this.template = ''; this.scope.models = '=models'; this.windows = []; @@ -799,6 +828,7 @@ not 1:1 in this setting. } this.linked = void 0; this.models = void 0; + this.isIconVisibleOnClick = void 0; this.$log.info(self); } @@ -858,14 +888,14 @@ not 1:1 in this setting. */ var gMap, isIconVisibleOnClick, markerModels, mm, model, modelsNotDefined, _i, _j, _len, _len1, _ref, _results, _results1, _this = this; - isIconVisibleOnClick = true; + this.isIconVisibleOnClick = true; if (angular.isDefined(this.linked.attrs.isiconvisibleonclick)) { isIconVisibleOnClick = this.linked.scope.isIconVisibleOnClick; } gMap = this.linked.ctrls[0].getMap(); markerModels = this.linked.ctrls.length > 1 && (this.linked.ctrls[1] != null) ? this.linked.ctrls[1].getMarkers() : void 0; modelsNotDefined = angular.isUndefined(this.linked.scope.models) || scope.models === void 0; - if (modelsNotDefined && (markerModels != null)) { + if (modelsNotDefined && markerModels === void 0) { this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"); return; } @@ -921,7 +951,7 @@ not 1:1 in this setting. _fn(name); } opts = this.createWindowOptions(gMarker, childScope, this.linked.element.html(), this.DEFAULTS); - return this.windows.push(new directives.api.models.WindowModel(childScope, opts, isIconVisibleOnClick, gMap, gMarker, this.$log, this.$http, this.$templateCache, this.$compile)); + return this.windows.push(new directives.api.models.WindowModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$log, this.$http, this.$templateCache, this.$compile)); }; return Windows; diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 3f069e25f..a9eea4b2f 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),google.maps.event.addListener(this.gMarker,"click",function(){return doClick&&null!=this.myScope.click?this.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=["^googleMap","^?marker"],this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f;return this.mapCtrl=b,f=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),this.markers[c.$id]=new google.maps.Marker(f),a.data("instance",this.markers[c.$id]),google.maps.event.addListener(this.markers[c.$id],"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarkers=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.createMarkers(a,c,d,e)},d.prototype.createMarkers=function(a,b){var c,d,e,f,g,h=this;for(g=b.models,d=function(a){return h.markers.push(new directives.api.models.MarkerModel(h.markersIndex,a,b,h.mapCtrl,h.$timeout,h.$log,function(a){return delete h.markers[a]},h.DEFAULTS)),h.markersIndex++},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.data("instance",this.markers)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(b=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&null!=c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkers=function(){return a.markers}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.createMarkers(a,c,d)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&void 0===c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b @@ -37,20 +39,35 @@ not 1:1 in this setting. # if we have made it here all attributes are valid so we can initialize and glue things together linkInit:(element,mapCtrl,scope,animate,doClick) => @mapCtrl = mapCtrl - @createMarkers(element,scope,animate,doClick) + @doClick = doClick + @animate = animate + @createMarkers(scope) - createMarkers:(element,scope,animate,doClick) => + createMarkers:(scope) => for model in scope.models do(model) => @markers.push( new directives.api.models.MarkerModel(@markersIndex,model,scope,@mapCtrl,@$timeout,@$log, (index) => delete @markers[index] - ,@DEFAULTS,doClick) + ,@DEFAULTS,@doClick) ) @markersIndex++ #put MarkerModels into local scope scope.markers = @markers + watchModels:(scope) => + scope.$watch('models', (newValue, oldValue) => + if (newValue != oldValue) + for oldM in @markers + do(oldM) => + oldM.destroy() + delete @markers + @markers = [] + @markersIndex = 0 + @createMarkers(scope) + + , true) + watchCoords:(scope) => scope.$watch('coords', (newValue, oldValue) => if (newValue != oldValue) From bc14e1129a78bf7f8da7337c935b7dc86157a7d8 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 25 Jul 2013 15:06:16 -0400 Subject: [PATCH 18/41] actually call watchModels --- dist/angular-google-maps.js | 3 ++- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/markers.coffee | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index f5b03c8a1..acd6bf654 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -647,7 +647,8 @@ not 1:1 in this setting. this.mapCtrl = mapCtrl; this.doClick = doClick; this.animate = animate; - return this.createMarkers(element, scope, animate); + this.watchModels(scope); + return this.createMarkers(scope); }; Markers.prototype.createMarkers = function(scope) { diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index a9eea4b2f..6dbc13f08 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkers=function(){return a.markers}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.createMarkers(a,c,d)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&void 0===c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkers=function(){return a.markers}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&void 0===c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b From 47a4c4c8411f02e40bfc969fd52465b1873b3c73 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 25 Jul 2013 15:15:41 -0400 Subject: [PATCH 19/41] renamed mapCtrl to gMap and removed all gmap that were supposed to be gMarker --- dist/angular-google-maps.js | 26 +++++++++---------- dist/angular-google-maps.min.js | 2 +- .../directives/api/models/marker-model.coffee | 26 +++++++++---------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index acd6bf654..6d83707d8 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -148,7 +148,7 @@ angular.module('google-maps', []);;(function() { MarkerModel.include(directives.api.utils.GmapUtil); - function MarkerModel(index, model, parentScope, mapCtrl, $timeout, $log, notifyLocalDestroy, defaults, doClick) { + function MarkerModel(index, model, parentScope, gMap, $timeout, $log, notifyLocalDestroy, defaults, doClick) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); @@ -161,8 +161,8 @@ angular.module('google-maps', []);;(function() { this.myScope = parentScope.$new(false); this.myScope.icon = this.iconKey === 'self' ? model : model[this.iconKey]; this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; - this.mapCtrl = mapCtrl; - this.opts = this.createMarkerOptions(this.mapCtrl, this.myScope.coords, this.myScope.icon, defaults); + this.gMap = gMap; + this.opts = this.createMarkerOptions(this.gMap, this.myScope.coords, this.myScope.icon, defaults); this.gMarker = new google.maps.Marker(this.opts); this.doClick = doClick; google.maps.event.addListener(this.gMarker, 'click', function() { @@ -186,11 +186,11 @@ angular.module('google-maps', []);;(function() { return scope.$watch('coords', function(newValue, oldValue) { if (newValue !== oldValue) { if (newValue) { - _this.gmap.setMap(_this.mapCtrl.getMap()); - _this.gmap.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - return _this.gmap.setVisible((newValue.latitude != null) && (newValue.longitude != null)); + _this.gMarker.setMap(_this.gMap.getMap()); + _this.gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + return _this.gMarker.setVisible((newValue.latitude != null) && (newValue.longitude != null)); } else { - return _this.gmap.setMap(void 0); + return _this.gMarker.setMap(void 0); } } }, true); @@ -200,11 +200,11 @@ angular.module('google-maps', []);;(function() { var _this = this; return scope.$watch('icon', function(newValue, oldValue) { if (newValue !== oldValue) { - _this.gmap.icon = newValue; - _this.gmap.setMap(void 0); - _this.gmap.setMap(_this.mapCtrl.getMap()); - _this.gmap.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); - return _this.gmap.setVisible(coords.latitude && (coords.longitude != null)); + _this.gMarker.icon = newValue; + _this.gMarker.setMap(void 0); + _this.gMarker.setMap(_this.gMap.getMap()); + _this.gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); + return _this.gMarker.setVisible(coords.latitude && (coords.longitude != null)); } }, true); }; @@ -212,7 +212,7 @@ angular.module('google-maps', []);;(function() { MarkerModel.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { - _this.gmap.setMap(null); + _this.gMarker.setMap(null); if (typeof notifyLocalDestroy !== "undefined" && notifyLocalDestroy !== null) { return notifyLocalDestroy(_this.index); } diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 6dbc13f08..c8746847a 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.mapCtrl=e,this.opts=this.createMarkerOptions(this.mapCtrl,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gmap.setVisible(null!=a.latitude&&null!=a.longitude)):b.gmap.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gmap.icon=a,b.gmap.setMap(void 0),b.gmap.setMap(b.mapCtrl.getMap()),b.gmap.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gmap.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gmap.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkers=function(){return a.markers}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&void 0===c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkers=function(){return a.markers}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&void 0===c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b class @MarkerModel extends oo.BaseObject @include directives.api.utils.GmapUtil - constructor:(index,model,parentScope,mapCtrl,$timeout,$log,notifyLocalDestroy,defaults,doClick)-> + constructor:(index,model,parentScope,gMap,$timeout,$log,notifyLocalDestroy,defaults,doClick)-> @index = index @model = model @iconKey = parentScope.icon @@ -9,8 +9,8 @@ @myScope = parentScope.$new(false) @myScope.icon = if @iconKey == 'self' then model else model[@iconKey] @myScope.coords = if @coordsKey == 'self' then model else model[@coordsKey] - @mapCtrl = mapCtrl - @opts = @createMarkerOptions(@mapCtrl,@myScope.coords,@myScope.icon,defaults) + @gMap = gMap + @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,defaults) @gMarker = new google.maps.Marker(@opts) @doClick = doClick google.maps.event.addListener(@gMarker, 'click', => @@ -30,26 +30,26 @@ scope.$watch('coords', (newValue, oldValue) => if (newValue != oldValue) if (newValue) - @gmap.setMap(@mapCtrl.getMap()) - @gmap.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - @gmap.setVisible(newValue.latitude? and newValue.longitude?) + @gMarker.setMap(@gMap.getMap()) + @gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + @gMarker.setVisible(newValue.latitude? and newValue.longitude?) else # Remove marker - @gmap.setMap(undefined) + @gMarker.setMap(undefined) , true) watchIcon:(scope) => scope.$watch('icon', (newValue, oldValue) => if (newValue != oldValue) - @gmap.icon = newValue - @gmap.setMap(undefined) - @gmap.setMap(@mapCtrl.getMap()) - @gmap.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) - @gmap.setVisible(coords.latitude and coords.longitude?) + @gMarker.icon = newValue + @gMarker.setMap(undefined) + @gMarker.setMap(@gMap.getMap()) + @gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) + @gMarker.setVisible(coords.latitude and coords.longitude?) , true) watchDestroy:(scope)=> scope.$on("$destroy", => - @gmap.setMap(null) + @gMarker.setMap(null) notifyLocalDestroy(@index) if notifyLocalDestroy? ) \ No newline at end of file From 792d77d1ccda4ae4646d10c30dcc12d3fb229b1a Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 25 Jul 2013 16:05:17 -0400 Subject: [PATCH 20/41] controller communication between Markers and Windows now hands Markers scope. This way Windows can listen in on Markers models to know when to clear its models. --- dist/angular-google-maps.js | 61 +++++++++++++++++------- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/markers.coffee | 6 +-- src/coffee/directives/api/windows.coffee | 32 ++++++++++--- 4 files changed, 73 insertions(+), 28 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 6d83707d8..5bc493d8b 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -629,8 +629,8 @@ not 1:1 in this setting. } Markers.prototype.controller = function($scope, $element) { - return this.getMarkers = function() { - return $scope.markers; + return this.getMarkersScope = function() { + return $scope; }; }; @@ -811,6 +811,7 @@ not 1:1 in this setting. this.createChildScopesWindows = __bind(this.createChildScopesWindows, this); this.link = __bind(this.link, this); this.watchOurScope = __bind(this.watchOurScope, this); + this.watchModels = __bind(this.watchModels, this); this.watch = __bind(this.watch, this); var name, self, _i, _len, _ref; Windows.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); @@ -830,6 +831,7 @@ not 1:1 in this setting. this.linked = void 0; this.models = void 0; this.isIconVisibleOnClick = void 0; + this.firstTime = true; this.$log.info(self); } @@ -852,6 +854,27 @@ not 1:1 in this setting. }, true); }; + Windows.prototype.watchModels = function(scope) { + var _this = this; + return scope.$watch('models', function(newValue, oldValue) { + var oldW, _fn, _i, _len, _ref; + if (newValue !== oldValue) { + _ref = _this.windows; + _fn = function(oldM) { + return oldW.destroy(); + }; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + oldW = _ref[_i]; + _fn(oldM); + } + delete _this.windows; + _this.windows = []; + _this.windowsIndex = 0; + return _this.createChildScopesWindows(); + } + }, true); + }; + Windows.prototype.watchOurScope = function(scope) { var name, _i, _len, _ref, _results, _this = this; @@ -887,42 +910,46 @@ not 1:1 in this setting. This may force redundant information into the model, but this appears to be the most flexible approach. */ - var gMap, isIconVisibleOnClick, markerModels, mm, model, modelsNotDefined, _i, _j, _len, _len1, _ref, _results, _results1, + var gMap, isIconVisibleOnClick, markersScope, mm, model, modelsNotDefined, _fn, _i, _j, _len, _len1, _ref, _ref1, _this = this; this.isIconVisibleOnClick = true; if (angular.isDefined(this.linked.attrs.isiconvisibleonclick)) { isIconVisibleOnClick = this.linked.scope.isIconVisibleOnClick; } gMap = this.linked.ctrls[0].getMap(); - markerModels = this.linked.ctrls.length > 1 && (this.linked.ctrls[1] != null) ? this.linked.ctrls[1].getMarkers() : void 0; + markersScope = this.linked.ctrls.length > 1 && (this.linked.ctrls[1] != null) ? this.linked.ctrls[1].getMarkersScope() : void 0; modelsNotDefined = angular.isUndefined(this.linked.scope.models) || scope.models === void 0; - if (modelsNotDefined && markerModels === void 0) { + if (modelsNotDefined && (markersScope === void 0 || markersScope.markers === void 0 || markersScope.models === void 0)) { this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"); return; } if (gMap != null) { if (this.linked.scope.models != null) { this.models = this.linked.scope.models; + if (this.firstTime) { + this.watchModels(this.linked.scope); + } _ref = this.linked.scope.models; - _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { model = _ref[_i]; - _results.push(this.createWindow(model, void 0, gMap)); + this.createWindow(model, void 0, gMap); } - return _results; } else { - this.models = []; - _results1 = []; - for (_j = 0, _len1 = markerModels.length; _j < _len1; _j++) { - mm = markerModels[_j]; - _results1.push((function(mm) { - _this.models.push(mm.model); - return _this.createWindow(mm.model, mm.gMarker, gMap); - })(mm)); + this.models = markersScope.models; + if (this.firstTime) { + this.watchModels(markersScope); + } + _ref1 = markersScope.markerModels; + _fn = function(mm) { + return _this.createWindow(mm.model, mm.gMarker, gMap); + }; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + mm = _ref1[_j]; + _fn(mm); } - return _results1; } } + return this.firstTime = false; }; Windows.prototype.createWindow = function(model, gMarker, gMap) { diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index c8746847a..ade162028 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkers=function(){return a.markers}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkers():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&void 0===c)return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a){if(null!=this.linked.scope.models){for(this.models=this.linked.scope.models,k=this.linked.scope.models,l=[],g=0,i=k.length;i>g;g++)e=k[g],l.push(this.createWindow(e,void 0,a));return l}for(this.models=[],m=[],h=0,j=c.length;j>h;h++)d=c[h],m.push(function(b){return n.models.push(b.model),n.createWindow(b.model,b.gMarker,a)}(d));return m}},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(){return d.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(oldM);return delete b.windows,b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markers||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&this.watchModels(this.linked.scope),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&this.watchModels(c),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b - @getMarkers = -> - $scope.markers + @getMarkersScope = -> + $scope validateLinkedScope:(scope)=> modelsNotDefined = angular.isUndefined(scope.models) or scope.models == undefined @@ -54,7 +54,7 @@ not 1:1 in this setting. ) @markersIndex++ #put MarkerModels into local scope - scope.markers = @markers + scope.markerModels = @markers watchModels:(scope) => scope.$watch('models', (newValue, oldValue) => diff --git a/src/coffee/directives/api/windows.coffee b/src/coffee/directives/api/windows.coffee index edbd04a5e..716357759 100644 --- a/src/coffee/directives/api/windows.coffee +++ b/src/coffee/directives/api/windows.coffee @@ -20,6 +20,7 @@ @linked = undefined @models = undefined @isIconVisibleOnClick = undefined + @firstTime = true @$log.info(self) #watch this scope(Parent to all WindowModels), these updates reflect expression / Key changes @@ -33,13 +34,26 @@ model.scope[name] = if (@[nameKey] == 'self' or @[nameKey] == undefined) then model else model[@[nameKey]] ,true) + watchModels:(scope) => + scope.$watch('models', (newValue, oldValue) => + if (newValue != oldValue) + for oldW in @windows + do(oldM) => + oldW.destroy() + delete @windows + @windows = [] + @windowsIndex = 0 + @createChildScopesWindows() + + , true) + watchOurScope:(scope) => for name in @scopePropNames do(name) => nameKey = name + 'Key' @[nameKey] = if typeof scope[name] == 'function' then scope[name]() else scope[name] @watch(scope,name,nameKey) - + link: (scope, element, attrs, ctrls) => @linked = new directives.api.utils.Linked(scope,element,attrs,ctrls) @watchOurScope(scope) @@ -59,11 +73,11 @@ if angular.isDefined(@linked.attrs.isiconvisibleonclick) isIconVisibleOnClick = @linked.scope.isIconVisibleOnClick gMap = @linked.ctrls[0].getMap() - markerModels = if @linked.ctrls.length > 1 and @linked.ctrls[1]? then @linked.ctrls[1].getMarkers() else undefined + markersScope = if @linked.ctrls.length > 1 and @linked.ctrls[1]? then @linked.ctrls[1].getMarkersScope() else undefined modelsNotDefined = angular.isUndefined(@linked.scope.models) or scope.models == undefined - if(modelsNotDefined and markerModels == undefined) + if(modelsNotDefined and (markersScope == undefined or markersScope.markers == undefined or markersScope.models == undefined )) @$log.info("No models to create windows from! Need direct models or models derrived from markers!") return if gMap? @@ -71,14 +85,18 @@ if @linked.scope.models? #we are creating windows with no markers @models = @linked.scope.models + if(@firstTime) + @watchModels(@linked.scope) @createWindow(model,undefined,gMap) for model in @linked.scope.models else #creating windows with parent markers - @models = [] - for mm in markerModels + @models = markersScope.models + if(@firstTime) + @watchModels(markersScope) + for mm in markersScope.markerModels do(mm) => - @models.push(mm.model) - @createWindow(mm.model,mm.gMarker,gMap) + @createWindow(mm.model,mm.gMarker,gMap) + @firstTime = false createWindow: (model,gMarker,gMap)=> ### From 77cf39e08147d411f8651e74d6a3621bd947b537 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 25 Jul 2013 16:10:28 -0400 Subject: [PATCH 21/41] Forgot to rename markers to markerModels --- dist/angular-google-maps.js | 4 ++-- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/windows.coffee | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 5bc493d8b..84185326e 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -665,7 +665,7 @@ not 1:1 in this setting. model = _ref[_i]; _fn(model); } - return scope.markers = this.markers; + return scope.markerModels = this.markers; }; Markers.prototype.watchModels = function(scope) { @@ -919,7 +919,7 @@ not 1:1 in this setting. gMap = this.linked.ctrls[0].getMap(); markersScope = this.linked.ctrls.length > 1 && (this.linked.ctrls[1] != null) ? this.linked.ctrls[1].getMarkersScope() : void 0; modelsNotDefined = angular.isUndefined(this.linked.scope.models) || scope.models === void 0; - if (modelsNotDefined && (markersScope === void 0 || markersScope.markers === void 0 || markersScope.models === void 0)) { + if (modelsNotDefined && (markersScope === void 0 || markersScope.markerModels === void 0 || markersScope.models === void 0)) { this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"); return; } diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index ade162028..b3a4b84c2 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markers=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(){return d.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(oldM);return delete b.windows,b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markers||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&this.watchModels(this.linked.scope),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&this.watchModels(c),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(){return d.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(oldM);return delete b.windows,b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&this.watchModels(this.linked.scope),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&this.watchModels(c),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b Date: Thu, 25 Jul 2013 17:34:49 -0400 Subject: [PATCH 22/41] Window content parsed correctly via delayed interpolation --- dist/angular-google-maps.js | 29 +++++++++++++++- dist/angular-google-maps.min.js | 2 +- example/example.html | 8 ++--- .../directives/api/models/window-model.coffee | 7 ++++ src/coffee/directives/api/window.coffee | 2 +- src/coffee/directives/api/windows.coffee | 33 +++++++++++++++---- src/js/directives/windows.js | 6 ++-- 7 files changed, 70 insertions(+), 17 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 84185326e..8993917df 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -292,7 +292,8 @@ angular.module('google-maps', []);;(function() { }).call(this); (function() { - var __hasProp = {}.hasOwnProperty, + 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; }; this.module("directives.api.models", function() { @@ -302,6 +303,7 @@ angular.module('google-maps', []);;(function() { WindowModel.include(directives.api.models.WindowFunctions); function WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $log, $http, $templateCache, $compile) { + this.destroy = __bind(this.destroy, this); this.scope = scope; this.opts = opts; this.mapCtrl = mapCtrl; @@ -321,6 +323,13 @@ angular.module('google-maps', []);;(function() { this.$log.info(this); } + WindowModel.prototype.destroy = function() { + this.hideWindow(this.gWin); + this.scope.$destroy(); + delete this.gWin; + return delete this; + }; + return WindowModel; })(oo.BaseObject); @@ -811,6 +820,7 @@ not 1:1 in this setting. this.createChildScopesWindows = __bind(this.createChildScopesWindows, this); this.link = __bind(this.link, this); this.watchOurScope = __bind(this.watchOurScope, this); + this.watchDestroy = __bind(this.watchDestroy, this); this.watchModels = __bind(this.watchModels, this); this.watch = __bind(this.watch, this); var name, self, _i, _len, _ref; @@ -875,6 +885,21 @@ not 1:1 in this setting. }, true); }; + Windows.prototype.watchDestroy = function(scope) { + var _this = this; + return scope.$on("$destroy", function() { + var model, _i, _len, _ref; + _ref = _this.windows; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + model.destroy(); + } + delete _this.windows; + _this.windows = []; + return _this.windowsIndex = 0; + }); + }; + Windows.prototype.watchOurScope = function(scope) { var name, _i, _len, _ref, _results, _this = this; @@ -928,6 +953,7 @@ not 1:1 in this setting. this.models = this.linked.scope.models; if (this.firstTime) { this.watchModels(this.linked.scope); + this.watchDestroy(this.linked.scope); } _ref = this.linked.scope.models; for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -938,6 +964,7 @@ not 1:1 in this setting. this.models = markersScope.models; if (this.firstTime) { this.watchModels(markersScope); + this.watchDestroy(markersScope); } _ref1 = markersScope.markerModels; _fn = function(mm) { diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index b3a4b84c2..8549420f4 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models",function(){return this.WindowModel=function(a){function c(a,b,c,d,e,f,g,h,i){this.scope=a,this.opts=b,this.mapCtrl=d,this.markerCtrl=e,this.isIconVisibleOnClick=c,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=f,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(b),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(a,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return b(c,a),c.include(directives.api.models.WindowFunctions),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(){return d.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(oldM);return delete b.windows,b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&this.watchModels(this.linked.scope),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&this.watchModels(c),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.WindowModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=g,this.$http=h,this.$templateCache=i,this.$compile=j,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,h,i,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.include(directives.api.models.WindowFunctions),d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(){return d.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(oldM);return delete b.windows,b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.watchOurScope(a),this.$timeout(function(){return e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k=this;for(d=this.linked.scope.$new(!1),j=this.scopePropNames,g=function(b){var c;return c=b+"Key",d[b]="self"===k[c]||void 0===k[c]?a:a[k[c]]},h=0,i=j.length;i>h;h++)e=j[h],g(e);return f=this.createWindowOptions(b,d,this.linked.element.html(),this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bangular-google-maps example events="map.events"> - -

This is an info window at {{ m.latitude | number:4 }}, {{ m.longitude | number:4 }}!

+ +

This is an info window at {{ latitude | number:4 }}, {{ longitude | number:4 }}!

My marker will stay open when the window is popped up!

- + @@ -66,20 +74,20 @@

angular-google-maps example

- + - +
diff --git a/src/coffee/directives/api/windows.coffee b/src/coffee/directives/api/windows.coffee index 7ebd01a0f..c93ad8081 100644 --- a/src/coffee/directives/api/windows.coffee +++ b/src/coffee/directives/api/windows.coffee @@ -140,6 +140,8 @@ ) interpolateContent: (content,model) => + if @contentKeys == undefined or @contentKeys.length == 0 + return exp = @$interpolate(content) interpModel = {} interpModel[key] = model[key] for key in @contentKeys From e37c1772210c38d7e54ee3abb47ee312c271160e Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Fri, 26 Jul 2013 13:34:59 -0400 Subject: [PATCH 25/41] removed as a injected parameter from all directives except map. Now they all share one Logger from directives.api.util.Logger which can turn on and off info logging by doLog flag. --- dist/angular-google-maps.js | 118 +++++++++++---- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/i-marker.coffee | 4 +- src/coffee/directives/api/i-window.coffee | 4 +- src/coffee/directives/api/marker.coffee | 6 +- src/coffee/directives/api/markers.coffee | 6 +- .../directives/api/models/marker-model.coffee | 3 +- .../directives/api/models/window-model.coffee | 4 +- src/coffee/directives/api/utils/logger.coffee | 10 ++ src/coffee/directives/api/window.coffee | 6 +- src/coffee/directives/api/windows.coffee | 6 +- src/js/directives/map.js | 2 + src/js/directives/marker.js | 4 +- src/js/directives/markers.js | 4 +- src/js/directives/window.js | 6 +- src/js/directives/window_orig.js | 143 ------------------ src/js/directives/windows.js | 6 +- 17 files changed, 135 insertions(+), 199 deletions(-) create mode 100644 src/coffee/directives/api/utils/logger.coffee delete mode 100644 src/js/directives/window_orig.js diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 3afbebec1..9f9ef086a 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -137,6 +137,25 @@ angular.module('google-maps', []);;(function() { }).call(this); +(function() { + this.module("directives.api.utils", function() { + return this.Logger = { + logger: void 0, + doLog: false, + info: function(msg) { + if (directives.api.utils.Logger.doLog) { + if (directives.api.utils.Logger.logger != null) { + return directives.api.utils.Logger.logger.info(msg); + } else { + return console.info(msg); + } + } + } + }; + }); + +}).call(this); + (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = {}.hasOwnProperty, @@ -148,7 +167,7 @@ angular.module('google-maps', []);;(function() { MarkerModel.include(directives.api.utils.GmapUtil); - function MarkerModel(index, model, parentScope, gMap, $timeout, $log, notifyLocalDestroy, defaults, doClick) { + function MarkerModel(index, model, parentScope, gMap, $timeout, notifyLocalDestroy, defaults, doClick) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); @@ -165,6 +184,7 @@ angular.module('google-maps', []);;(function() { this.opts = this.createMarkerOptions(this.gMap, this.myScope.coords, this.myScope.icon, defaults); this.gMarker = new google.maps.Marker(this.opts); this.doClick = doClick; + this.$log = directives.api.utils.Logger; google.maps.event.addListener(this.gMarker, 'click', function() { if (_this.doClick && (_this.myScope.click != null)) { return _this.myScope.click(); @@ -302,7 +322,7 @@ angular.module('google-maps', []);;(function() { WindowModel.include(directives.api.models.WindowFunctions); - function WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $log, $http, $templateCache, $compile) { + function WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $http, $templateCache, $compile) { this.destroy = __bind(this.destroy, this); this.scope = scope; this.opts = opts; @@ -310,7 +330,7 @@ angular.module('google-maps', []);;(function() { this.markerCtrl = markerCtrl; this.isIconVisibleOnClick = isIconVisibleOnClick; this.initialMarkerVisibility = this.markerCtrl != null ? this.markerCtrl.getVisible() : false; - this.$log = $log; + this.$log = directives.api.utils.Logger; this.$http = $http; this.$templateCache = $templateCache; this.$compile = $compile; @@ -364,7 +384,7 @@ angular.module('google-maps', []);;(function() { return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) !== -1; }; - function IMarker($log, $timeout) { + function IMarker($timeout) { this.linkInit = __bind(this.linkInit, this); this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); @@ -374,7 +394,7 @@ angular.module('google-maps', []);;(function() { var self; self = this; this.clsName = "IMarker"; - this.$log = $log; + this.$log = directives.api.utils.Logger; this.$timeout = $timeout; this.restrict = 'ECMA'; this.require = '^googleMap'; @@ -457,7 +477,7 @@ angular.module('google-maps', []);;(function() { IWindow.prototype.DEFAULTS = {}; - function IWindow($log, $timeout, $compile, $http, $templateCache) { + function IWindow($timeout, $compile, $http, $templateCache) { this.link = __bind(this.link, this); var self; self = this; @@ -475,7 +495,7 @@ angular.module('google-maps', []);;(function() { isIconVisibleOnClick: '=isiconvisibleonclick', closeClick: '&closeclick' }; - this.$log = $log; + this.$log = directives.api.utils.Logger; this.$timeout = $timeout; this.$compile = $compile; this.$http = $http; @@ -510,7 +530,7 @@ angular.module('google-maps', []);;(function() { Marker.include(directives.api.utils.GmapUtil); - function Marker($log, $timeout) { + function Marker($timeout) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); @@ -521,7 +541,7 @@ angular.module('google-maps', []);;(function() { self = this; this.template = ''; this.clsName = "Marker"; - $log.info(this); + this.$log.info(this); this.markers = {}; this.mapCtrl = void 0; } @@ -614,7 +634,7 @@ not 1:1 in this setting. return this.Markers = (function(_super) { __extends(Markers, _super); - function Markers($log, $timeout) { + function Markers($timeout) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); @@ -665,7 +685,7 @@ not 1:1 in this setting. _this = this; _ref = scope.models; _fn = function(model) { - _this.markers.push(new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, _this.$log, function(index) { + _this.markers.push(new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, function(index) { return delete _this.markers[index]; }, _this.DEFAULTS, _this.doClick)); return _this.markersIndex++; @@ -680,7 +700,21 @@ not 1:1 in this setting. Markers.prototype.watchModels = function(scope) { var _this = this; return scope.$watch('models', function(newValue, oldValue) { - return ""; + var oldM, _fn, _i, _len, _ref; + if (newValue !== oldValue) { + _ref = _this.markers; + _fn = function(oldM) { + return oldM.destroy(); + }; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + oldM = _ref[_i]; + _fn(oldM); + } + delete _this.markers; + _this.markers = []; + _this.markersIndex = 0; + return _this.createMarkers(scope); + } }, true); }; @@ -752,7 +786,7 @@ not 1:1 in this setting. return this.Window = (function(_super) { __extends(Window, _super); - function Window($log, $timeout, $compile, $http, $templateCache, $interpolate) { + function Window($timeout, $compile, $http, $templateCache, $interpolate) { this.link = __bind(this.link, this); var self; Window.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); @@ -775,7 +809,7 @@ not 1:1 in this setting. markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarker() : void 0; opts = _this.createWindowOptions(markerCtrl, scope, element.html(), _this.DEFAULTS); if (mapCtrl != null) { - return new directives.api.models.WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$log, _this.$http, _this.$templateCache, _this.$compile); + return new directives.api.models.WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$http, _this.$templateCache, _this.$compile); } }, 50); }; @@ -801,9 +835,10 @@ not 1:1 in this setting. return this.Windows = (function(_super) { __extends(Windows, _super); - function Windows($log, $timeout, $compile, $http, $templateCache, $interpolate) { + function Windows($timeout, $compile, $http, $templateCache, $interpolate) { this.interpolateContent = __bind(this.interpolateContent, this); this.createWindow = __bind(this.createWindow, this); + this.setContentKeys = __bind(this.setContentKeys, this); this.createChildScopesWindows = __bind(this.createChildScopesWindows, this); this.link = __bind(this.link, this); this.watchOurScope = __bind(this.watchOurScope, this); @@ -818,10 +853,9 @@ not 1:1 in this setting. this.require = ['^googleMap', '^?markers']; this.template = ''; this.scope.models = '=models'; - this.scope.contentKeys = '=contentkeys'; this.windows = []; this.windwsIndex = 0; - this.scopePropNames = ['show', 'coords', 'templateUrl', 'templateParameter', 'isIconVisibleOnClick', 'closeClick', 'contentKeys']; + this.scopePropNames = ['show', 'coords', 'templateUrl', 'templateParameter', 'isIconVisibleOnClick', 'closeClick']; _ref = this.scopePropNames; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; @@ -829,6 +863,7 @@ not 1:1 in this setting. } this.linked = void 0; this.models = void 0; + this.contentKeys = void 0; this.isIconVisibleOnClick = void 0; this.firstTime = true; this.$log.info(self); @@ -837,8 +872,18 @@ not 1:1 in this setting. Windows.prototype.watch = function(scope, name, nameKey) { var _this = this; return scope.$watch(name, function(newValue, oldValue) { + var model, _i, _len, _ref, _results; if (newValue !== oldValue) { - return _this[nameKey] = typeof newValue === 'function' ? newValue() : newValue; + _this[nameKey] = typeof newValue === 'function' ? newValue() : newValue; + _ref = _this.windows; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push((function(model) { + return model.scope[name] = _this[nameKey] === 'self' || _this[nameKey] === void 0 ? model : model[_this[nameKey]]; + })(model)); + } + return _results; } }, true); }; @@ -846,7 +891,20 @@ not 1:1 in this setting. Windows.prototype.watchModels = function(scope) { var _this = this; return scope.$watch('models', function(newValue, oldValue) { - return ""; + var model, _fn, _i, _len, _ref; + if (newValue !== oldValue) { + _ref = _this.windows; + _fn = function(model) { + return model.destroy(); + }; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _fn(model); + } + _this.windows = []; + _this.windowsIndex = 0; + return _this.createChildScopesWindows(); + } }, true); }; @@ -876,9 +934,7 @@ not 1:1 in this setting. var nameKey; nameKey = name + 'Key'; _this[nameKey] = typeof scope[name] === 'function' ? scope[name]() : scope[name]; - if (firstTime) { - return _this.watch(scope, name, nameKey); - } + return _this.watch(scope, name, nameKey); })(name)); } return _results; @@ -922,6 +978,7 @@ not 1:1 in this setting. this.watchModels(this.linked.scope); this.watchDestroy(this.linked.scope); } + this.setContentKeys(this.linked.scope.models); _ref = this.linked.scope.models; for (_i = 0, _len = _ref.length; _i < _len; _i++) { model = _ref[_i]; @@ -933,6 +990,7 @@ not 1:1 in this setting. this.watchModels(markersScope); this.watchDestroy(markersScope); } + this.setContentKeys(markersScope.models); _ref1 = markersScope.markerModels; _fn = function(mm) { return _this.createWindow(mm.model, mm.gMarker, gMap); @@ -946,6 +1004,12 @@ not 1:1 in this setting. return this.firstTime = false; }; + Windows.prototype.setContentKeys = function(models) { + if (models.length > 0) { + return this.contentKeys = Object.keys(models[0]); + } + }; + Windows.prototype.createWindow = function(model, gMarker, gMap) { /* @@ -972,19 +1036,19 @@ not 1:1 in this setting. name = _ref[_i]; _fn(name); } - parsedContent = ""; + parsedContent = this.interpolateContent(this.linked.element.html(), model); opts = this.createWindowOptions(gMarker, childScope, parsedContent, this.DEFAULTS); - return this.windows.push(new directives.api.models.WindowModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$log, this.$http, this.$templateCache, this.$compile)); + return this.windows.push(new directives.api.models.WindowModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$http, this.$templateCache, this.$compile)); }; Windows.prototype.interpolateContent = function(content, model) { var exp, interpModel, key, _i, _len, _ref; - if (this.contentKeysKey == null) { + if (this.contentKeys === void 0 || this.contentKeys.length === 0) { return; } exp = this.$interpolate(content); interpModel = {}; - _ref = this.contentKeysKey; + _ref = this.contentKeys; for (_i = 0, _len = _ref.length; _i < _len; _i++) { key = _ref[_i]; interpModel[key] = model[key]; @@ -1031,6 +1095,8 @@ angular.module('google-maps') .directive('googleMap', ['$log', '$timeout', function ($log, $timeout) { "use strict"; + + directives.api.utils.Logger.logger = $log; var DEFAULTS = { mapTypeId: google.maps.MapTypeId.ROADMAP diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 0239437de..881d2faea 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var k=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,i),this.gMarker=new google.maps.Marker(this.opts),this.doClick=j,google.maps.event.addListener(this.gMarker,"click",function(){return k.doClick&&null!=k.myScope.click?k.myScope.click():void 0}),f(function(){return k.watchCoords(k.myScope),k.watchIcon(k.myScope),k.watchDestroy(k.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.WindowModel=function(b){function d(b,c,d,e,f,g,h,i,j){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=g,this.$http=h,this.$templateCache=i,this.$compile=j,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,h,i,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.include(directives.api.models.WindowFunctions),d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b,c){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var d;d=this,this.clsName="IMarker",this.$log=b,this.$timeout=c,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e,f){this.link=a(this.link,this);var g;g=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=b,this.$timeout=c,this.$compile=d,this.$http=e,this.$templateCache=f}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Marker",b.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b,c){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var e;d.__super__.constructor.call(this,b,c),e=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=c,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,g.$log,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){return a.$watch("models",function(){return""},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$log,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g,h){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var i,j,k,l,m;for(d.__super__.constructor.call(this,b,c,e,f,g),j=this,this.$interpolate=h,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.scope.contentKeys="=contentkeys",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick","contentKeys"],m=this.scopePropNames,k=0,l=m.length;l>k;k++)i=m[k],this[i+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(j)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,b){return a!==b?d[c]="function"==typeof a?a():a:void 0},!0)},d.prototype.watchModels=function(a){return a.$watch("models",function(){return""},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],firstTime?g.watch(a,b,c):void 0}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.$timeout(function(){return e.watchOurScope(a),e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]||void 0===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g="",f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$log,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(null!=this.contentKeysKey){for(c=this.$interpolate(a),d={},h=this.contentKeysKey,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,h),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.WindowModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.include(directives.api.models.WindowFunctions),d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,$log,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,$log,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=b,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,$log,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,$log,b,c,e,f),i=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.$timeout(function(){return e.watchOurScope(a),e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]||void 0===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) != -1 - constructor: ($log, $timeout) -> + constructor: ($timeout) -> self = @ @clsName = "IMarker" - @$log = $log + @$log = directives.api.utils.Logger @$timeout = $timeout @restrict = 'ECMA' @require = '^googleMap' diff --git a/src/coffee/directives/api/i-window.coffee b/src/coffee/directives/api/i-window.coffee index 56064f6d7..d4f334b59 100644 --- a/src/coffee/directives/api/i-window.coffee +++ b/src/coffee/directives/api/i-window.coffee @@ -7,7 +7,7 @@ # Animation is enabled by default DEFAULTS: {} - constructor: ($log, $timeout, $compile, $http, $templateCache) -> + constructor: ($timeout, $compile, $http, $templateCache) -> self = @ @clsName = "IWindow" @restrict= 'ECMA' @@ -23,7 +23,7 @@ isIconVisibleOnClick: '=isiconvisibleonclick', closeClick: '&closeclick' #scope glue to gmap InfoWindow closeclick } - @$log = $log + @$log = directives.api.utils.Logger @$timeout = $timeout @$compile = $compile @$http = $http diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index 9170869d9..185015983 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -6,12 +6,12 @@ class @Marker extends directives.api.IMarker @include directives.api.utils.GmapUtil - constructor: ($log, $timeout) -> - super($log,$timeout) + constructor: ($timeout) -> + super($timeout) self = @ @template = '' @clsName = "Marker" - $log.info(@) + @$log.info(@) @markers = {} @mapCtrl = undefined diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index f93625e52..c9f63e2f0 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -11,8 +11,8 @@ not 1:1 in this setting. ### @module "directives.api", -> class @Markers extends directives.api.IMarker - constructor: ($log, $timeout) -> - super($log,$timeout) + constructor: ($timeout) -> + super($timeout) self = @ @template = '' @clsName = "Markers" @@ -48,7 +48,7 @@ not 1:1 in this setting. for model in scope.models do(model) => @markers.push( - new directives.api.models.MarkerModel(@markersIndex,model,scope,@mapCtrl,@$timeout,@$log, (index) => + new directives.api.models.MarkerModel(@markersIndex,model,scope,@mapCtrl,@$timeout,(index) => delete @markers[index] ,@DEFAULTS,@doClick) ) diff --git a/src/coffee/directives/api/models/marker-model.coffee b/src/coffee/directives/api/models/marker-model.coffee index d4b8d7781..15ed7731d 100644 --- a/src/coffee/directives/api/models/marker-model.coffee +++ b/src/coffee/directives/api/models/marker-model.coffee @@ -1,7 +1,7 @@ @module "directives.api.models", -> class @MarkerModel extends oo.BaseObject @include directives.api.utils.GmapUtil - constructor:(index,model,parentScope,gMap,$timeout,$log,notifyLocalDestroy,defaults,doClick)-> + constructor:(index,model,parentScope,gMap,$timeout,notifyLocalDestroy,defaults,doClick)-> @index = index @model = model @iconKey = parentScope.icon @@ -13,6 +13,7 @@ @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,defaults) @gMarker = new google.maps.Marker(@opts) @doClick = doClick + @$log = directives.api.utils.Logger google.maps.event.addListener(@gMarker, 'click', => #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ if @doClick and @myScope.click? diff --git a/src/coffee/directives/api/models/window-model.coffee b/src/coffee/directives/api/models/window-model.coffee index b897f6554..00f80023b 100644 --- a/src/coffee/directives/api/models/window-model.coffee +++ b/src/coffee/directives/api/models/window-model.coffee @@ -1,14 +1,14 @@ @module "directives.api.models", -> class @WindowModel extends oo.BaseObject @include directives.api.models.WindowFunctions - constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$log,$http,$templateCache,$compile)-> + constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$http,$templateCache,$compile)-> @scope = scope @opts = opts @mapCtrl = mapCtrl @markerCtrl = markerCtrl @isIconVisibleOnClick = isIconVisibleOnClick @initialMarkerVisibility = if @markerCtrl? then @markerCtrl.getVisible() else false - @$log = $log + @$log = directives.api.utils.Logger @$http = $http @$templateCache = $templateCache @$compile = $compile diff --git a/src/coffee/directives/api/utils/logger.coffee b/src/coffee/directives/api/utils/logger.coffee new file mode 100644 index 000000000..4452814eb --- /dev/null +++ b/src/coffee/directives/api/utils/logger.coffee @@ -0,0 +1,10 @@ +@module "directives.api.utils", -> + @Logger = + logger: undefined + doLog: false + info:(msg) -> + if(directives.api.utils.Logger.doLog) + if directives.api.utils.Logger.logger? + directives.api.utils.Logger.logger.info(msg) + else + console.info(msg) \ No newline at end of file diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee index 7473bebe3..6b12f501e 100644 --- a/src/coffee/directives/api/window.coffee +++ b/src/coffee/directives/api/window.coffee @@ -5,8 +5,8 @@ @module "directives.api", -> class @Window extends directives.api.IWindow - constructor: ($log, $timeout, $compile, $http, $templateCache,$interpolate) -> - super($log, $timeout, $compile, $http, $templateCache) + constructor: ($timeout, $compile, $http, $templateCache,$interpolate) -> + super($timeout, $compile, $http, $templateCache) self = @ @clsName = "Window" @require= ['^googleMap', '^?marker'] @@ -26,6 +26,6 @@ if mapCtrl? #at the very least we need a Map, the marker is optional as we can create Windows without markers new directives.api.models.WindowModel( scope,opts,isIconVisibleOnClick,mapCtrl, - markerCtrl,@$log,@$http,@$templateCache,@$compile + markerCtrl,@$http,@$templateCache,@$compile ) ,50) \ No newline at end of file diff --git a/src/coffee/directives/api/windows.coffee b/src/coffee/directives/api/windows.coffee index c93ad8081..e25b13342 100644 --- a/src/coffee/directives/api/windows.coffee +++ b/src/coffee/directives/api/windows.coffee @@ -4,8 +4,8 @@ @module "directives.api", -> class @Windows extends directives.api.IWindow - constructor: ($log, $timeout, $compile, $http, $templateCache,$interpolate) -> - super($log, $timeout, $compile, $http, $templateCache) + constructor: ($timeout, $compile, $http, $templateCache,$interpolate) -> + super($timeout, $compile, $http, $templateCache) self = @ @$interpolate = $interpolate @clsName = "Windows" @@ -136,7 +136,7 @@ parsedContent = @interpolateContent(@linked.element.html(),model) opts = @createWindowOptions(gMarker,childScope,parsedContent,@DEFAULTS) @windows.push( - new directives.api.models.WindowModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$log,@$http,@$templateCache,@$compile) + new directives.api.models.WindowModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile) ) interpolateContent: (content,model) => diff --git a/src/js/directives/map.js b/src/js/directives/map.js index 130b86e47..cde3196e2 100644 --- a/src/js/directives/map.js +++ b/src/js/directives/map.js @@ -31,6 +31,8 @@ angular.module('google-maps') .directive('googleMap', ['$log', '$timeout', function ($log, $timeout) { "use strict"; + + directives.api.utils.Logger.logger = $log; var DEFAULTS = { mapTypeId: google.maps.MapTypeId.ROADMAP diff --git a/src/js/directives/marker.js b/src/js/directives/marker.js index 35204cef3..60605fb52 100644 --- a/src/js/directives/marker.js +++ b/src/js/directives/marker.js @@ -38,5 +38,5 @@ * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('marker', ['$log', '$timeout', function($log,$timeout){ - return new directives.api.Marker($log,$timeout);}]); +angular.module('google-maps').directive('marker', ['$timeout', function($timeout){ + return new directives.api.Marker($timeout);}]); diff --git a/src/js/directives/markers.js b/src/js/directives/markers.js index c1ccdaf3e..32ffd958f 100644 --- a/src/js/directives/markers.js +++ b/src/js/directives/markers.js @@ -38,5 +38,5 @@ * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('markers', ['$log', '$timeout', function($log,$timeout){ - return new directives.api.Markers($log,$timeout);}]); +angular.module('google-maps').directive('markers', ['$timeout', function($timeout){ + return new directives.api.Markers($timeout);}]); diff --git a/src/js/directives/window.js b/src/js/directives/window.js index 9777a774f..3a3258caf 100644 --- a/src/js/directives/window.js +++ b/src/js/directives/window.js @@ -37,7 +37,7 @@ * {attribute show optional} map will show when this expression returns true */ -angular.module("google-maps").directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', - function ($log, $timeout, $compile, $http, $templateCache) { - return new directives.api.Window($log, $timeout, $compile, $http, $templateCache); +angular.module("google-maps").directive("window", ['$timeout','$compile', '$http', '$templateCache', + function ($timeout, $compile, $http, $templateCache) { + return new directives.api.Window($timeout, $compile, $http, $templateCache); }]); \ No newline at end of file diff --git a/src/js/directives/window_orig.js b/src/js/directives/window_orig.js deleted file mode 100644 index 2dfc80512..000000000 --- a/src/js/directives/window_orig.js +++ /dev/null @@ -1,143 +0,0 @@ -/**! - * The MIT License - * - * Copyright (c) 2010-2012 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 - * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 - */ - -/** - * Map info window directive - * - * This directive is used to create an info window on an existing map. - * This directive creates a new scope. - * - * {attribute coords required} object containing latitude and longitude properties - * {attribute show optional} map will show when this expression returns true - */ - -angular.module("google-maps"). - directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', function ($log, $timeout, $compile, $http, $templateCache) { - - "use strict"; - - var DEFAULTS = { - - }; - - return { - restrict: 'ECMA', - template: '', - transclude: true, - priority: -100, - require: ['^googleMap', '^?marker'], - scope: { - coords: '=coords', - show: '&show', - templateUrl: '=templateurl', - templateParameter: '=templateparameter', - isIconVisibleOnClick: '=isiconvisibleonclick', - closeClick: '&closeclick' //scope glue to gmap InfoWindow closeclick - }, - link: function (scope, element, attrs, ctrls) { - $timeout(function () { - - var isIconVisibleOnClick = true; - - if (angular.isDefined(attrs.isiconvisibleonclick)) - isIconVisibleOnClick = scope.isIconVisibleOnClick; - - var mapCtrl = ctrls[0], - markerCtrl = ctrls.length > 1 ? ctrls[1] : null; - - var opts = angular.extend({}, DEFAULTS, { - content: element.html(), - position: angular.isDefined(markerCtrl) ? markerCtrl.getMarker().getPosition() : - new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude) - }); - - var win = new google.maps.InfoWindow(opts); - - if (angular.isDefined(markerCtrl)) { - // Open window on click - var markerInstance = markerCtrl.getMarker(); - - markerInstance.setClickable(true); - - // Show the window and hide the marker on click - var initialMarkerVisibility; - google.maps.event.addListener(markerInstance, 'click', function () { - win.setPosition(markerInstance.getPosition()); - win.open(mapCtrl.getMap()); - - initialMarkerVisibility = markerInstance.getVisible(); - - markerInstance.setVisible(isIconVisibleOnClick); - }); - - // Set visibility of marker back to what it was before opening the window - google.maps.event.addListener(win, 'closeclick', function () { - markerInstance.setVisible(initialMarkerVisibility); - scope.closeClick(); - }); - } - - function showWindow() { - if (scope.templateUrl) { - $http.get(scope.templateUrl, { cache: $templateCache }) - .then(function (content) { - var templateScope = scope.$new(); - if (angular.isDefined(scope.templateParameter)) { - templateScope.parameter = scope.templateParameter; - } - var compiled = $compile(content.data)(templateScope); - win.setContent(compiled.get(0)); - win.open(mapCtrl.getMap()); - }); - } else { - win.open(mapCtrl.getMap()); - } - } - - function hideWindow() { - win.close(); - } - - scope.$watch('show()', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - showWindow(); - } - else { - hideWindow(); - } - } else if (newValue && !win.getMap()) { - // If we're initially showing the marker and it's not yet visible, show it. - showWindow(); - } - },true); - }, 50); - } - }; - }]); diff --git a/src/js/directives/windows.js b/src/js/directives/windows.js index e451c58ec..521e35bcf 100644 --- a/src/js/directives/windows.js +++ b/src/js/directives/windows.js @@ -39,7 +39,7 @@ * {attribute show optional} map will show when this expression returns true */ -angular.module("google-maps").directive("windows", ['$log', '$timeout','$compile', '$http', '$templateCache', '$interpolate', - function ($log, $timeout, $compile, $http, $templateCache,$interpolate) { - return new directives.api.Windows($log, $timeout, $compile, $http, $templateCache, $interpolate); +angular.module("google-maps").directive("windows", ['$timeout','$compile', '$http', '$templateCache', '$interpolate', + function ($timeout, $compile, $http, $templateCache,$interpolate) { + return new directives.api.Windows($timeout, $compile, $http, $templateCache, $interpolate); }]); \ No newline at end of file From 79dd5fcb0ea7f26bfc5940defb943bab3c0b0bfd Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Fri, 26 Jul 2013 15:47:29 -0400 Subject: [PATCH 26/41] setMap(null) for marker removal instead of undefined --- dist/angular-google-maps.js | 36 +++++++++---------- dist/angular-google-maps.min.js | 2 +- src/coffee/directives/api/marker.coffee | 4 +-- .../directives/api/models/marker-model.coffee | 4 +-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 9f9ef086a..324ed157a 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -210,7 +210,7 @@ angular.module('google-maps', []);;(function() { _this.gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); return _this.gMarker.setVisible((newValue.latitude != null) && (newValue.longitude != null)); } else { - return _this.gMarker.setMap(void 0); + return _this.gMarker.setMap(null); } } }, true); @@ -221,7 +221,7 @@ angular.module('google-maps', []);;(function() { return scope.$watch('icon', function(newValue, oldValue) { if (newValue !== oldValue) { _this.gMarker.icon = newValue; - _this.gMarker.setMap(void 0); + _this.gMarker.setMap(null); _this.gMarker.setMap(_this.gMap.getMap()); _this.gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); return _this.gMarker.setVisible(coords.latitude && (coords.longitude != null)); @@ -537,7 +537,7 @@ angular.module('google-maps', []);;(function() { this.linkInit = __bind(this.linkInit, this); this.validateLinkedScope = __bind(this.validateLinkedScope, this); var self; - Marker.__super__.constructor.call(this, $log, $timeout); + Marker.__super__.constructor.call(this, $timeout); self = this; this.template = ''; this.clsName = "Marker"; @@ -579,7 +579,7 @@ angular.module('google-maps', []);;(function() { _this.markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); return _this.markers[scope.$id].setVisible((newValue.latitude != null) && (newValue.longitude != null)); } else { - return _this.markers[scope.$id].setMap(void 0); + return _this.markers[scope.$id].setMap(null); } } }, true); @@ -590,7 +590,7 @@ angular.module('google-maps', []);;(function() { return scope.$watch('icon', function(newValue, oldValue) { if (newValue !== oldValue) { _this.markers[scope.$id].icon = newValue; - _this.markers[scope.$id].setMap(void 0); + _this.markers[scope.$id].setMap(null); _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); _this.markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); return _this.markers[scope.$id].setVisible(coords.latitude && (coords.longitude != null)); @@ -643,7 +643,7 @@ not 1:1 in this setting. this.linkInit = __bind(this.linkInit, this); this.validateLinkedScope = __bind(this.validateLinkedScope, this); var self; - Markers.__super__.constructor.call(this, $log, $timeout); + Markers.__super__.constructor.call(this, $timeout); self = this; this.template = ''; this.clsName = "Markers"; @@ -789,7 +789,7 @@ not 1:1 in this setting. function Window($timeout, $compile, $http, $templateCache, $interpolate) { this.link = __bind(this.link, this); var self; - Window.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); + Window.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache); self = this; this.clsName = "Window"; this.require = ['^googleMap', '^?marker']; @@ -846,7 +846,7 @@ not 1:1 in this setting. this.watchModels = __bind(this.watchModels, this); this.watch = __bind(this.watch, this); var name, self, _i, _len, _ref; - Windows.__super__.constructor.call(this, $log, $timeout, $compile, $http, $templateCache); + Windows.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache); self = this; this.$interpolate = $interpolate; this.clsName = "Windows"; @@ -1389,8 +1389,8 @@ angular.module('google-maps') * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('marker', ['$log', '$timeout', function($log,$timeout){ - return new directives.api.Marker($log,$timeout);}]); +angular.module('google-maps').directive('marker', ['$timeout', function($timeout){ + return new directives.api.Marker($timeout);}]); ;/**! * The MIT License * @@ -1431,8 +1431,8 @@ angular.module('google-maps').directive('marker', ['$log', '$timeout', function( * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('markers', ['$log', '$timeout', function($log,$timeout){ - return new directives.api.Markers($log,$timeout);}]); +angular.module('google-maps').directive('markers', ['$timeout', function($timeout){ + return new directives.api.Markers($timeout);}]); ;/**! * The MIT License * @@ -1622,9 +1622,9 @@ angular.module("google-maps") * {attribute show optional} map will show when this expression returns true */ -angular.module("google-maps").directive("window", ['$log', '$timeout','$compile', '$http', '$templateCache', - function ($log, $timeout, $compile, $http, $templateCache) { - return new directives.api.Window($log, $timeout, $compile, $http, $templateCache); +angular.module("google-maps").directive("window", ['$timeout','$compile', '$http', '$templateCache', + function ($timeout, $compile, $http, $templateCache) { + return new directives.api.Window($timeout, $compile, $http, $templateCache); }]);;/**! * The MIT License * @@ -1666,7 +1666,7 @@ angular.module("google-maps").directive("window", ['$log', '$timeout','$compile' * {attribute show optional} map will show when this expression returns true */ -angular.module("google-maps").directive("windows", ['$log', '$timeout','$compile', '$http', '$templateCache', '$interpolate', - function ($log, $timeout, $compile, $http, $templateCache,$interpolate) { - return new directives.api.Windows($log, $timeout, $compile, $http, $templateCache, $interpolate); +angular.module("google-maps").directive("windows", ['$timeout','$compile', '$http', '$templateCache', '$interpolate', + function ($timeout, $compile, $http, $templateCache,$interpolate) { + return new directives.api.Windows($timeout, $compile, $http, $templateCache, $interpolate); }]); \ No newline at end of file diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 881d2faea..b88ef3fb5 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,h),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(void 0),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.WindowModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.include(directives.api.models.WindowFunctions),d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,$log,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(void 0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(void 0),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,$log,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=b,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,$log,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,$log,b,c,e,f),i=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.$timeout(function(){return e.watchOurScope(a),e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]||void 0===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$log","$timeout",function(a,b){return new directives.api.Marker(a,b)}]),angular.module("google-maps").directive("markers",["$log","$timeout",function(a,b){return new directives.api.Markers(a,b)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,h),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.WindowModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.include(directives.api.models.WindowFunctions),d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(null),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=b,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f),i=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.$timeout(function(){return e.watchOurScope(a),e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]||void 0===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b scope.$watch('icon', (newValue, oldValue) => if (newValue != oldValue) @markers[scope.$id].icon = newValue - @markers[scope.$id].setMap(undefined) + @markers[scope.$id].setMap(null) @markers[scope.$id].setMap(@mapCtrl.getMap()) @markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) @markers[scope.$id].setVisible(coords.latitude and coords.longitude?) diff --git a/src/coffee/directives/api/models/marker-model.coffee b/src/coffee/directives/api/models/marker-model.coffee index 15ed7731d..fbef13a7f 100644 --- a/src/coffee/directives/api/models/marker-model.coffee +++ b/src/coffee/directives/api/models/marker-model.coffee @@ -36,14 +36,14 @@ @gMarker.setVisible(newValue.latitude? and newValue.longitude?) else # Remove marker - @gMarker.setMap(undefined) + @gMarker.setMap(null) , true) watchIcon:(scope) => scope.$watch('icon', (newValue, oldValue) => if (newValue != oldValue) @gMarker.icon = newValue - @gMarker.setMap(undefined) + @gMarker.setMap(null) @gMarker.setMap(@gMap.getMap()) @gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) @gMarker.setVisible(coords.latitude and coords.longitude?) From 894c627b5cb8161ff5ce3048c1cfa4335ebe6282 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Sun, 28 Jul 2013 12:18:23 -0400 Subject: [PATCH 27/41] fixing linking problems. --- Gruntfile.js | 3 +- dist/angular-google-maps.js | 815 +++++++++++------- dist/angular-google-maps.min.js | 4 +- example/example-controller.js | 11 +- example/example.html | 16 + src/coffee/directives/api/i-marker.coffee | 43 +- src/coffee/directives/api/i-window.coffee | 6 +- src/coffee/directives/api/marker.coffee | 56 +- src/coffee/directives/api/markers.coffee | 71 +- .../marker-child-model.coffee} | 4 +- .../window-child-model.coffee} | 39 +- .../parent/i-marker-parent-model.coffee | 56 ++ .../parent/i-window-parent-model.coffee | 17 + .../models/parent/marker-parent-model.coffee | 57 ++ .../models/parent/markers-parent-model.coffee | 67 ++ .../models/parent/windows-parent-model.coffee | 141 +++ .../directives/api/models/window-model.coffee | 30 - src/coffee/directives/api/window.coffee | 6 +- src/coffee/directives/api/windows.coffee | 134 +-- src/js/directives/marker.js | 5 +- src/js/directives/markers.js | 5 +- 21 files changed, 903 insertions(+), 683 deletions(-) rename src/coffee/directives/api/models/{marker-model.coffee => child/marker-child-model.coffee} (95%) rename src/coffee/directives/api/models/{window-functions.coffee => child/window-child-model.coffee} (60%) create mode 100644 src/coffee/directives/api/models/parent/i-marker-parent-model.coffee create mode 100644 src/coffee/directives/api/models/parent/i-window-parent-model.coffee create mode 100644 src/coffee/directives/api/models/parent/marker-parent-model.coffee create mode 100644 src/coffee/directives/api/models/parent/markers-parent-model.coffee create mode 100644 src/coffee/directives/api/models/parent/windows-parent-model.coffee delete mode 100644 src/coffee/directives/api/models/window-model.coffee diff --git a/Gruntfile.js b/Gruntfile.js index bd3ce2514..d33645e3e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -41,7 +41,8 @@ module.exports = function(grunt) { 'src/coffee/oo/module.coffee', 'src/coffee/oo/base-object.coffee', 'src/coffee/directives/api/utils/*.coffee', - 'src/coffee/directives/api/models/*.coffee', + 'src/coffee/directives/api/models/child/*.coffee', + 'src/coffee/directives/api/models/parent/*.coffee', 'src/coffee/directives/api/*.coffee', 'src/coffee/directives/*.coffee'] // concat then compile into single file } diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 324ed157a..f6d2afb9a 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -161,13 +161,13 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api.models", function() { - return this.MarkerModel = (function(_super) { - __extends(MarkerModel, _super); + this.module("directives.api.models.child", function() { + return this.MarkerChildModel = (function(_super) { + __extends(MarkerChildModel, _super); - MarkerModel.include(directives.api.utils.GmapUtil); + MarkerChildModel.include(directives.api.utils.GmapUtil); - function MarkerModel(index, model, parentScope, gMap, $timeout, notifyLocalDestroy, defaults, doClick) { + function MarkerChildModel(index, model, parentScope, gMap, $timeout, notifyLocalDestroy, defaults, doClick) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); @@ -197,11 +197,11 @@ angular.module('google-maps', []);;(function() { }); } - MarkerModel.prototype.destroy = function() { + MarkerChildModel.prototype.destroy = function() { return this.myScope.$destroy(); }; - MarkerModel.prototype.watchCoords = function(scope) { + MarkerChildModel.prototype.watchCoords = function(scope) { var _this = this; return scope.$watch('coords', function(newValue, oldValue) { if (newValue !== oldValue) { @@ -216,7 +216,7 @@ angular.module('google-maps', []);;(function() { }, true); }; - MarkerModel.prototype.watchIcon = function(scope) { + MarkerChildModel.prototype.watchIcon = function(scope) { var _this = this; return scope.$watch('icon', function(newValue, oldValue) { if (newValue !== oldValue) { @@ -229,7 +229,7 @@ angular.module('google-maps', []);;(function() { }, true); }; - MarkerModel.prototype.watchDestroy = function(scope) { + MarkerChildModel.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { _this.gMarker.setMap(null); @@ -239,7 +239,53 @@ angular.module('google-maps', []);;(function() { }); }; - return MarkerModel; + return MarkerChildModel; + + })(oo.BaseObject); + }); + +}).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; }; + + this.module("directives.api.models.child", function() { + return this.WindowChildModel = (function(_super) { + __extends(WindowChildModel, _super); + + WindowChildModel.include(directives.api.models.child.WindowFunctions); + + function WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $http, $templateCache, $compile) { + this.destroy = __bind(this.destroy, this); + this.scope = scope; + this.opts = opts; + this.mapCtrl = mapCtrl; + this.markerCtrl = markerCtrl; + this.isIconVisibleOnClick = isIconVisibleOnClick; + this.initialMarkerVisibility = this.markerCtrl != null ? this.markerCtrl.getVisible() : false; + this.$log = directives.api.utils.Logger; + this.$http = $http; + this.$templateCache = $templateCache; + this.$compile = $compile; + this.gWin = new google.maps.InfoWindow(opts); + if (this.markerCtrl != null) { + this.markerCtrl.setClickable(true); + } + this.handleClick(this.scope, this.mapCtrl, this.markerCtrl, this.gWin, this.isIconVisibleOnClick, this.initialMarkerVisibility); + this.watchShow(scope, $http, $templateCache, this.$compile, this.gWin, this.showWindow, this.hideWindow, this.mapCtrl); + this.$log.info(this); + } + + WindowChildModel.prototype.destroy = function() { + this.hideWindow(this.gWin); + this.scope.$destroy(); + delete this.gWin; + return delete this; + }; + + return WindowChildModel; })(oo.BaseObject); }); @@ -255,10 +301,10 @@ angular.module('google-maps', []);;(function() { */ (function() { - this.module("directives.api.models", function() { + this.module("directives.api.models.child", function() { return this.WindowFunctions = { watchShow: function(scope, $http, $templateCache, $compile, gWin, showHandle, hideHandle, mapCtrl) { - return scope.$watch('show()', function(newValue, oldValue) { + return scope.$watch('show', function(newValue, oldValue) { if (newValue !== oldValue) { if (newValue) { return showHandle(scope, $http, $templateCache, $compile, gWin, mapCtrl); @@ -311,52 +357,6 @@ angular.module('google-maps', []);;(function() { }).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; }; - - this.module("directives.api.models", function() { - return this.WindowModel = (function(_super) { - __extends(WindowModel, _super); - - WindowModel.include(directives.api.models.WindowFunctions); - - function WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $http, $templateCache, $compile) { - this.destroy = __bind(this.destroy, this); - this.scope = scope; - this.opts = opts; - this.mapCtrl = mapCtrl; - this.markerCtrl = markerCtrl; - this.isIconVisibleOnClick = isIconVisibleOnClick; - this.initialMarkerVisibility = this.markerCtrl != null ? this.markerCtrl.getVisible() : false; - this.$log = directives.api.utils.Logger; - this.$http = $http; - this.$templateCache = $templateCache; - this.$compile = $compile; - this.gWin = new google.maps.InfoWindow(opts); - if (this.markerCtrl != null) { - this.markerCtrl.setClickable(true); - } - this.handleClick(this.scope, this.mapCtrl, this.markerCtrl, this.gWin, this.isIconVisibleOnClick, this.initialMarkerVisibility); - this.watchShow(scope, $http, $templateCache, this.$compile, this.gWin, this.showWindow, this.hideWindow, this.mapCtrl); - this.$log.info(this); - } - - WindowModel.prototype.destroy = function() { - this.hideWindow(this.gWin); - this.scope.$destroy(); - delete this.gWin; - return delete this; - }; - - return WindowModel; - - })(oo.BaseObject); - }); - -}).call(this); - /* - interface for all markers to derrive from @@ -372,47 +372,52 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api", function() { - return this.IMarker = (function(_super) { - __extends(IMarker, _super); + this.module("directives.api.models.parent", function() { + return this.IMarkerParentModel = (function(_super) { + __extends(IMarkerParentModel, _super); - IMarker.prototype.DEFAULTS = { + IMarkerParentModel.prototype.DEFAULTS = { animation: google.maps.Animation.DROP }; - IMarker.prototype.isFalse = function(value) { + IMarkerParentModel.prototype.isFalse = function(value) { return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) !== -1; }; - function IMarker($timeout) { + function IMarkerParentModel(scope, element, attrs, mapCtrl, $timeout) { this.linkInit = __bind(this.linkInit, this); this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); - this.link = __bind(this.link, this); - this.validateLinkedScope = __bind(this.validateLinkedScope, this); - var self; + this.validateScope = __bind(this.validateScope, this); + var self, + _this = this; self = this; + if (this.validateScope(scope)) { + return; + } + this.mapCtrl = mapCtrl; + this.doClick = doClick; + this.animate = animate; this.clsName = "IMarker"; this.$log = directives.api.utils.Logger; this.$timeout = $timeout; - this.restrict = 'ECMA'; - this.require = '^googleMap'; - this.priority = -1; - this.transclude = true; - this.replace = true; - this.scope = { - coords: '=coords', - icon: '=icon', - click: '&click' - }; + this.$timeout(function() { + var animate; + animate = angular.isDefined(attrs.animate) && _this.isFalse(attrs.animate); + _this.watchModels(scope); + _this.createMarkers(scope); + _this.watchCoords(scope); + _this.watchIcon(scope); + return _this.watchDestroy(scope); + }); } - IMarker.prototype.controller = function($scope, $element) { + IMarkerParentModel.prototype.controller = function($scope, $element) { throw new Exception("Not Implemented!!"); }; - IMarker.prototype.validateLinkedScope = function(scope) { + IMarkerParentModel.prototype.validateScope = function(scope) { var ret; ret = angular.isUndefined(scope.coords) || scope.coords === void 0; if (ret) { @@ -421,38 +426,23 @@ angular.module('google-maps', []);;(function() { return ret; }; - IMarker.prototype.link = function(scope, element, attrs, mapCtrl) { - var _this = this; - if (this.validateLinkedScope(scope)) { - return; - } - return this.$timeout(function() { - var animate; - animate = angular.isDefined(attrs.animate) && _this.isFalse(attrs.animate); - _this.linkInit(element, mapCtrl, scope, animate, angular.isDefined(attrs.click)); - _this.watchCoords(scope); - _this.watchIcon(scope); - return _this.watchDestroy(scope); - }); - }; - - IMarker.prototype.watchCoords = function(scope) { + IMarkerParentModel.prototype.watchCoords = function(scope) { throw new Exception("Not Implemented!!"); }; - IMarker.prototype.watchIcon = function(scope) { + IMarkerParentModel.prototype.watchIcon = function(scope) { throw new Exception("Not Implemented!!"); }; - IMarker.prototype.watchDestroy = function(scope) { + IMarkerParentModel.prototype.watchDestroy = function(scope) { throw new Exception("Not Implemented!!"); }; - IMarker.prototype.linkInit = function(element, mapCtrl, scope, animate) { + IMarkerParentModel.prototype.linkInit = function(element, mapCtrl, scope, animate) { throw new Exception("Not Implemented!!"); }; - return IMarker; + return IMarkerParentModel; })(oo.BaseObject); }); @@ -465,48 +455,35 @@ angular.module('google-maps', []);;(function() { */ (function() { - var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - __hasProp = {}.hasOwnProperty, + 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; }; - this.module("directives.api", function() { - return this.IWindow = (function(_super) { - __extends(IWindow, _super); + this.module("directives.api.models.parent", function() { + var _ref; + return this.IWindowParentModel = (function(_super) { + __extends(IWindowParentModel, _super); - IWindow.include(directives.api.utils.GmapUtil); + function IWindowParentModel() { + _ref = IWindowParentModel.__super__.constructor.apply(this, arguments); + return _ref; + } - IWindow.prototype.DEFAULTS = {}; + IWindowParentModel.include(directives.api.utils.GmapUtil); - function IWindow($timeout, $compile, $http, $templateCache) { - this.link = __bind(this.link, this); + IWindowParentModel.prototype.DEFAULTS = {}; + + IWindowParentModel.prototype.link = function(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache) { var self; self = this; - this.clsName = "IWindow"; - this.restrict = 'ECMA'; - this.template = void 0; - this.transclude = true; - this.priority = -100; - this.require = void 0; - this.scope = { - coords: '=coords', - show: '&show', - templateUrl: '=templateurl', - templateParameter: '=templateparameter', - isIconVisibleOnClick: '=isiconvisibleonclick', - closeClick: '&closeclick' - }; + this.clsName = "directives.api.models.parent.IWindow"; this.$log = directives.api.utils.Logger; this.$timeout = $timeout; this.$compile = $compile; this.$http = $http; - this.$templateCache = $templateCache; - } - - IWindow.prototype.link = function(scope, element, attrs, ctrls) { - throw new Exception("Not Implemented!!"); + return this.$templateCache = $templateCache; }; - return IWindow; + return IWindowParentModel; })(oo.BaseObject); }); @@ -524,168 +501,137 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api", function() { - return this.Marker = (function(_super) { - __extends(Marker, _super); + this.module("directives.api.models.parent", function() { + return this.MarkerParentModel = (function(_super) { + __extends(MarkerParentModel, _super); - Marker.include(directives.api.utils.GmapUtil); + MarkerParentModel.include(directives.api.utils.GmapUtil); - function Marker($timeout) { + function MarkerParentModel(scope, element, attrs, mapCtrl, $timeout) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); - this.linkInit = __bind(this.linkInit, this); - this.validateLinkedScope = __bind(this.validateLinkedScope, this); - var self; - Marker.__super__.constructor.call(this, $timeout); + this.validateScope = __bind(this.validateScope, this); + var opts, self; + MarkerParentModel.__super__.constructor.call(this, scope, element, attrs, mapCtrl, $timeout); self = this; - this.template = ''; - this.clsName = "Marker"; + this.clsName = "MarkerParentModel"; this.$log.info(this); - this.markers = {}; - this.mapCtrl = void 0; - } - - Marker.prototype.controller = function($scope, $element) { - return this.getMarker = function() { - return $element.data('instance'); - }; - }; - - Marker.prototype.validateLinkedScope = function(scope) { - return Marker.__super__.validateLinkedScope.call(this, scope) || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude); - }; - - Marker.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { - var gMarker, opts; - this.mapCtrl = mapCtrl; opts = this.createMarkerOptions(mapCtrl, scope.coords, scope.icon, animate, this.DEFAULTS); - gMarker = new google.maps.Marker(opts); - this.markers[scope.$id] = gMarker; - element.data('instance', gMarker); - return google.maps.event.addListener(gMarker, 'click', function() { + this.gMarker = new google.maps.Marker(opts); + this.scope = scope; + google.maps.event.addListener(gMarker, 'click', function() { if (doClick && (scope.click != null)) { return scope.click(); } }); + } + + MarkerParentModel.prototype.validateScope = function(scope) { + return MarkerParentModel.__super__.validateScope.call(this, scope) || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude); + }; + + MarkerParentModel.prototype.controller = function($scope, $element) { + return this.getMarker = function() { + return this.gMarker; + }; }; - Marker.prototype.watchCoords = function(scope) { + MarkerParentModel.prototype.watchCoords = function(scope) { var _this = this; return scope.$watch('coords', function(newValue, oldValue) { if (newValue !== oldValue) { - if (newValue) { - _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); - _this.markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - return _this.markers[scope.$id].setVisible((newValue.latitude != null) && (newValue.longitude != null)); + if (newValue && (typeof gMarker !== "undefined" && gMarker !== null)) { + _this.gMarker.setMap(_this.mapCtrl.getMap()); + _this.gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); + return _this.gMarker.setVisible((newValue.latitude != null) && (newValue.longitude != null)); } else { - return _this.markers[scope.$id].setMap(null); + return _this.gMarker.setMap(null); } } }, true); }; - Marker.prototype.watchIcon = function(scope) { + MarkerParentModel.prototype.watchIcon = function(scope) { var _this = this; return scope.$watch('icon', function(newValue, oldValue) { - if (newValue !== oldValue) { - _this.markers[scope.$id].icon = newValue; - _this.markers[scope.$id].setMap(null); - _this.markers[scope.$id].setMap(_this.mapCtrl.getMap()); - _this.markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); - return _this.markers[scope.$id].setVisible(coords.latitude && (coords.longitude != null)); + if (newValue !== oldValue && (typeof gMarker !== "undefined" && gMarker !== null)) { + _this.gMarker.icon = newValue; + _this.gMarker.setMap(null); + _this.gMarker.setMap(_this.mapCtrl.getMap()); + _this.gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); + return _this.gMarker.setVisible(coords.latitude && (coords.longitude != null)); } }, true); }; - Marker.prototype.watchDestroy = function(scope) { + MarkerParentModel.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { - _this.markers[scope.$id].setMap(null); - return delete _this.markers[scope.$id]; + if (_this.gMarker === void 0) { + delete _this; + return; + } + _this.gMarker.setMap(null); + delete _this.gMarker; + return delete _this; }); }; - return Marker; + return MarkerParentModel; - })(directives.api.IMarker); + })(directives.api.models.parent.IMarkerParent); }); }).call(this); - -/* -Markers will map icon and coords differently than directibes.api.Marker. This is because Scope and the model marker are -not 1:1 in this setting. - - - icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] - - coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] - - - watches from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself - - actual changes to a model are tracked inside directives.api.model.MarkerModel -*/ - (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; }; - this.module("directives.api", function() { - return this.Markers = (function(_super) { - __extends(Markers, _super); + this.module("directives.api.models", function() { + return this.MarkersParentModel = (function(_super) { + __extends(MarkersParentModel, _super); - function Markers($timeout) { + function MarkersParentModel(scope, element, attrs, mapCtrl, $timeout) { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); this.watchModels = __bind(this.watchModels, this); this.createMarkers = __bind(this.createMarkers, this); - this.linkInit = __bind(this.linkInit, this); - this.validateLinkedScope = __bind(this.validateLinkedScope, this); + this.validateScope = __bind(this.validateScope, this); var self; - Markers.__super__.constructor.call(this, $timeout); + MarkersParentModel.__super__.constructor.call(this, scope, element, attrs, mapCtrl, $timeout); self = this; - this.template = ''; - this.clsName = "Markers"; - this.scope.models = '=models'; + this.clsName = "MarkersParentModel"; this.markers = []; this.markersIndex = 0; - this.mapCtrl = void 0; - this.$timeout = $timeout; - this.doClick = void 0; - this.animate = void 0; + this.scope = scope; this.$log.info(this); } - Markers.prototype.controller = function($scope, $element) { + MarkersParentModel.prototype.controller = function($scope, $element) { return this.getMarkersScope = function() { return $scope; }; }; - Markers.prototype.validateLinkedScope = function(scope) { + MarkersParentModel.prototype.validateScope = function(scope) { var modelsNotDefined; modelsNotDefined = angular.isUndefined(scope.models) || scope.models === void 0; if (modelsNotDefined) { this.$log.error(this.clsName + ": no valid models attribute found"); } - return Markers.__super__.validateLinkedScope.call(this, scope) || modelsNotDefined; - }; - - Markers.prototype.linkInit = function(element, mapCtrl, scope, animate, doClick) { - this.mapCtrl = mapCtrl; - this.doClick = doClick; - this.animate = animate; - this.watchModels(scope); - return this.createMarkers(scope); + return MarkersParentModel.__super__.validateScope.call(this, scope) || modelsNotDefined; }; - Markers.prototype.createMarkers = function(scope) { + MarkersParentModel.prototype.createMarkers = function(scope) { var model, _fn, _i, _len, _ref, _this = this; _ref = scope.models; _fn = function(model) { - _this.markers.push(new directives.api.models.MarkerModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, function(index) { + _this.markers.push(new directives.api.models.child.MarkerChildModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, function(index) { return delete _this.markers[index]; }, _this.DEFAULTS, _this.doClick)); return _this.markersIndex++; @@ -697,7 +643,7 @@ not 1:1 in this setting. return scope.markerModels = this.markers; }; - Markers.prototype.watchModels = function(scope) { + MarkersParentModel.prototype.watchModels = function(scope) { var _this = this; return scope.$watch('models', function(newValue, oldValue) { var oldM, _fn, _i, _len, _ref; @@ -718,7 +664,7 @@ not 1:1 in this setting. }, true); }; - Markers.prototype.watchCoords = function(scope) { + MarkersParentModel.prototype.watchCoords = function(scope) { var _this = this; return scope.$watch('coords', function(newValue, oldValue) { var model, _i, _len, _ref, _results; @@ -734,7 +680,7 @@ not 1:1 in this setting. }, true); }; - Markers.prototype.watchIcon = function(scope) { + MarkersParentModel.prototype.watchIcon = function(scope) { var _this = this; return scope.$watch('icon', function(newValue, oldValue) { var model, _i, _len, _ref, _results; @@ -750,7 +696,7 @@ not 1:1 in this setting. }, true); }; - Markers.prototype.watchDestroy = function(scope) { + MarkersParentModel.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { var model, _i, _len, _ref, _results; @@ -764,17 +710,16 @@ not 1:1 in this setting. }); }; - return Markers; + return MarkersParentModel; - })(directives.api.IMarker); + })(directives.api.models.parent.IMarkerParentModel); }); }).call(this); /* - Window directive for GoogleMap Info Windows, where ng-repeat is being used.... - Where Html DOM element is 1:1 on Scope and a Model + Windows directive where many windows map to the models property */ (function() { @@ -782,94 +727,46 @@ not 1:1 in this setting. __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; }; - this.module("directives.api", function() { - return this.Window = (function(_super) { - __extends(Window, _super); + this.module("directives.api.models.parent", function() { + return this.WindowsParentModel = (function(_super) { + __extends(WindowsParentModel, _super); - function Window($timeout, $compile, $http, $templateCache, $interpolate) { - this.link = __bind(this.link, this); - var self; - Window.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache); + function WindowsParentModel(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache, $interpolate) { + this.interpolateContent = __bind(this.interpolateContent, this); + this.createWindow = __bind(this.createWindow, this); + this.setContentKeys = __bind(this.setContentKeys, this); + this.createChildScopesWindows = __bind(this.createChildScopesWindows, this); + this.watchOurScope = __bind(this.watchOurScope, this); + this.watchDestroy = __bind(this.watchDestroy, this); + this.watchModels = __bind(this.watchModels, this); + this.watch = __bind(this.watch, this); + var name, self, _i, _len, _ref, + _this = this; + WindowsParentModel.__super__.constructor.call(this, scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache, $interpolate); self = this; - this.clsName = "Window"; - this.require = ['^googleMap', '^?marker']; - this.template = ''; + this.$interpolate = $interpolate; + this.clsName = "WindowsParentModel"; + this.windows = []; + this.windwsIndex = 0; + this.scopePropNames = ['show', 'coords', 'templateUrl', 'templateParameter', 'isIconVisibleOnClick', 'closeClick']; + _ref = this.scopePropNames; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + name = _ref[_i]; + this[name + 'Key'] = void 0; + } + this.linked = new directives.api.utils.Linked(scope, element, attrs, ctrls); + this.models = void 0; + this.contentKeys = void 0; + this.isIconVisibleOnClick = void 0; + this.firstTime = true; this.$log.info(self); - } - - Window.prototype.link = function(scope, element, attrs, ctrls) { - var _this = this; - return this.$timeout(function() { - var isIconVisibleOnClick, mapCtrl, markerCtrl, opts; - isIconVisibleOnClick = true; - if (angular.isDefined(attrs.isiconvisibleonclick)) { - isIconVisibleOnClick = scope.isIconVisibleOnClick; - } - mapCtrl = ctrls[0].getMap(); - markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarker() : void 0; - opts = _this.createWindowOptions(markerCtrl, scope, element.html(), _this.DEFAULTS); - if (mapCtrl != null) { - return new directives.api.models.WindowModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$http, _this.$templateCache, _this.$compile); - } + this.$timeout(function() { + _this.watchOurScope(scope); + return _this.createChildScopesWindows(); }, 50); - }; - - return Window; - - })(directives.api.IWindow); - }); - -}).call(this); - - -/* - Windows directive where many windows map to the models property -*/ - -(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; }; - - this.module("directives.api", function() { - return this.Windows = (function(_super) { - __extends(Windows, _super); - - function Windows($timeout, $compile, $http, $templateCache, $interpolate) { - this.interpolateContent = __bind(this.interpolateContent, this); - this.createWindow = __bind(this.createWindow, this); - this.setContentKeys = __bind(this.setContentKeys, this); - this.createChildScopesWindows = __bind(this.createChildScopesWindows, this); - this.link = __bind(this.link, this); - this.watchOurScope = __bind(this.watchOurScope, this); - this.watchDestroy = __bind(this.watchDestroy, this); - this.watchModels = __bind(this.watchModels, this); - this.watch = __bind(this.watch, this); - var name, self, _i, _len, _ref; - Windows.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache); - self = this; - this.$interpolate = $interpolate; - this.clsName = "Windows"; - this.require = ['^googleMap', '^?markers']; - this.template = ''; - this.scope.models = '=models'; - this.windows = []; - this.windwsIndex = 0; - this.scopePropNames = ['show', 'coords', 'templateUrl', 'templateParameter', 'isIconVisibleOnClick', 'closeClick']; - _ref = this.scopePropNames; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - name = _ref[_i]; - this[name + 'Key'] = void 0; - } - this.linked = void 0; - this.models = void 0; - this.contentKeys = void 0; - this.isIconVisibleOnClick = void 0; - this.firstTime = true; - this.$log.info(self); } - Windows.prototype.watch = function(scope, name, nameKey) { + WindowsParentModel.prototype.watch = function(scope, name, nameKey) { var _this = this; return scope.$watch(name, function(newValue, oldValue) { var model, _i, _len, _ref, _results; @@ -880,7 +777,7 @@ not 1:1 in this setting. for (_i = 0, _len = _ref.length; _i < _len; _i++) { model = _ref[_i]; _results.push((function(model) { - return model.scope[name] = _this[nameKey] === 'self' || _this[nameKey] === void 0 ? model : model[_this[nameKey]]; + return model.scope[name] = _this[nameKey] === 'self' ? model : model[_this[nameKey]]; })(model)); } return _results; @@ -888,7 +785,7 @@ not 1:1 in this setting. }, true); }; - Windows.prototype.watchModels = function(scope) { + WindowsParentModel.prototype.watchModels = function(scope) { var _this = this; return scope.$watch('models', function(newValue, oldValue) { var model, _fn, _i, _len, _ref; @@ -908,7 +805,7 @@ not 1:1 in this setting. }, true); }; - Windows.prototype.watchDestroy = function(scope) { + WindowsParentModel.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { var model, _i, _len, _ref; @@ -923,7 +820,7 @@ not 1:1 in this setting. }); }; - Windows.prototype.watchOurScope = function(scope) { + WindowsParentModel.prototype.watchOurScope = function(scope) { var name, _i, _len, _ref, _results, _this = this; _ref = this.scopePropNames; @@ -940,16 +837,7 @@ not 1:1 in this setting. return _results; }; - Windows.prototype.link = function(scope, element, attrs, ctrls) { - var _this = this; - this.linked = new directives.api.utils.Linked(scope, element, attrs, ctrls); - return this.$timeout(function() { - _this.watchOurScope(scope); - return _this.createChildScopesWindows(); - }, 50); - }; - - Windows.prototype.createChildScopesWindows = function() { + WindowsParentModel.prototype.createChildScopesWindows = function() { /* being that we cannot tell the difference in Key String vs. a normal value string (TemplateUrl) @@ -1004,13 +892,13 @@ not 1:1 in this setting. return this.firstTime = false; }; - Windows.prototype.setContentKeys = function(models) { + WindowsParentModel.prototype.setContentKeys = function(models) { if (models.length > 0) { return this.contentKeys = Object.keys(models[0]); } }; - Windows.prototype.createWindow = function(model, gMarker, gMap) { + WindowsParentModel.prototype.createWindow = function(model, gMarker, gMap) { /* Create ChildScope to Mimmick an ng-repeat created scope, must define the below scope @@ -1030,7 +918,7 @@ not 1:1 in this setting. _fn = function(name) { var nameKey; nameKey = name + 'Key'; - return childScope[name] = _this[nameKey] === 'self' || _this[nameKey] === void 0 ? model : model[_this[nameKey]]; + return childScope[name] = _this[nameKey] === 'self' ? model : model[_this[nameKey]]; }; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; @@ -1041,7 +929,7 @@ not 1:1 in this setting. return this.windows.push(new directives.api.models.WindowModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$http, this.$templateCache, this.$compile)); }; - Windows.prototype.interpolateContent = function(content, model) { + WindowsParentModel.prototype.interpolateContent = function(content, model) { var exp, interpModel, key, _i, _len, _ref; if (this.contentKeys === void 0 || this.contentKeys.length === 0) { return; @@ -1056,6 +944,273 @@ not 1:1 in this setting. return exp(interpModel); }; + return WindowsParentModel; + + })(directives.api.IWindow); + }); + +}).call(this); + + +/* + - interface for all markers to derrive from + - to enforce a minimum set of requirements + - attributes + - coords + - icon + - implementation needed on watches +*/ + +(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; }; + + this.module("directives.api", function() { + return this.IMarker = (function(_super) { + __extends(IMarker, _super); + + function IMarker($timeout) { + this.link = __bind(this.link, this); + var self; + self = this; + this.clsName = "IMarker"; + this.$log = directives.api.utils.Logger; + this.$timeout = $timeout; + this.restrict = 'ECMA'; + this.require = '^googleMap'; + this.priority = -1; + this.transclude = true; + this.replace = true; + this.scope = { + coords: '=coords', + icon: '=icon', + click: '&click' + }; + } + + IMarker.prototype.link = function(scope, element, attrs, mapCtrl) { + throw new Exception("Not implemented!!"); + }; + + return IMarker; + + })(oo.BaseObject); + }); + +}).call(this); + + +/* + - interface directive for all window(s) to derrive from +*/ + +(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; }; + + this.module("directives.api", function() { + return this.IWindow = (function(_super) { + __extends(IWindow, _super); + + function IWindow($timeout, $compile, $http, $templateCache) { + this.link = __bind(this.link, this); + var self; + self = this; + this.clsName = "IWindow"; + this.restrict = 'ECMA'; + this.template = void 0; + this.transclude = true; + this.priority = -100; + this.require = void 0; + this.scope = { + coords: '=coords', + show: '=show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' + }; + this.$log = directives.api.utils.Logger; + this.$timeout = $timeout; + this.$compile = $compile; + this.$http = $http; + this.$templateCache = $templateCache; + } + + IWindow.prototype.link = function(scope, element, attrs, mapCtrl) { + throw new Exception("Not Implemented!!"); + }; + + return IWindow; + + })(oo.BaseObject); + }); + +}).call(this); + + +/* + Basic Directive api for a marker. Basic in the sense that this directive contains 1:1 on scope and model. + Thus there will be one html element per marker within the directive. +*/ + +(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; }; + + this.module("directives.api", function() { + return this.Marker = (function(_super) { + __extends(Marker, _super); + + function Marker($timeout) { + this.link = __bind(this.link, this); + var self; + Marker.__super__.constructor.call(this, $timeout); + self = this; + this.template = ''; + this.clsName = "Marker"; + this.$log.info(this); + } + + Marker.prototype.link = function(scope, element, attrs, mapCtrl) { + return new directives.api.models.MarkerParentModel(scope, element, attrs, mapCtrl, this.$timeout); + }; + + return Marker; + + })(directives.api.IMarker); + }); + +}).call(this); + + +/* +Markers will map icon and coords differently than directibes.api.Marker. This is because Scope and the model marker are +not 1:1 in this setting. + + - icon - will be the iconKey to the marker value ie: to get the icon marker[iconKey] + - coords - will be the coordsKey to the marker value ie: to get the icon marker[coordsKey] + + - watches from IMarker reflect that the look up key for a value has changed and not the actual icon or coords itself + - actual changes to a model are tracked inside directives.api.model.MarkerModel +*/ + +(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; }; + + this.module("directives.api", function() { + return this.Markers = (function(_super) { + __extends(Markers, _super); + + function Markers($timeout) { + this.link = __bind(this.link, this); + var self; + Markers.__super__.constructor.call(this, $timeout); + self = this; + this.template = ''; + this.clsName = "Markers"; + this.scope.models = '=models'; + this.$timeout = $timeout; + this.$log.info(this); + } + + Markers.prototype.link = function(scope, element, attrs, ctrl) { + return new directives.api.models.parent.MarkersParentModel(element, ctrl, scope, animate, doClick, this.$timeout); + }; + + return Markers; + + })(directives.api.directives.IMarker); + }); + +}).call(this); + + +/* + Window directive for GoogleMap Info Windows, where ng-repeat is being used.... + Where Html DOM element is 1:1 on Scope and a Model +*/ + +(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; }; + + this.module("directives.api", function() { + return this.Window = (function(_super) { + __extends(Window, _super); + + function Window($timeout, $compile, $http, $templateCache) { + this.link = __bind(this.link, this); + var self; + Window.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache); + self = this; + this.clsName = "Window"; + this.require = ['^googleMap', '^?marker']; + this.template = ''; + this.$log.info(self); + } + + Window.prototype.link = function(scope, element, attrs, ctrls) { + var _this = this; + return this.$timeout(function() { + var isIconVisibleOnClick, mapCtrl, markerCtrl, opts; + isIconVisibleOnClick = true; + if (angular.isDefined(attrs.isiconvisibleonclick)) { + isIconVisibleOnClick = scope.isIconVisibleOnClick; + } + mapCtrl = ctrls[0].getMap(); + markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarker() : void 0; + opts = _this.createWindowOptions(markerCtrl, scope, element.html(), _this.DEFAULTS); + if (mapCtrl != null) { + return new directives.api.models.child.WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$http, _this.$templateCache, _this.$compile); + } + }, 50); + }; + + return Window; + + })(directives.api.IWindow); + }); + +}).call(this); + + +/* + Windows directive where many windows map to the models property +*/ + +(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; }; + + this.module("directives.api", function() { + return this.Windows = (function(_super) { + __extends(Windows, _super); + + function Windows($timeout, $compile, $http, $templateCache, $interpolate) { + this.link = __bind(this.link, this); + var self; + Windows.__super__.constructor.call(this, $timeout, $compile, $http, $templateCache); + self = this; + this.$interpolate = $interpolate; + this.clsName = "Windows"; + this.require = ['^googleMap', '^?markers']; + this.template = ''; + this.scope.models = '=models'; + this.$log.info(self); + } + + Windows.prototype.link = function(scope, element, attrs, ctrls) { + return new directives.api.models.parent.WindowsParentModel(scope, element, attrs, ctrls, this.$timeout, this.$compile, this.$http, this.$templateCache, this.$interpolate); + }; + return Windows; })(directives.api.IWindow); @@ -1389,8 +1544,9 @@ angular.module('google-maps') * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('marker', ['$timeout', function($timeout){ - return new directives.api.Marker($timeout);}]); +angular.module('google-maps').directive('marker', ['$timeout', function ($timeout) { + return new directives.api.Marker($timeout); +}]); ;/**! * The MIT License * @@ -1431,8 +1587,9 @@ angular.module('google-maps').directive('marker', ['$timeout', function($timeout * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('markers', ['$timeout', function($timeout){ - return new directives.api.Markers($timeout);}]); +angular.module('google-maps').directive('markers', ['$timeout', function ($timeout) { + return new directives.api.Markers($timeout); +}]); ;/**! * The MIT License * diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index b88ef3fb5..b7f9d7beb 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -1,5 +1,5 @@ -/*! angular-google-maps 0.0.0 2013-07-26 +/*! angular-google-maps 0.0.0 2013-07-27 * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkerModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,h),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show()",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.WindowModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.include(directives.api.models.WindowFunctions),d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.link=a(this.link,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.link=function(a,b,c,d){var e=this;if(!this.validateLinkedScope(a))return this.$timeout(function(){var f;return f=angular.isDefined(c.animate)&&e.isFalse(c.animate),e.linkInit(b,d,a,f,angular.isDefined(c.click)),e.watchCoords(a),e.watchIcon(a),e.watchDestroy(a)})},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"&show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this),this.markers={},this.mapCtrl=void 0}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.validateLinkedScope=function(a){return d.__super__.validateLinkedScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.linkInit=function(a,b,c,d,e){var f,g;return this.mapCtrl=b,g=this.createMarkerOptions(b,c.coords,c.icon,d,this.DEFAULTS),f=new google.maps.Marker(g),this.markers[c.$id]=f,a.data("instance",f),google.maps.event.addListener(f,"click",function(){return e&&null!=c.click?c.click():void 0})},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?c?(b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(c.latitude,c.longitude)),b.markers[a.$id].setVisible(null!=c.latitude&&null!=c.longitude)):b.markers[a.$id].setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.markers[a.$id].icon=c,b.markers[a.$id].setMap(null),b.markers[a.$id].setMap(b.mapCtrl.getMap()),b.markers[a.$id].setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.markers[a.$id].setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.markers[a.$id].setMap(null),delete b.markers[a.$id]})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.linkInit=a(this.linkInit,this),this.validateLinkedScope=a(this.validateLinkedScope,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.markers=[],this.markersIndex=0,this.mapCtrl=void 0,this.$timeout=b,this.doClick=void 0,this.animate=void 0,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateLinkedScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateLinkedScope.call(this,a)||b},d.prototype.linkInit=function(a,b,c,d,e){return this.mapCtrl=b,this.doClick=e,this.animate=d,this.watchModels(c),this.createMarkers(c)},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.MarkerModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.WindowModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.link=a(this.link,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var h,i,j,k,l;for(d.__super__.constructor.call(this,b,c,e,f),i=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],l=this.scopePropNames,j=0,k=l.length;k>j;j++)h=l[j],this[h+"Key"]=void 0;this.linked=void 0,this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(i)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]||void 0===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.link=function(a,b,c,d){var e=this;return this.linked=new directives.api.utils.Linked(a,b,c,d),this.$timeout(function(){return e.watchOurScope(a),e.createChildScopesWindows()},50)},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]||void 0===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,h),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.include(directives.api.models.child.WindowFunctions),d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.models.child",function(){return this.WindowFunctions={watchShow:function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},handleClick:function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},showWindow:function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},hideWindow:function(a){return a.close()}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this);var g,h=this;g=this,this.validateScope(b)||(this.mapCtrl=e,this.doClick=doClick,this.animate=animate,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){var a;return a=angular.isDefined(d.animate)&&h.isFalse(d.animate),h.watchModels(b),h.createMarkers(b),h.watchCoords(b),h.watchIcon(b),h.watchDestroy(b)}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){var a;return this.IWindowParentModel=function(c){function d(){return a=d.__super__.constructor.apply(this,arguments)}return b(d,c),d.include(directives.api.utils.GmapUtil),d.prototype.DEFAULTS={},d.prototype.link=function(a,b,c,d,e,f,g,h){var i;return i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this);var h,i;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",this.$log.info(this),h=this.createMarkerOptions(f,b.coords,b.icon,animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),this.scope=b,google.maps.event.addListener(gMarker,"click",function(){return doClick&&null!=b.click?b.click():void 0})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.controller=function(){return this.getMarker=function(){return this.gMarker}},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a&&"undefined"!=typeof gMarker&&null!==gMarker?(b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c&&"undefined"!=typeof gMarker&&null!==gMarker?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return void 0===b.gMarker?(delete b,void 0):(b.gMarker.setMap(null),delete b.gMarker,delete b)})},d}(directives.api.models.parent.IMarkerParent)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.WindowModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(b,d,a,animate,doClick,this.$timeout)},d}(directives.api.directives.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;if(google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})}),google.maps.event.addListener(k,"center_changed",function(){var a=k.center;b(function(){e.$apply(function(b){k.dragging||(b.center.latitude=a.lat(),b.center.longitude=a.lng())})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var m=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var n in e.events)e.events.hasOwnProperty(n)&&angular.isFunction(e.events[n])&&google.maps.event.addListener(k,n,m(n))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b&&!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bangular-google-maps example + + dynamicMarkers + + + + center
 {{ map.center.latitude | number:4 }} lat
 {{ map.center.longitude | number:4 }} lng
diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index 9a6a9bb20..7a53eb1a0 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -8,15 +8,6 @@ ### @module "directives.api", -> class @IMarker extends oo.BaseObject - # Animation is enabled by default - DEFAULTS: { animation: google.maps.Animation.DROP } - - # Check if a value is literally false - # @param value the value to test - # @returns {boolean} true if value is literally false, false otherwise - isFalse: (value) -> - ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) != -1 - constructor: ($timeout) -> self = @ @clsName = "IMarker" @@ -32,37 +23,7 @@ icon: '=icon', click: '&click' } - controller: ($scope, $element) -> throw new Exception("Not Implemented!!") - - validateLinkedScope:(scope)=> - ret = angular.isUndefined(scope.coords) or - scope.coords == undefined - if(ret) - @$log.error(@clsName + ": no valid coords attribute found") - ret - - link: (scope, element, attrs, mapCtrl) => - # Validate required properties - if (@validateLinkedScope(scope)) - return - # Wrap marker initialization inside a $timeout() call to make sure the map is created already - @$timeout( => - animate = angular.isDefined(attrs.animate) and @isFalse(attrs.animate) - @linkInit(element,mapCtrl,scope,animate,angular.isDefined(attrs.click)) - @watchCoords(scope) - @watchIcon(scope) - @watchDestroy(scope) - ) - - watchCoords:(scope) => - throw new Exception("Not Implemented!!") - - watchIcon:(scope) => - throw new Exception("Not Implemented!!") - watchDestroy:(scope) => - throw new Exception("Not Implemented!!") - - linkInit:(element,mapCtrl,scope,animate)=> - throw new Exception("Not Implemented!!") \ No newline at end of file + link: (scope, element, attrs, ctrl) => + throw new Exception("Not implemented!!") \ No newline at end of file diff --git a/src/coffee/directives/api/i-window.coffee b/src/coffee/directives/api/i-window.coffee index d4f334b59..d6e7bea28 100644 --- a/src/coffee/directives/api/i-window.coffee +++ b/src/coffee/directives/api/i-window.coffee @@ -3,10 +3,6 @@ ### @module "directives.api", -> class @IWindow extends oo.BaseObject - @include directives.api.utils.GmapUtil - # Animation is enabled by default - DEFAULTS: {} - constructor: ($timeout, $compile, $http, $templateCache) -> self = @ @clsName = "IWindow" @@ -17,7 +13,7 @@ @require = undefined @scope= { coords: '=coords', - show: '&show', + show: '=show', templateUrl: '=templateurl', templateParameter: '=templateparameter', isIconVisibleOnClick: '=isiconvisibleonclick', diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index b87df2d52..bbb9103c2 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -4,66 +4,16 @@ ### @module "directives.api", -> class @Marker extends directives.api.IMarker - @include directives.api.utils.GmapUtil - constructor: ($timeout) -> super($timeout) self = @ @template = '' @clsName = "Marker" @$log.info(@) - @markers = {} - @mapCtrl = undefined - - + controller:($scope, $element) -> @getMarker = -> $element.data('instance') - validateLinkedScope:(scope)=> - super(scope) or angular.isUndefined(scope.coords.latitude) or angular.isUndefined(scope.coords.longitude) - - # if we have made it here all attributes are valid so we can initialize and glue things together - linkInit:(element,mapCtrl,scope,animate,doClick) => - #linked scope is 1:1 per marker - @mapCtrl = mapCtrl - opts = @createMarkerOptions(mapCtrl,scope.coords,scope.icon,animate,@DEFAULTS) - - #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the index) - gMarker = new google.maps.Marker(opts) - @markers[scope.$id] = gMarker - element.data('instance', gMarker) - - google.maps.event.addListener(gMarker, 'click', -> - if doClick and scope.click? - scope.click() - ) - - watchCoords:(scope) => - scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - if (newValue) - @markers[scope.$id].setMap(@mapCtrl.getMap()) - @markers[scope.$id].setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - @markers[scope.$id].setVisible(newValue.latitude? and newValue.longitude?) - else - # Remove marker - @markers[scope.$id].setMap(null) - , true) - - watchIcon:(scope) => - scope.$watch('icon', (newValue, oldValue) => - if (newValue != oldValue) - @markers[scope.$id].icon = newValue - @markers[scope.$id].setMap(null) - @markers[scope.$id].setMap(@mapCtrl.getMap()) - @markers[scope.$id].setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) - @markers[scope.$id].setVisible(coords.latitude and coords.longitude?) - , true) - - watchDestroy:(scope)=> - scope.$on("$destroy", => - #remove from gMaps and then free resources - @markers[scope.$id].setMap(null) - delete @markers[scope.$id] - ) + link: (scope, element, attrs, ctrl) => + new directives.api.models.parent.MarkerParentModel(scope, element, attrs, ctrl, @$timeout) \ No newline at end of file diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index c9f63e2f0..dff0baa1a 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -16,76 +16,13 @@ not 1:1 in this setting. self = @ @template = '' @clsName = "Markers" - @scope.models = '=models' - @markers = [] - @markersIndex = 0 - @mapCtrl = undefined + @scope.models = '=models' @$timeout = $timeout - @doClick = undefined - @animate = undefined @$log.info(@) - + controller:($scope, $element) -> @getMarkersScope = -> $scope - validateLinkedScope:(scope)=> - modelsNotDefined = angular.isUndefined(scope.models) or scope.models == undefined - if(modelsNotDefined) - @$log.error(@clsName + ": no valid models attribute found") - - super(scope) or modelsNotDefined - - # if we have made it here all attributes are valid so we can initialize and glue things together - linkInit:(element,mapCtrl,scope,animate,doClick) => - @mapCtrl = mapCtrl - @doClick = doClick - @animate = animate - @watchModels(scope) - @createMarkers(scope) - - createMarkers:(scope) => - for model in scope.models - do(model) => - @markers.push( - new directives.api.models.MarkerModel(@markersIndex,model,scope,@mapCtrl,@$timeout,(index) => - delete @markers[index] - ,@DEFAULTS,@doClick) - ) - @markersIndex++ - #put MarkerModels into local scope - scope.markerModels = @markers - - watchModels:(scope) => - scope.$watch('models', (newValue, oldValue) => - if (newValue != oldValue) - for oldM in @markers - do(oldM) => - oldM.destroy() - delete @markers - @markers = [] - @markersIndex = 0 - @createMarkers(scope) - - , true) - - watchCoords:(scope) => - scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - model.coordsKey = newValue for model in @markers - , true) - - watchIcon:(scope) => - scope.$watch('icon', (newValue, oldValue) => - if (newValue != oldValue) - model.iconKey = newValue for model in @markers - , true) - - watchDestroy:(scope)=> - #need to figure out how to handle individual destroys - #slap index to the external model so that when they pass external back - #for destroy we have a lookup? - #this will require another attribute for destroySingle(marker) - scope.$on("$destroy", => - model.destroy() for model in @markers - ) \ No newline at end of file + link: (scope, element, attrs, ctrl) => + new directives.api.models.parent.MarkersParentModel(scope, element, attrs, ctrl, @$timeout) \ No newline at end of file diff --git a/src/coffee/directives/api/models/marker-model.coffee b/src/coffee/directives/api/models/child/marker-child-model.coffee similarity index 95% rename from src/coffee/directives/api/models/marker-model.coffee rename to src/coffee/directives/api/models/child/marker-child-model.coffee index fbef13a7f..e2a5c183a 100644 --- a/src/coffee/directives/api/models/marker-model.coffee +++ b/src/coffee/directives/api/models/child/marker-child-model.coffee @@ -1,5 +1,5 @@ -@module "directives.api.models", -> - class @MarkerModel extends oo.BaseObject +@module "directives.api.models.child", -> + class @MarkerChildModel extends oo.BaseObject @include directives.api.utils.GmapUtil constructor:(index,model,parentScope,gMap,$timeout,notifyLocalDestroy,defaults,doClick)-> @index = index diff --git a/src/coffee/directives/api/models/window-functions.coffee b/src/coffee/directives/api/models/child/window-child-model.coffee similarity index 60% rename from src/coffee/directives/api/models/window-functions.coffee rename to src/coffee/directives/api/models/child/window-child-model.coffee index 3b16f98fe..e061ee16e 100644 --- a/src/coffee/directives/api/models/window-functions.coffee +++ b/src/coffee/directives/api/models/child/window-child-model.coffee @@ -1,13 +1,27 @@ -### - Functions are using entireley local variables as to try and reuse functionality. - Hopefully this will work when an HTML Element is created or not for an InfoWindow. +@module "directives.api.models.child", -> + class @WindowChildModel extends oo.BaseObject + constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$http,$templateCache,$compile)-> + @scope = scope + @opts = opts + @mapCtrl = mapCtrl + @markerCtrl = markerCtrl + @isIconVisibleOnClick = isIconVisibleOnClick + @initialMarkerVisibility = if @markerCtrl? then @markerCtrl.getVisible() else false + @$log = directives.api.utils.Logger + @$http = $http + @$templateCache = $templateCache + @$compile = $compile + @gWin = new google.maps.InfoWindow(opts) + # Open window on click + @markerCtrl.setClickable(true) if @markerCtrl? + + @handleClick(@scope,@mapCtrl,@markerCtrl,@gWin,@isIconVisibleOnClick,@initialMarkerVisibility) + @watchShow(scope,$http,$templateCache,@$compile,@gWin,@showWindow,@hideWindow,@mapCtrl) + + @$log.info(@) - IE if another window-model needs to be derrived for Windows or other Window directives. -### -@module "directives.api.models", -> - @WindowFunctions = watchShow:(scope,$http,$templateCache,$compile,gWin,showHandle,hideHandle,mapCtrl) -> - scope.$watch('show()', (newValue, oldValue) -> + scope.$watch('show', (newValue, oldValue) -> if (newValue != oldValue) if (newValue) showHandle(scope,$http,$templateCache,$compile,gWin,mapCtrl) @@ -47,4 +61,11 @@ gWin.open(mapCtrl) hideWindow: (gWin) -> - gWin.close() \ No newline at end of file + gWin.close() + + destroy:()=> + @hideWindow(@gWin) + @scope.$destroy() + delete @gWin + delete @ + diff --git a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee new file mode 100644 index 000000000..c3978909b --- /dev/null +++ b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee @@ -0,0 +1,56 @@ +### + - interface for all markers to derrive from + - to enforce a minimum set of requirements + - attributes + - coords + - icon + - implementation needed on watches +### +@module "directives.api.models.parent", -> + class @IMarkerParentModel extends oo.BaseObject + # Animation is enabled by default + DEFAULTS: { animation: google.maps.Animation.DROP } + + # Check if a value is literally false + # @param value the value to test + # @returns {boolean} true if value is literally false, false otherwise + isFalse: (value) -> + ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value) != -1 + + constructor: (scope, element, attrs, mapCtrl,$timeout) -> + self = @ + # Validate required properties + if (@validateScope(scope)) + return + @animate = angular.isDefined(attrs.animate) and @isFalse(attrs.animate) + @doClick = angular.isDefined(attrs.click) + @mapCtrl = mapCtrl + @clsName = "IMarker" + @$log = directives.api.utils.Logger + @$timeout = $timeout + # Wrap marker initialization inside a $timeout() call to make sure the map is created already + @$timeout( => + @watchCoords(scope) + @watchIcon(scope) + @watchDestroy(scope) + ) + + onTimeOut:(scope)=> + + validateScope:(scope)=> + ret = angular.isUndefined(scope.coords) or + scope.coords == undefined + if(ret) + @$log.error(@clsName + ": no valid coords attribute found") + ret + + watchCoords:(scope) => + throw new Exception("Not Implemented!!") + + watchIcon:(scope) => + throw new Exception("Not Implemented!!") + watchDestroy:(scope) => + throw new Exception("Not Implemented!!") + + linkInit:(element,mapCtrl,scope,animate)=> + throw new Exception("Not Implemented!!") \ No newline at end of file diff --git a/src/coffee/directives/api/models/parent/i-window-parent-model.coffee b/src/coffee/directives/api/models/parent/i-window-parent-model.coffee new file mode 100644 index 000000000..8ea86687c --- /dev/null +++ b/src/coffee/directives/api/models/parent/i-window-parent-model.coffee @@ -0,0 +1,17 @@ +### + - interface directive for all window(s) to derrive from +### +@module "directives.api.models.parent", -> + class @IWindowParentModel extends oo.BaseObject + @include directives.api.utils.GmapUtil + # Animation is enabled by default + DEFAULTS: {} + + constructor: (scope, element, attrs, ctrls,$timeout, $compile, $http, $templateCache) -> + self = @ + @clsName = "directives.api.models.parent.IWindow" + @$log = directives.api.utils.Logger + @$timeout = $timeout + @$compile = $compile + @$http = $http + @$templateCache = $templateCache \ No newline at end of file diff --git a/src/coffee/directives/api/models/parent/marker-parent-model.coffee b/src/coffee/directives/api/models/parent/marker-parent-model.coffee new file mode 100644 index 000000000..2386339fd --- /dev/null +++ b/src/coffee/directives/api/models/parent/marker-parent-model.coffee @@ -0,0 +1,57 @@ +### + Basic Directive api for a marker. Basic in the sense that this directive contains 1:1 on scope and model. + Thus there will be one html element per marker within the directive. +### +@module "directives.api.models.parent", -> + class @MarkerParentModel extends directives.api.models.parent.IMarkerParentModel + @include directives.api.utils.GmapUtil + constructor: (scope, element, attrs, mapCtrl,$timeout) -> + super(scope, element, attrs, mapCtrl,$timeout) + self = @ + @clsName = "MarkerParentModel" + opts = @createMarkerOptions(mapCtrl,scope.coords,scope.icon,@animate,@DEFAULTS) + #using scope.$id as the identifier for a marker as scope.$id should be unique, no need for an index (as it is the index) + @gMarker = new google.maps.Marker(opts) + element.data('instance', @gMarker) + @scope = scope + google.maps.event.addListener(@gMarker, 'click', -> + if @doClick and scope.click? + scope.click() + ) + @$log.info(@) + + validateScope:(scope)=> + super(scope) or angular.isUndefined(scope.coords.latitude) or angular.isUndefined(scope.coords.longitude) + + watchCoords:(scope) => + scope.$watch('coords', (newValue, oldValue) => + if (newValue != oldValue) + if (newValue and @gMarker?) + @gMarker.setMap(@mapCtrl.getMap()) + @gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) + @gMarker.setVisible(newValue.latitude? and newValue.longitude?) + else + # Remove marker + @gMarker.setMap(null) + , true) + + watchIcon:(scope) => + scope.$watch('icon', (newValue, oldValue) => + if (newValue != oldValue and @gMarker?) + @gMarker.icon = newValue + @gMarker.setMap(null) + @gMarker.setMap(@mapCtrl.getMap()) + @gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) + @gMarker.setVisible(coords.latitude and coords.longitude?) + , true) + + watchDestroy:(scope)=> + scope.$on("$destroy", => + if @gMarker == undefined + delete @ + return + #remove from gMaps and then free resources + @gMarker.setMap(null) + delete @gMarker + delete @ + ) diff --git a/src/coffee/directives/api/models/parent/markers-parent-model.coffee b/src/coffee/directives/api/models/parent/markers-parent-model.coffee new file mode 100644 index 000000000..dee4d08fc --- /dev/null +++ b/src/coffee/directives/api/models/parent/markers-parent-model.coffee @@ -0,0 +1,67 @@ +@module "directives.api.models.parent", -> + class @MarkersParentModel extends directives.api.models.parent.IMarkerParentModel + constructor: (scope, element, attrs, mapCtrl,$timeout) -> + super(scope, element, attrs, mapCtrl,$timeout) + self = @ + @clsName = "MarkersParentModel" + @markers = [] + @markersIndex = 0 + @scope = scope + @$log.info(@) + + onTimeOut:(scope)=> + @watchModels(scope) + @createMarkers(scope) + + validateScope:(scope)=> + modelsNotDefined = angular.isUndefined(scope.models) or scope.models == undefined + if(modelsNotDefined) + @$log.error(@clsName + ": no valid models attribute found") + + super(scope) or modelsNotDefined + + createMarkers:(scope) => + for model in scope.models + do(model) => + @markers.push( + new directives.api.models.child.MarkerChildModel(@markersIndex,model,scope,@mapCtrl,@$timeout,(index) => + delete @markers[index] + ,@DEFAULTS,@doClick) + ) + @markersIndex++ + #put MarkerModels into local scope + scope.markerModels = @markers + + watchModels:(scope) => + scope.$watch('models', (newValue, oldValue) => + if (newValue != oldValue) + for oldM in @markers + do(oldM) => + oldM.destroy() + delete @markers + @markers = [] + @markersIndex = 0 + @createMarkers(scope) + + , true) + + watchCoords:(scope) => + scope.$watch('coords', (newValue, oldValue) => + if (newValue != oldValue) + model.coordsKey = newValue for model in @markers + , true) + + watchIcon:(scope) => + scope.$watch('icon', (newValue, oldValue) => + if (newValue != oldValue) + model.iconKey = newValue for model in @markers + , true) + + watchDestroy:(scope)=> + #need to figure out how to handle individual destroys + #slap index to the external model so that when they pass external back + #for destroy we have a lookup? + #this will require another attribute for destroySingle(marker) + scope.$on("$destroy", => + model.destroy() for model in @markers + ) \ No newline at end of file diff --git a/src/coffee/directives/api/models/parent/windows-parent-model.coffee b/src/coffee/directives/api/models/parent/windows-parent-model.coffee new file mode 100644 index 000000000..a83af7a73 --- /dev/null +++ b/src/coffee/directives/api/models/parent/windows-parent-model.coffee @@ -0,0 +1,141 @@ +### + Windows directive where many windows map to the models property +### +@module "directives.api.models.parent", -> + class @WindowsParentModel extends directives.api.models.parent.IWindowParentModel + constructor: (scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache,$interpolate) -> + super(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache,$interpolate) + self = @ + @$interpolate = $interpolate + @clsName = "WindowsParentModel" + @windows = [] + @windwsIndex = 0 + @scopePropNames = ['show','coords','templateUrl','templateParameter', + 'isIconVisibleOnClick','closeClick'] + #setting up local references to propety keys IE: @coordsKey + @[name + 'Key'] = undefined for name in @scopePropNames + @linked = new directives.api.utils.Linked(scope,element,attrs,ctrls) + @models = undefined + @contentKeys = undefined #model keys to parse html angular content + @isIconVisibleOnClick = undefined + @firstTime = true + @$log.info(self) + + @$timeout( => + @watchOurScope(scope) + @createChildScopesWindows() + ,50) + + #watch this scope(Parent to all WindowModels), these updates reflect expression / Key changes + #thus they need to be pushed to all the children models so that they are bound to the correct objects / keys + watch:(scope,name,nameKey) => + scope.$watch(name, (newValue, oldValue) => + if (newValue != oldValue) + @[nameKey] = if typeof newValue == 'function' then newValue() else newValue + for model in @windows + do(model) => + model.scope[name] = if @[nameKey] == 'self' then model else model[@[nameKey]] + ,true) + + watchModels:(scope) => + scope.$watch('models', (newValue, oldValue) => + if (newValue != oldValue) + for model in @windows + do(model) => + model.destroy() + # delete @windows + @windows = [] + @windowsIndex = 0 + @createChildScopesWindows() + , true) + + watchDestroy:(scope)=> + scope.$on("$destroy", => + model.destroy() for model in @windows + delete @windows + @windows = [] + @windowsIndex = 0 + ) + + watchOurScope:(scope) => + for name in @scopePropNames + do(name) => + nameKey = name + 'Key' + @[nameKey] = if typeof scope[name] == 'function' then scope[name]() else scope[name] + @watch(scope,name,nameKey) + + createChildScopesWindows: => + ### + being that we cannot tell the difference in Key String vs. a normal value string (TemplateUrl) + we will assume that all scope values are string expressions either pointing to a key (propName) or using + 'self' to point the model as container/object of interest. + + This may force redundant information into the model, but this appears to be the most flexible approach. + ### + @isIconVisibleOnClick = true + if angular.isDefined(@linked.attrs.isiconvisibleonclick) + isIconVisibleOnClick = @linked.scope.isIconVisibleOnClick + gMap = @linked.ctrls[0].getMap() + markersScope = if @linked.ctrls.length > 1 and @linked.ctrls[1]? then @linked.ctrls[1].getMarkersScope() else undefined + + modelsNotDefined = angular.isUndefined(@linked.scope.models) or scope.models == undefined + + if(modelsNotDefined and (markersScope == undefined or markersScope.markerModels == undefined or markersScope.models == undefined )) + @$log.info("No models to create windows from! Need direct models or models derrived from markers!") + return + if gMap? + #at the very least we need a Map, the marker is optional as we can create Windows without markers + if @linked.scope.models? + #we are creating windows with no markers + @models = @linked.scope.models + if(@firstTime) + @watchModels(@linked.scope) + @watchDestroy(@linked.scope) + @setContentKeys(@linked.scope.models) #only setting content keys once per model array + @createWindow(model,undefined,gMap) for model in @linked.scope.models + else + #creating windows with parent markers + @models = markersScope.models + if(@firstTime) + @watchModels(markersScope) + @watchDestroy(markersScope) + @setContentKeys(markersScope.models) #only setting content keys once per model array + for mm in markersScope.markerModels + do(mm) => + @createWindow(mm.model,mm.gMarker,gMap) + @firstTime = false + + setContentKeys:(models)=> + if(models.length > 0) + @contentKeys = Object.keys(models[0]) + + createWindow: (model,gMarker,gMap)=> + ### + Create ChildScope to Mimmick an ng-repeat created scope, must define the below scope + scope= { + coords: '=coords', + show: '&show', + templateUrl: '=templateurl', + templateParameter: '=templateparameter', + isIconVisibleOnClick: '=isiconvisibleonclick', + closeClick: '&closeclick' + } + ### + childScope = @linked.scope.$new(false) + for name in @scopePropNames + do (name) => + nameKey = name + 'Key' + childScope[name] = if @[nameKey] == 'self' then model else model[@[nameKey]] + parsedContent = @interpolateContent(@linked.element.html(),model) + opts = @createWindowOptions(gMarker,childScope,parsedContent,@DEFAULTS) + @windows.push( + new directives.api.models.WindowModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile) + ) + + interpolateContent: (content,model) => + if @contentKeys == undefined or @contentKeys.length == 0 + return + exp = @$interpolate(content) + interpModel = {} + interpModel[key] = model[key] for key in @contentKeys + exp(interpModel) \ No newline at end of file diff --git a/src/coffee/directives/api/models/window-model.coffee b/src/coffee/directives/api/models/window-model.coffee deleted file mode 100644 index 00f80023b..000000000 --- a/src/coffee/directives/api/models/window-model.coffee +++ /dev/null @@ -1,30 +0,0 @@ -@module "directives.api.models", -> - class @WindowModel extends oo.BaseObject - @include directives.api.models.WindowFunctions - constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$http,$templateCache,$compile)-> - @scope = scope - @opts = opts - @mapCtrl = mapCtrl - @markerCtrl = markerCtrl - @isIconVisibleOnClick = isIconVisibleOnClick - @initialMarkerVisibility = if @markerCtrl? then @markerCtrl.getVisible() else false - @$log = directives.api.utils.Logger - @$http = $http - @$templateCache = $templateCache - @$compile = $compile - @gWin = new google.maps.InfoWindow(opts) - # Open window on click - @markerCtrl.setClickable(true) if @markerCtrl? - - @handleClick(@scope,@mapCtrl,@markerCtrl,@gWin,@isIconVisibleOnClick,@initialMarkerVisibility) - @watchShow(scope,$http,$templateCache,@$compile,@gWin,@showWindow,@hideWindow,@mapCtrl) - - @$log.info(@) - - - destroy:()=> - @hideWindow(@gWin) - @scope.$destroy() - delete @gWin - delete @ - diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee index 6b12f501e..488ab86e5 100644 --- a/src/coffee/directives/api/window.coffee +++ b/src/coffee/directives/api/window.coffee @@ -4,8 +4,8 @@ ### @module "directives.api", -> class @Window extends directives.api.IWindow - - constructor: ($timeout, $compile, $http, $templateCache,$interpolate) -> + @include directives.api.utils.GmapUtil + constructor: ($timeout, $compile, $http, $templateCache) -> super($timeout, $compile, $http, $templateCache) self = @ @clsName = "Window" @@ -24,7 +24,7 @@ opts = @createWindowOptions(markerCtrl,scope,element.html(),@DEFAULTS) if mapCtrl? #at the very least we need a Map, the marker is optional as we can create Windows without markers - new directives.api.models.WindowModel( + new directives.api.models.child.WindowChildModel( scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,@$http,@$templateCache,@$compile ) diff --git a/src/coffee/directives/api/windows.coffee b/src/coffee/directives/api/windows.coffee index e25b13342..63668f96d 100644 --- a/src/coffee/directives/api/windows.coffee +++ b/src/coffee/directives/api/windows.coffee @@ -3,7 +3,6 @@ ### @module "directives.api", -> class @Windows extends directives.api.IWindow - constructor: ($timeout, $compile, $http, $templateCache,$interpolate) -> super($timeout, $compile, $http, $templateCache) self = @ @@ -12,137 +11,8 @@ @require= ['^googleMap', '^?markers'] @template = '' @scope.models = '=models' #if undefined it will try get a markers models - @windows = [] - @windwsIndex = 0 - @scopePropNames = ['show','coords','templateUrl','templateParameter', - 'isIconVisibleOnClick','closeClick'] - #setting up local references to propety keys IE: @coordsKey - @[name + 'Key'] = undefined for name in @scopePropNames - @linked = undefined - @models = undefined - @contentKeys = undefined #model keys to parse html angular content - @isIconVisibleOnClick = undefined - @firstTime = true @$log.info(self) - #watch this scope(Parent to all WindowModels), these updates reflect expression / Key changes - #thus they need to be pushed to all the children models so that they are bound to the correct objects / keys - watch:(scope,name,nameKey) => - scope.$watch(name, (newValue, oldValue) => - if (newValue != oldValue) - @[nameKey] = if typeof newValue == 'function' then newValue() else newValue - for model in @windows - do(model) => - model.scope[name] = if (@[nameKey] == 'self' or @[nameKey] == undefined) then model else model[@[nameKey]] - ,true) - - watchModels:(scope) => - scope.$watch('models', (newValue, oldValue) => - if (newValue != oldValue) - for model in @windows - do(model) => - model.destroy() - # delete @windows - @windows = [] - @windowsIndex = 0 - @createChildScopesWindows() - , true) - - watchDestroy:(scope)=> - scope.$on("$destroy", => - model.destroy() for model in @windows - delete @windows - @windows = [] - @windowsIndex = 0 - ) - - watchOurScope:(scope) => - for name in @scopePropNames - do(name) => - nameKey = name + 'Key' - @[nameKey] = if typeof scope[name] == 'function' then scope[name]() else scope[name] - @watch(scope,name,nameKey) - link: (scope, element, attrs, ctrls) => - @linked = new directives.api.utils.Linked(scope,element,attrs,ctrls) - - @$timeout( => - @watchOurScope(scope) - @createChildScopesWindows() - ,50) - - createChildScopesWindows: => - ### - being that we cannot tell the difference in Key String vs. a normal value string (TemplateUrl) - we will assume that all scope values are string expressions either pointing to a key (propName) or using - 'self' to point the model as container/object of interest. - - This may force redundant information into the model, but this appears to be the most flexible approach. - ### - @isIconVisibleOnClick = true - if angular.isDefined(@linked.attrs.isiconvisibleonclick) - isIconVisibleOnClick = @linked.scope.isIconVisibleOnClick - gMap = @linked.ctrls[0].getMap() - markersScope = if @linked.ctrls.length > 1 and @linked.ctrls[1]? then @linked.ctrls[1].getMarkersScope() else undefined - - modelsNotDefined = angular.isUndefined(@linked.scope.models) or scope.models == undefined - - if(modelsNotDefined and (markersScope == undefined or markersScope.markerModels == undefined or markersScope.models == undefined )) - @$log.info("No models to create windows from! Need direct models or models derrived from markers!") - return - if gMap? - #at the very least we need a Map, the marker is optional as we can create Windows without markers - if @linked.scope.models? - #we are creating windows with no markers - @models = @linked.scope.models - if(@firstTime) - @watchModels(@linked.scope) - @watchDestroy(@linked.scope) - @setContentKeys(@linked.scope.models) #only setting content keys once per model array - @createWindow(model,undefined,gMap) for model in @linked.scope.models - else - #creating windows with parent markers - @models = markersScope.models - if(@firstTime) - @watchModels(markersScope) - @watchDestroy(markersScope) - @setContentKeys(markersScope.models) #only setting content keys once per model array - for mm in markersScope.markerModels - do(mm) => - @createWindow(mm.model,mm.gMarker,gMap) - @firstTime = false - - setContentKeys:(models)=> - if(models.length > 0) - @contentKeys = Object.keys(models[0]) - - createWindow: (model,gMarker,gMap)=> - ### - Create ChildScope to Mimmick an ng-repeat created scope, must define the below scope - scope= { - coords: '=coords', - show: '&show', - templateUrl: '=templateurl', - templateParameter: '=templateparameter', - isIconVisibleOnClick: '=isiconvisibleonclick', - closeClick: '&closeclick' - } - ### - childScope = @linked.scope.$new(false) - for name in @scopePropNames - do (name) => - nameKey = name + 'Key' - childScope[name] = if (@[nameKey] == 'self' or @[nameKey] == undefined) then model else model[@[nameKey]] - parsedContent = @interpolateContent(@linked.element.html(),model) - opts = @createWindowOptions(gMarker,childScope,parsedContent,@DEFAULTS) - @windows.push( - new directives.api.models.WindowModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile) - ) - - interpolateContent: (content,model) => - if @contentKeys == undefined or @contentKeys.length == 0 - return - exp = @$interpolate(content) - interpModel = {} - interpModel[key] = model[key] for key in @contentKeys - exp(interpModel) \ No newline at end of file + new directives.api.models.parent.WindowsParentModel(scope, element, attrs, ctrls, @$timeout, + @$compile, @$http, @$templateCache,@$interpolate) \ No newline at end of file diff --git a/src/js/directives/marker.js b/src/js/directives/marker.js index 60605fb52..e88f34efc 100644 --- a/src/js/directives/marker.js +++ b/src/js/directives/marker.js @@ -38,5 +38,6 @@ * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('marker', ['$timeout', function($timeout){ - return new directives.api.Marker($timeout);}]); +angular.module('google-maps').directive('marker', ['$timeout', function ($timeout) { + return new directives.api.Marker($timeout); +}]); diff --git a/src/js/directives/markers.js b/src/js/directives/markers.js index 32ffd958f..6fa2f4ddd 100644 --- a/src/js/directives/markers.js +++ b/src/js/directives/markers.js @@ -38,5 +38,6 @@ * {attribute animate optional} if set to false, the marker won't be animated (on by default) */ -angular.module('google-maps').directive('markers', ['$timeout', function($timeout){ - return new directives.api.Markers($timeout);}]); +angular.module('google-maps').directive('markers', ['$timeout', function ($timeout) { + return new directives.api.Markers($timeout); +}]); From 2cd90a51bb1ef03c7e83341c65e9d4a98e9a84e2 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Sun, 28 Jul 2013 17:15:24 -0400 Subject: [PATCH 28/41] mostly everything appears to be working --- .../directives/api/models/parent/i-marker-parent-model.coffee | 1 + .../directives/api/models/parent/windows-parent-model.coffee | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee index c3978909b..efdbaf2c8 100644 --- a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee @@ -33,6 +33,7 @@ @watchCoords(scope) @watchIcon(scope) @watchDestroy(scope) + @onTimeOut(scope) ) onTimeOut:(scope)=> diff --git a/src/coffee/directives/api/models/parent/windows-parent-model.coffee b/src/coffee/directives/api/models/parent/windows-parent-model.coffee index a83af7a73..62f46b695 100644 --- a/src/coffee/directives/api/models/parent/windows-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/windows-parent-model.coffee @@ -129,7 +129,7 @@ parsedContent = @interpolateContent(@linked.element.html(),model) opts = @createWindowOptions(gMarker,childScope,parsedContent,@DEFAULTS) @windows.push( - new directives.api.models.WindowModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile) + new directives.api.models.child.WindowChildModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile) ) interpolateContent: (content,model) => From 6c065300a0a100cb2c506d5186b0911cd9a7b2b0 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 08:39:11 -0400 Subject: [PATCH 29/41] turning logging on for the example --- dist/angular-google-maps.min.js | 2 +- example/example-controller.js | 2 +- example/example.html | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 38e2b8f7d..0af9681c3 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -1,4 +1,4 @@ -/*! angular-google-maps 0.0.0 2013-07-28 +/*! angular-google-maps 0.0.0 2013-07-29 * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ diff --git a/example/example-controller.js b/example/example-controller.js index 45ea115ed..300153651 100644 --- a/example/example-controller.js +++ b/example/example-controller.js @@ -50,7 +50,7 @@ function ExampleController ($scope, $timeout, $log) { icon: 'plane.png', latitude: 35, longitude: -125, - showWindow: true + showWindow: false } ], dynamicMarkers: [], diff --git a/example/example.html b/example/example.html index d2ccb9fbc..f2acd054b 100644 --- a/example/example.html +++ b/example/example.html @@ -179,6 +179,9 @@

angular-google-maps example

+ From 6ebe34b9f4d65be843ae566975a95f1e81b91346 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 09:34:13 -0400 Subject: [PATCH 30/41] clicking and show working for Markers and Windows --- example/example-controller.js | 22 ++++++++++++++++--- example/example.html | 6 ++--- .../models/child/marker-child-model.coffee | 2 ++ .../parent/i-marker-parent-model.coffee | 2 +- .../models/parent/marker-parent-model.coffee | 4 ++-- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/example/example-controller.js b/example/example-controller.js index 300153651..507a2412d 100644 --- a/example/example-controller.js +++ b/example/example-controller.js @@ -9,6 +9,11 @@ function ExampleController ($scope, $timeout, $log) { // See http://googlegeodevelopers.blogspot.ca/2013/05/a-fresh-new-look-for-maps-api-for-all.html google.maps.visualRefresh = true; + onMarkerClicked = function(marker){ + marker.showWindow = true; + window.alert("Marker: lat: " + marker.latitude +", lon: " + marker.longitude + " clicked!!") + }; + angular.extend($scope, { map: { center: { @@ -126,16 +131,22 @@ function ExampleController ($scope, $timeout, $log) { _.each($scope.map.markers,function(marker){ marker.closeClick = function(){ - this.showWindow = false; + marker.showWindow = false; $scope.$apply(); }; + marker.onClicked = function(){ + onMarkerClicked(marker); + }; }); _.each($scope.map.markers2,function(marker){ marker.closeClick = function(){ - this.showWindow = false; + marker.showWindow = false; $scope.$apply(); }; + marker.onClicked = function(){ + onMarkerClicked(marker); + }; }); $scope.removeMarkers = function () { @@ -146,6 +157,8 @@ function ExampleController ($scope, $timeout, $log) { $scope.map.clickedMarker = null; }; + $scope.onMarkerClicked = onMarkerClicked + $timeout(function () { $scope.map.infoWindow.show = true; dynamicMarkers = [ @@ -168,9 +181,12 @@ function ExampleController ($scope, $timeout, $log) { ]; _.each(dynamicMarkers,function(marker){ marker.closeClick = function(){ - this.showWindow = false; + marker.showWindow = false; $scope.$apply(); }; + marker.onClicked = function(){ + onMarkerClicked(marker); + }; }); $scope.map.dynamicMarkers = dynamicMarkers; }, 2000); diff --git a/example/example.html b/example/example.html index f2acd054b..e338adb1d 100644 --- a/example/example.html +++ b/example/example.html @@ -49,7 +49,7 @@

angular-google-maps example

dragging="map.dragging" events="map.events"> - +

This is an info window at {{ latitude | number:4 }}, {{ longitude | number:4 }}!

My marker will stay open when the window is popped up!

@@ -57,7 +57,7 @@

angular-google-maps example

- +

Dynamic Marker created via a delay!

This is an info window at {{ latitude | number:4 }}, {{ longitude | number:4 }}!

@@ -66,7 +66,7 @@

angular-google-maps example

- +

This is an info window at {{ m.latitude | number:4 }}, {{ m.longitude | number:4 }}!

My marker will stay open when the window is popped up!

diff --git a/src/coffee/directives/api/models/child/marker-child-model.coffee b/src/coffee/directives/api/models/child/marker-child-model.coffee index e2a5c183a..f83eabb85 100644 --- a/src/coffee/directives/api/models/child/marker-child-model.coffee +++ b/src/coffee/directives/api/models/child/marker-child-model.coffee @@ -6,9 +6,11 @@ @model = model @iconKey = parentScope.icon @coordsKey = parentScope.coords + @clickKey = parentScope.click() @myScope = parentScope.$new(false) @myScope.icon = if @iconKey == 'self' then model else model[@iconKey] @myScope.coords = if @coordsKey == 'self' then model else model[@coordsKey] + @myScope.click = if @clickKey == 'self' then model else model[@clickKey] @gMap = gMap @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,defaults) @gMarker = new google.maps.Marker(@opts) diff --git a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee index efdbaf2c8..416af2a03 100644 --- a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee @@ -21,7 +21,7 @@ self = @ # Validate required properties if (@validateScope(scope)) - return + return @animate = angular.isDefined(attrs.animate) and @isFalse(attrs.animate) @doClick = angular.isDefined(attrs.click) @mapCtrl = mapCtrl diff --git a/src/coffee/directives/api/models/parent/marker-parent-model.coffee b/src/coffee/directives/api/models/parent/marker-parent-model.coffee index 2386339fd..a9da5ea9e 100644 --- a/src/coffee/directives/api/models/parent/marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/marker-parent-model.coffee @@ -14,9 +14,9 @@ @gMarker = new google.maps.Marker(opts) element.data('instance', @gMarker) @scope = scope - google.maps.event.addListener(@gMarker, 'click', -> + google.maps.event.addListener(@gMarker, 'click', => if @doClick and scope.click? - scope.click() + @scope.click() ) @$log.info(@) From df9dc3b588dc3d3fe819b241dfa3ce558388a42f Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 09:45:19 -0400 Subject: [PATCH 31/41] If any key changes occur in MarkersParentModel, then the entire child set is rebuilt. --- .../models/child/marker-child-model.coffee | 5 ++++- .../models/parent/markers-parent-model.coffee | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/coffee/directives/api/models/child/marker-child-model.coffee b/src/coffee/directives/api/models/child/marker-child-model.coffee index f83eabb85..fc5ffc64a 100644 --- a/src/coffee/directives/api/models/child/marker-child-model.coffee +++ b/src/coffee/directives/api/models/child/marker-child-model.coffee @@ -7,12 +7,15 @@ @iconKey = parentScope.icon @coordsKey = parentScope.coords @clickKey = parentScope.click() + @animateKey = parentScope.animate @myScope = parentScope.$new(false) @myScope.icon = if @iconKey == 'self' then model else model[@iconKey] @myScope.coords = if @coordsKey == 'self' then model else model[@coordsKey] @myScope.click = if @clickKey == 'self' then model else model[@clickKey] + @myScope.animate = if @animateKey == 'self' then model else model[@animateKey] + @defaults = defaults @gMap = gMap - @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,defaults) + @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,@myScope.animate,@defaults) @gMarker = new google.maps.Marker(@opts) @doClick = doClick @$log = directives.api.utils.Logger diff --git a/src/coffee/directives/api/models/parent/markers-parent-model.coffee b/src/coffee/directives/api/models/parent/markers-parent-model.coffee index dee4d08fc..06d4ebf50 100644 --- a/src/coffee/directives/api/models/parent/markers-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/markers-parent-model.coffee @@ -32,29 +32,31 @@ #put MarkerModels into local scope scope.markerModels = @markers + reBuildMarkers:(scope) => + for oldM in @markers + do(oldM) => + oldM.destroy() + delete @markers + @markers = [] + @markersIndex = 0 + @createMarkers(scope) + watchModels:(scope) => scope.$watch('models', (newValue, oldValue) => if (newValue != oldValue) - for oldM in @markers - do(oldM) => - oldM.destroy() - delete @markers - @markers = [] - @markersIndex = 0 - @createMarkers(scope) - + @reBuildMarkers(scope) , true) watchCoords:(scope) => scope.$watch('coords', (newValue, oldValue) => if (newValue != oldValue) - model.coordsKey = newValue for model in @markers + @reBuildMarkers(scope) , true) watchIcon:(scope) => scope.$watch('icon', (newValue, oldValue) => if (newValue != oldValue) - model.iconKey = newValue for model in @markers + @reBuildMarkers(scope) , true) watchDestroy:(scope)=> From b1482e6fc8aab78b9c9e8dc78967e132dc139136 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 11:06:45 -0400 Subject: [PATCH 32/41] watching scopes in markers, imarkerparentmodel now using OnWatch to reduce code bloat. Cleaned up window destruction in the Window directive and WindowChildModel --- dist/angular-google-maps.js | 66 +++++++++---------- dist/angular-google-maps.min.js | 2 +- example/example.html | 4 +- .../models/child/marker-child-model.coffee | 5 +- .../models/child/window-child-model.coffee | 7 +- .../parent/i-marker-parent-model.coffee | 23 ++++--- .../models/parent/marker-parent-model.coffee | 49 +++++++------- .../models/parent/markers-parent-model.coffee | 28 ++------ .../models/parent/windows-parent-model.coffee | 2 +- src/coffee/directives/api/window.coffee | 5 +- 10 files changed, 92 insertions(+), 99 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 16c3dfc2a..400bb5752 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -177,11 +177,16 @@ angular.module('google-maps', []);;(function() { this.model = model; this.iconKey = parentScope.icon; this.coordsKey = parentScope.coords; + this.clickKey = parentScope.click(); + this.animateKey = parentScope.animate; this.myScope = parentScope.$new(false); this.myScope.icon = this.iconKey === 'self' ? model : model[this.iconKey]; this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; + this.myScope.click = this.clickKey === 'self' ? model : model[this.clickKey]; + this.myScope.animate = this.animateKey === 'self' ? model : model[this.animateKey]; + this.defaults = defaults; this.gMap = gMap; - this.opts = this.createMarkerOptions(this.gMap, this.myScope.coords, this.myScope.icon, defaults); + this.opts = this.createMarkerOptions(this.gMap, this.myScope.coords, this.myScope.icon, this.myScope.animate, this.defaults); this.gMarker = new google.maps.Marker(this.opts); this.doClick = doClick; this.$log = directives.api.utils.Logger; @@ -383,7 +388,7 @@ angular.module('google-maps', []);;(function() { if (this.validateScope(scope)) { return; } - this.animate = angular.isDefined(attrs.animate) && this.isFalse(attrs.animate); + this.animate = angular.isDefined(attrs.animate) ? !this.isFalse(attrs.animate) : false; this.doClick = angular.isDefined(attrs.click); this.mapCtrl = mapCtrl; this.clsName = "IMarker"; @@ -488,7 +493,8 @@ angular.module('google-maps', []);;(function() { this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); this.validateScope = __bind(this.validateScope, this); - var opts, self; + var opts, self, + _this = this; MarkerParentModel.__super__.constructor.call(this, scope, element, attrs, mapCtrl, $timeout); self = this; this.clsName = "MarkerParentModel"; @@ -497,8 +503,8 @@ angular.module('google-maps', []);;(function() { element.data('instance', this.gMarker); this.scope = scope; google.maps.event.addListener(this.gMarker, 'click', function() { - if (this.doClick && (scope.click != null)) { - return scope.click(); + if (_this.doClick && (scope.click != null)) { + return _this.scope.click(); } }); this.$log.info(this); @@ -570,6 +576,7 @@ angular.module('google-maps', []);;(function() { this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); this.watchModels = __bind(this.watchModels, this); + this.reBuildMarkers = __bind(this.reBuildMarkers, this); this.createMarkers = __bind(this.createMarkers, this); this.validateScope = __bind(this.validateScope, this); this.onTimeOut = __bind(this.onTimeOut, this); @@ -614,23 +621,28 @@ angular.module('google-maps', []);;(function() { return scope.markerModels = this.markers; }; + MarkersParentModel.prototype.reBuildMarkers = function(scope) { + var oldM, _fn, _i, _len, _ref, + _this = this; + _ref = this.markers; + _fn = function(oldM) { + return oldM.destroy(); + }; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + oldM = _ref[_i]; + _fn(oldM); + } + delete this.markers; + this.markers = []; + this.markersIndex = 0; + return this.createMarkers(scope); + }; + MarkersParentModel.prototype.watchModels = function(scope) { var _this = this; return scope.$watch('models', function(newValue, oldValue) { - var oldM, _fn, _i, _len, _ref; if (newValue !== oldValue) { - _ref = _this.markers; - _fn = function(oldM) { - return oldM.destroy(); - }; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - oldM = _ref[_i]; - _fn(oldM); - } - delete _this.markers; - _this.markers = []; - _this.markersIndex = 0; - return _this.createMarkers(scope); + return _this.reBuildMarkers(scope); } }, true); }; @@ -638,15 +650,8 @@ angular.module('google-maps', []);;(function() { MarkersParentModel.prototype.watchCoords = function(scope) { var _this = this; return scope.$watch('coords', function(newValue, oldValue) { - var model, _i, _len, _ref, _results; if (newValue !== oldValue) { - _ref = _this.markers; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - model = _ref[_i]; - _results.push(model.coordsKey = newValue); - } - return _results; + return _this.reBuildMarkers(scope); } }, true); }; @@ -654,15 +659,8 @@ angular.module('google-maps', []);;(function() { MarkersParentModel.prototype.watchIcon = function(scope) { var _this = this; return scope.$watch('icon', function(newValue, oldValue) { - var model, _i, _len, _ref, _results; if (newValue !== oldValue) { - _ref = _this.markers; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - model = _ref[_i]; - _results.push(model.iconKey = newValue); - } - return _results; + return _this.reBuildMarkers(scope); } }, true); }; diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 0af9681c3..64e279d60 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,h),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)&&this.isFalse(d.animate),this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watchCoords(b),h.watchIcon(b),h.watchDestroy(b),h.onTimeOut(b)}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this);var h,i;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return this.doClick&&null!=b.click?b.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a&&null!=b.gMarker?(b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c&&null!=b.gMarker?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return void 0===b.gMarker?(delete b,void 0):(b.gMarker.setMap(null),delete b.gMarker,delete b)})},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watchModels(a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){var e,f,g,h,i;if(c!==d){for(i=b.markers,f=function(a){return a.destroy()},g=0,h=i.length;h>g;g++)e=i[g],f(e);return delete b.markers,b.markers=[],b.markersIndex=0,b.createMarkers(a)}},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.coordsKey=a);return h}},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){var d,e,f,g,h;if(a!==c){for(g=b.markers,h=[],e=0,f=g.length;f>e;e++)d=g[e],h.push(d.iconKey=a);return h}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.myScope.click="self"===this.clickKey?c:c[this.clickKey],this.myScope.animate="self"===this.animateKey?c:c[this.animateKey],this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watchCoords(b),h.watchIcon(b),h.watchDestroy(b),h.onTimeOut(b)}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a&&null!=b.gMarker?(b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c&&null!=b.gMarker?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return void 0===b.gMarker?(delete b,void 0):(b.gMarker.setMap(null),delete b.gMarker,delete b)})},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watchModels(a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){return c!==d?b.reBuildMarkers(a):void 0},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?b.reBuildMarkers(a):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?b.reBuildMarkers(a):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bangular-google-maps example
- +

Dynamic Marker created via a delay!

This is an info window at {{ latitude | number:4 }}, {{ longitude | number:4 }}!

@@ -74,7 +74,7 @@

angular-google-maps example

- + This is my clicked marker!

My marker will reappear when you close me.

diff --git a/src/coffee/directives/api/models/child/marker-child-model.coffee b/src/coffee/directives/api/models/child/marker-child-model.coffee index fc5ffc64a..a3b939325 100644 --- a/src/coffee/directives/api/models/child/marker-child-model.coffee +++ b/src/coffee/directives/api/models/child/marker-child-model.coffee @@ -13,6 +13,7 @@ @myScope.coords = if @coordsKey == 'self' then model else model[@coordsKey] @myScope.click = if @clickKey == 'self' then model else model[@clickKey] @myScope.animate = if @animateKey == 'self' then model else model[@animateKey] + @myScope.animate = if @animateKey == undefined then false else @myScope.animate @defaults = defaults @gMap = gMap @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,@myScope.animate,@defaults) @@ -50,8 +51,8 @@ @gMarker.icon = newValue @gMarker.setMap(null) @gMarker.setMap(@gMap.getMap()) - @gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) - @gMarker.setVisible(coords.latitude and coords.longitude?) + @gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) + @gMarker.setVisible(scope.coords.latitude and scope.coords.longitude?) , true) watchDestroy:(scope)=> diff --git a/src/coffee/directives/api/models/child/window-child-model.coffee b/src/coffee/directives/api/models/child/window-child-model.coffee index e061ee16e..7d8723323 100644 --- a/src/coffee/directives/api/models/child/window-child-model.coffee +++ b/src/coffee/directives/api/models/child/window-child-model.coffee @@ -1,6 +1,6 @@ @module "directives.api.models.child", -> class @WindowChildModel extends oo.BaseObject - constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$http,$templateCache,$compile)-> + constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$http,$templateCache,$compile,needToManualDestroy = false)-> @scope = scope @opts = opts @mapCtrl = mapCtrl @@ -17,7 +17,7 @@ @handleClick(@scope,@mapCtrl,@markerCtrl,@gWin,@isIconVisibleOnClick,@initialMarkerVisibility) @watchShow(scope,$http,$templateCache,@$compile,@gWin,@showWindow,@hideWindow,@mapCtrl) - + @needToManualDestroy = needToManualDestroy @$log.info(@) watchShow:(scope,$http,$templateCache,$compile,gWin,showHandle,hideHandle,mapCtrl) -> @@ -65,7 +65,8 @@ destroy:()=> @hideWindow(@gWin) - @scope.$destroy() + if(@scope? and @needToManualDestroy) + @scope.$destroy() delete @gWin delete @ diff --git a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee index 416af2a03..9a10570a1 100644 --- a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee @@ -22,7 +22,7 @@ # Validate required properties if (@validateScope(scope)) return - @animate = angular.isDefined(attrs.animate) and @isFalse(attrs.animate) + @animate = if angular.isDefined(attrs.animate) then !@isFalse(attrs.animate) else false @doClick = angular.isDefined(attrs.click) @mapCtrl = mapCtrl @clsName = "IMarker" @@ -30,10 +30,13 @@ @$timeout = $timeout # Wrap marker initialization inside a $timeout() call to make sure the map is created already @$timeout( => - @watchCoords(scope) - @watchIcon(scope) - @watchDestroy(scope) + @watch('coords',scope) + @watch('icon',scope) + @watch('animate',scope) @onTimeOut(scope) + scope.$on("$destroy", => + @onDestroy(scope) + ) ) onTimeOut:(scope)=> @@ -45,12 +48,16 @@ @$log.error(@clsName + ": no valid coords attribute found") ret - watchCoords:(scope) => - throw new Exception("Not Implemented!!") + watch:(propNameToWatch,scope) => + scope.$watch(propNameToWatch, (newValue, oldValue) => + if (newValue != oldValue) + @onWatch(propNameToWatch,scope) + , true) - watchIcon:(scope) => + onWatch:(propNameToWatch,scope) => throw new Exception("Not Implemented!!") - watchDestroy:(scope) => + + onDestroy:(scope) => throw new Exception("Not Implemented!!") linkInit:(element,mapCtrl,scope,animate)=> diff --git a/src/coffee/directives/api/models/parent/marker-parent-model.coffee b/src/coffee/directives/api/models/parent/marker-parent-model.coffee index a9da5ea9e..0c953a6cf 100644 --- a/src/coffee/directives/api/models/parent/marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/marker-parent-model.coffee @@ -23,35 +23,34 @@ validateScope:(scope)=> super(scope) or angular.isUndefined(scope.coords.latitude) or angular.isUndefined(scope.coords.longitude) - watchCoords:(scope) => - scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - if (newValue and @gMarker?) + onWatch:(propNameToWatch,scope) => + + switch propNameToWatch + when 'coords' + if (scope.coords? and @gMarker?) @gMarker.setMap(@mapCtrl.getMap()) - @gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - @gMarker.setVisible(newValue.latitude? and newValue.longitude?) + @gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) + @gMarker.setVisible(scope.coords.latitude? and scope.coords.longitude?) else # Remove marker @gMarker.setMap(null) - , true) + when 'icon' + if (scope.icon? and scope.coords? and @gMarker?) + @gMarker.icon = scope.icon + @gMarker.setMap(null) + @gMarker.setMap(@mapCtrl.getMap()) + @gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) + @gMarker.setVisible(scope.coords.latitude and scope.coords.longitude?) + when 'animate' + else - watchIcon:(scope) => - scope.$watch('icon', (newValue, oldValue) => - if (newValue != oldValue and @gMarker?) - @gMarker.icon = newValue - @gMarker.setMap(null) - @gMarker.setMap(@mapCtrl.getMap()) - @gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)) - @gMarker.setVisible(coords.latitude and coords.longitude?) - , true) - watchDestroy:(scope)=> - scope.$on("$destroy", => - if @gMarker == undefined - delete @ - return - #remove from gMaps and then free resources - @gMarker.setMap(null) - delete @gMarker + onDestroy:(scope)=> + if @gMarker == undefined delete @ - ) + return + #remove from gMaps and then free resources + @gMarker.setMap(null) + delete @gMarker + delete @ + diff --git a/src/coffee/directives/api/models/parent/markers-parent-model.coffee b/src/coffee/directives/api/models/parent/markers-parent-model.coffee index 06d4ebf50..09039bebe 100644 --- a/src/coffee/directives/api/models/parent/markers-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/markers-parent-model.coffee @@ -10,7 +10,7 @@ @$log.info(@) onTimeOut:(scope)=> - @watchModels(scope) + @watch('models',scope) @createMarkers(scope) validateScope:(scope)=> @@ -41,29 +41,13 @@ @markersIndex = 0 @createMarkers(scope) - watchModels:(scope) => - scope.$watch('models', (newValue, oldValue) => - if (newValue != oldValue) - @reBuildMarkers(scope) - , true) + onWatch:(propNameToWatch,scope) => + @reBuildMarkers(scope) - watchCoords:(scope) => - scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - @reBuildMarkers(scope) - , true) - - watchIcon:(scope) => - scope.$watch('icon', (newValue, oldValue) => - if (newValue != oldValue) - @reBuildMarkers(scope) - , true) - - watchDestroy:(scope)=> + onDestroy:(scope)=> #need to figure out how to handle individual destroys #slap index to the external model so that when they pass external back #for destroy we have a lookup? #this will require another attribute for destroySingle(marker) - scope.$on("$destroy", => - model.destroy() for model in @markers - ) \ No newline at end of file + model.destroy() for model in @markers + \ No newline at end of file diff --git a/src/coffee/directives/api/models/parent/windows-parent-model.coffee b/src/coffee/directives/api/models/parent/windows-parent-model.coffee index 62f46b695..cfbf5be78 100644 --- a/src/coffee/directives/api/models/parent/windows-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/windows-parent-model.coffee @@ -129,7 +129,7 @@ parsedContent = @interpolateContent(@linked.element.html(),model) opts = @createWindowOptions(gMarker,childScope,parsedContent,@DEFAULTS) @windows.push( - new directives.api.models.child.WindowChildModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile) + new directives.api.models.child.WindowChildModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile,true) ) interpolateContent: (content,model) => diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee index 488ab86e5..e5b8ec684 100644 --- a/src/coffee/directives/api/window.coffee +++ b/src/coffee/directives/api/window.coffee @@ -24,8 +24,11 @@ opts = @createWindowOptions(markerCtrl,scope,element.html(),@DEFAULTS) if mapCtrl? #at the very least we need a Map, the marker is optional as we can create Windows without markers - new directives.api.models.child.WindowChildModel( + window = new directives.api.models.child.WindowChildModel( scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,@$http,@$templateCache,@$compile ) + scope.$on("$destroy", => + window.destroy() + ) ,50) \ No newline at end of file From b4380bf4dc6f264aa7f64ae945aa0e6a4fe61909 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 13:44:05 -0400 Subject: [PATCH 33/41] Detaching model(s) rebuilding of all children on simple updates. --- dist/angular-google-maps.js | 189 +++++++++--------- dist/angular-google-maps.min.js | 2 +- .../models/child/marker-child-model.coffee | 44 ++-- .../parent/i-marker-parent-model.coffee | 4 +- .../models/parent/markers-parent-model.coffee | 7 +- .../models/parent/windows-parent-model.coffee | 22 +- 6 files changed, 147 insertions(+), 121 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 400bb5752..e77d01b2f 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -184,6 +184,7 @@ angular.module('google-maps', []);;(function() { this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; this.myScope.click = this.clickKey === 'self' ? model : model[this.clickKey]; this.myScope.animate = this.animateKey === 'self' ? model : model[this.animateKey]; + this.myScope.animate = this.animateKey === void 0 ? false : this.myScope.animate; this.defaults = defaults; this.gMap = gMap; this.opts = this.createMarkerOptions(this.gMap, this.myScope.coords, this.myScope.icon, this.myScope.animate, this.defaults); @@ -228,8 +229,8 @@ angular.module('google-maps', []);;(function() { _this.gMarker.icon = newValue; _this.gMarker.setMap(null); _this.gMarker.setMap(_this.gMap.getMap()); - _this.gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); - return _this.gMarker.setVisible(coords.latitude && (coords.longitude != null)); + _this.gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); + return _this.gMarker.setVisible(scope.coords.latitude && (scope.coords.longitude != null)); } }, true); }; @@ -260,7 +261,10 @@ angular.module('google-maps', []);;(function() { return this.WindowChildModel = (function(_super) { __extends(WindowChildModel, _super); - function WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $http, $templateCache, $compile) { + function WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, $http, $templateCache, $compile, needToManualDestroy) { + if (needToManualDestroy == null) { + needToManualDestroy = false; + } this.destroy = __bind(this.destroy, this); this.scope = scope; this.opts = opts; @@ -278,6 +282,7 @@ angular.module('google-maps', []);;(function() { } this.handleClick(this.scope, this.mapCtrl, this.markerCtrl, this.gWin, this.isIconVisibleOnClick, this.initialMarkerVisibility); this.watchShow(scope, $http, $templateCache, this.$compile, this.gWin, this.showWindow, this.hideWindow, this.mapCtrl); + this.needToManualDestroy = needToManualDestroy; this.$log.info(this); } @@ -336,7 +341,9 @@ angular.module('google-maps', []);;(function() { WindowChildModel.prototype.destroy = function() { this.hideWindow(this.gWin); - this.scope.$destroy(); + if ((this.scope != null) && this.needToManualDestroy) { + this.scope.$destroy(); + } delete this.gWin; return delete this; }; @@ -377,9 +384,10 @@ angular.module('google-maps', []);;(function() { function IMarkerParentModel(scope, element, attrs, mapCtrl, $timeout) { this.linkInit = __bind(this.linkInit, this); - this.watchDestroy = __bind(this.watchDestroy, this); - this.watchIcon = __bind(this.watchIcon, this); - this.watchCoords = __bind(this.watchCoords, this); + this.onDestroy = __bind(this.onDestroy, this); + this.onWatch = __bind(this.onWatch, this); + this.watchShallow = __bind(this.watchShallow, this); + this.watchDeep = __bind(this.watchDeep, this); this.validateScope = __bind(this.validateScope, this); this.onTimeOut = __bind(this.onTimeOut, this); var self, @@ -395,10 +403,13 @@ angular.module('google-maps', []);;(function() { this.$log = directives.api.utils.Logger; this.$timeout = $timeout; this.$timeout(function() { - _this.watchCoords(scope); - _this.watchIcon(scope); - _this.watchDestroy(scope); - return _this.onTimeOut(scope); + _this.watchDeep('coords', scope); + _this.watchDeep('icon', scope); + _this.watchDeep('animate', scope); + _this.onTimeOut(scope); + return scope.$on("$destroy", function() { + return _this.onDestroy(scope); + }); }); } @@ -413,15 +424,29 @@ angular.module('google-maps', []);;(function() { return ret; }; - IMarkerParentModel.prototype.watchCoords = function(scope) { - throw new Exception("Not Implemented!!"); + IMarkerParentModel.prototype.watchDeep = function(propNameToWatch, scope) { + var _this = this; + return scope.$watch(propNameToWatch, function(newValue, oldValue) { + if (newValue !== oldValue) { + return _this.onWatch(propNameToWatch, scope); + } + }, true); }; - IMarkerParentModel.prototype.watchIcon = function(scope) { + IMarkerParentModel.prototype.watchShallow = function(propNameToWatch, scope) { + var _this = this; + return scope.$watch(propNameToWatch, function(newValue, oldValue) { + if (newValue !== oldValue) { + return _this.onWatch(propNameToWatch, scope); + } + }, false); + }; + + IMarkerParentModel.prototype.onWatch = function(propNameToWatch, scope) { throw new Exception("Not Implemented!!"); }; - IMarkerParentModel.prototype.watchDestroy = function(scope) { + IMarkerParentModel.prototype.onDestroy = function(scope) { throw new Exception("Not Implemented!!"); }; @@ -489,9 +514,8 @@ angular.module('google-maps', []);;(function() { MarkerParentModel.include(directives.api.utils.GmapUtil); function MarkerParentModel(scope, element, attrs, mapCtrl, $timeout) { - this.watchDestroy = __bind(this.watchDestroy, this); - this.watchIcon = __bind(this.watchIcon, this); - this.watchCoords = __bind(this.watchCoords, this); + this.onDestroy = __bind(this.onDestroy, this); + this.onWatch = __bind(this.onWatch, this); this.validateScope = __bind(this.validateScope, this); var opts, self, _this = this; @@ -514,45 +538,39 @@ angular.module('google-maps', []);;(function() { return MarkerParentModel.__super__.validateScope.call(this, scope) || angular.isUndefined(scope.coords.latitude) || angular.isUndefined(scope.coords.longitude); }; - MarkerParentModel.prototype.watchCoords = function(scope) { - var _this = this; - return scope.$watch('coords', function(newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue && (_this.gMarker != null)) { - _this.gMarker.setMap(_this.mapCtrl.getMap()); - _this.gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - return _this.gMarker.setVisible((newValue.latitude != null) && (newValue.longitude != null)); + MarkerParentModel.prototype.onWatch = function(propNameToWatch, scope) { + switch (propNameToWatch) { + case 'coords': + if ((scope.coords != null) && (this.gMarker != null)) { + this.gMarker.setMap(this.mapCtrl.getMap()); + this.gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); + return this.gMarker.setVisible((scope.coords.latitude != null) && (scope.coords.longitude != null)); } else { - return _this.gMarker.setMap(null); + return this.gMarker.setMap(null); } - } - }, true); - }; - - MarkerParentModel.prototype.watchIcon = function(scope) { - var _this = this; - return scope.$watch('icon', function(newValue, oldValue) { - if (newValue !== oldValue && (_this.gMarker != null)) { - _this.gMarker.icon = newValue; - _this.gMarker.setMap(null); - _this.gMarker.setMap(_this.mapCtrl.getMap()); - _this.gMarker.setPosition(new google.maps.LatLng(coords.latitude, coords.longitude)); - return _this.gMarker.setVisible(coords.latitude && (coords.longitude != null)); - } - }, true); + break; + case 'icon': + if ((scope.icon != null) && (scope.coords != null) && (this.gMarker != null)) { + this.gMarker.icon = scope.icon; + this.gMarker.setMap(null); + this.gMarker.setMap(this.mapCtrl.getMap()); + this.gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); + return this.gMarker.setVisible(scope.coords.latitude && (scope.coords.longitude != null)); + } + break; + case 'animate': + break; + } }; - MarkerParentModel.prototype.watchDestroy = function(scope) { - var _this = this; - return scope.$on("$destroy", function() { - if (_this.gMarker === void 0) { - delete _this; - return; - } - _this.gMarker.setMap(null); - delete _this.gMarker; - return delete _this; - }); + MarkerParentModel.prototype.onDestroy = function(scope) { + if (this.gMarker === void 0) { + delete this; + return; + } + this.gMarker.setMap(null); + delete this.gMarker; + return delete this; }; return MarkerParentModel; @@ -572,10 +590,8 @@ angular.module('google-maps', []);;(function() { __extends(MarkersParentModel, _super); function MarkersParentModel(scope, element, attrs, mapCtrl, $timeout) { - this.watchDestroy = __bind(this.watchDestroy, this); - this.watchIcon = __bind(this.watchIcon, this); - this.watchCoords = __bind(this.watchCoords, this); - this.watchModels = __bind(this.watchModels, this); + this.onDestroy = __bind(this.onDestroy, this); + this.onWatch = __bind(this.onWatch, this); this.reBuildMarkers = __bind(this.reBuildMarkers, this); this.createMarkers = __bind(this.createMarkers, this); this.validateScope = __bind(this.validateScope, this); @@ -591,7 +607,7 @@ angular.module('google-maps', []);;(function() { } MarkersParentModel.prototype.onTimeOut = function(scope) { - this.watchModels(scope); + this.watchShallow('models', scope); return this.createMarkers(scope); }; @@ -638,45 +654,19 @@ angular.module('google-maps', []);;(function() { return this.createMarkers(scope); }; - MarkersParentModel.prototype.watchModels = function(scope) { - var _this = this; - return scope.$watch('models', function(newValue, oldValue) { - if (newValue !== oldValue) { - return _this.reBuildMarkers(scope); - } - }, true); - }; - - MarkersParentModel.prototype.watchCoords = function(scope) { - var _this = this; - return scope.$watch('coords', function(newValue, oldValue) { - if (newValue !== oldValue) { - return _this.reBuildMarkers(scope); - } - }, true); + MarkersParentModel.prototype.onWatch = function(propNameToWatch, scope) { + return this.reBuildMarkers(scope); }; - MarkersParentModel.prototype.watchIcon = function(scope) { - var _this = this; - return scope.$watch('icon', function(newValue, oldValue) { - if (newValue !== oldValue) { - return _this.reBuildMarkers(scope); - } - }, true); - }; - - MarkersParentModel.prototype.watchDestroy = function(scope) { - var _this = this; - return scope.$on("$destroy", function() { - var model, _i, _len, _ref, _results; - _ref = _this.markers; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - model = _ref[_i]; - _results.push(model.destroy()); - } - return _results; - }); + MarkersParentModel.prototype.onDestroy = function(scope) { + var model, _i, _len, _ref, _results; + _ref = this.markers; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push(model.destroy()); + } + return _results; }; return MarkersParentModel; @@ -895,7 +885,7 @@ angular.module('google-maps', []);;(function() { } parsedContent = this.interpolateContent(this.linked.element.html(), model); opts = this.createWindowOptions(gMarker, childScope, parsedContent, this.DEFAULTS); - return this.windows.push(new directives.api.models.child.WindowChildModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$http, this.$templateCache, this.$compile)); + return this.windows.push(new directives.api.models.child.WindowChildModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$http, this.$templateCache, this.$compile, true)); }; WindowsParentModel.prototype.interpolateContent = function(content, model) { @@ -1146,7 +1136,7 @@ not 1:1 in this setting. Window.prototype.link = function(scope, element, attrs, ctrls) { var _this = this; return this.$timeout(function() { - var isIconVisibleOnClick, mapCtrl, markerCtrl, opts; + var isIconVisibleOnClick, mapCtrl, markerCtrl, opts, window; isIconVisibleOnClick = true; if (angular.isDefined(attrs.isiconvisibleonclick)) { isIconVisibleOnClick = scope.isIconVisibleOnClick; @@ -1155,8 +1145,11 @@ not 1:1 in this setting. markerCtrl = ctrls.length > 1 && (ctrls[1] != null) ? ctrls[1].getMarker() : void 0; opts = _this.createWindowOptions(markerCtrl, scope, element.html(), _this.DEFAULTS); if (mapCtrl != null) { - return new directives.api.models.child.WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$http, _this.$templateCache, _this.$compile); + window = new directives.api.models.child.WindowChildModel(scope, opts, isIconVisibleOnClick, mapCtrl, markerCtrl, _this.$http, _this.$templateCache, _this.$compile); } + return scope.$on("$destroy", function() { + return window.destroy(); + }); }, 50); }; diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 64e279d60..274f7ae05 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.myScope.click="self"===this.clickKey?c:c[this.clickKey],this.myScope.animate="self"===this.animateKey?c:c[this.animateKey],this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watchCoords(b),h.watchIcon(b),h.watchDestroy(b),h.onTimeOut(b)}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watchCoords=function(){throw new Exception("Not Implemented!!")},d.prototype.watchIcon=function(){throw new Exception("Not Implemented!!")},d.prototype.watchDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a&&null!=b.gMarker?(b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c&&null!=b.gMarker?(b.gMarker.icon=a,b.gMarker.setMap(null),b.gMarker.setMap(b.mapCtrl.getMap()),b.gMarker.setPosition(new google.maps.LatLng(coords.latitude,coords.longitude)),b.gMarker.setVisible(coords.latitude&&null!=coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return void 0===b.gMarker?(delete b,void 0):(b.gMarker.setMap(null),delete b.gMarker,delete b)})},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.watchModels=a(this.watchModels,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watchModels(a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(c,d){return c!==d?b.reBuildMarkers(a):void 0},!0)},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?b.reBuildMarkers(a):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?b.reBuildMarkers(a):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e,f;for(e=b.markers,f=[],c=0,d=e.length;d>c;c++)a=e[c],f.push(a.destroy());return f})},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g?new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile):void 0},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.myScope.click="self"===this.clickKey?c:c[this.clickKey],this.myScope.animate="self"===this.animateKey?c:c[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.gMarker.icon=c,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),b.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watchShallow=a(this.watchShallow,this),this.watchDeep=a(this.watchDeep,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watchDeep("coords",b),h.watchDeep("icon",b),h.watchDeep("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watchDeep=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b):void 0},!0)},d.prototype.watchShallow=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b):void 0},!1)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watchShallow("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)},d.prototype.onWatch=function(a,b){return this.reBuildMarkers(b)},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b @index = index @model = model + @parentScope = parentScope @iconKey = parentScope.icon @coordsKey = parentScope.coords @clickKey = parentScope.click() @@ -25,6 +26,8 @@ if @doClick and @myScope.click? @myScope.click() ) + @setCoords(@myScope) + @setIcon(@myScope) $timeout( => @watchCoords(@myScope) @watchIcon(@myScope) @@ -33,26 +36,41 @@ destroy:() => @myScope.$destroy() + setCoords:(scope) => + if(scope.$id != @myScope.$id) + return + if (scope.coords?) + @gMarker.setMap(@gMap.getMap()) + @gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) + @gMarker.setVisible(scope.coords.latitude? and scope.coords.longitude?) + else + # Remove marker + @gMarker.setMap(null) + + setIcon:(scope) => + if(scope.$id != @myScope.$id) + return + @gMarker.icon = scope.icon + @gMarker.setMap(null) + @gMarker.setMap(@gMap.getMap()) + @gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) + @gMarker.setVisible(scope.coords.latitude and scope.coords.longitude?) + + watchCoords:(scope) => scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - if (newValue) - @gMarker.setMap(@gMap.getMap()) - @gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)) - @gMarker.setVisible(newValue.latitude? and newValue.longitude?) - else - # Remove marker - @gMarker.setMap(null) + if (newValue != oldValue) + @parentScope.doRebuild = false + @setCoords(newValue) + @parentScope.doRebuild = true , true) watchIcon:(scope) => scope.$watch('icon', (newValue, oldValue) => if (newValue != oldValue) - @gMarker.icon = newValue - @gMarker.setMap(null) - @gMarker.setMap(@gMap.getMap()) - @gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)) - @gMarker.setVisible(scope.coords.latitude and scope.coords.longitude?) + @parentScope.doRebuild = false + @setIcon(newValue) + @parentScope.doRebuild = true , true) watchDestroy:(scope)=> diff --git a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee index 9a10570a1..bd6809c50 100644 --- a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee @@ -51,10 +51,10 @@ watch:(propNameToWatch,scope) => scope.$watch(propNameToWatch, (newValue, oldValue) => if (newValue != oldValue) - @onWatch(propNameToWatch,scope) + @onWatch(propNameToWatch,scope,newValue,oldValue) , true) - onWatch:(propNameToWatch,scope) => + onWatch:(propNameToWatch,scope,newValue,oldValue) => throw new Exception("Not Implemented!!") onDestroy:(scope) => diff --git a/src/coffee/directives/api/models/parent/markers-parent-model.coffee b/src/coffee/directives/api/models/parent/markers-parent-model.coffee index 09039bebe..76ed33ef5 100644 --- a/src/coffee/directives/api/models/parent/markers-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/markers-parent-model.coffee @@ -23,6 +23,7 @@ createMarkers:(scope) => for model in scope.models do(model) => + scope.doRebuild = true @markers.push( new directives.api.models.child.MarkerChildModel(@markersIndex,model,scope,@mapCtrl,@$timeout,(index) => delete @markers[index] @@ -33,6 +34,8 @@ scope.markerModels = @markers reBuildMarkers:(scope) => + if(!scope.doRebuild and scope.doRebuild != undefined) + return for oldM in @markers do(oldM) => oldM.destroy() @@ -41,7 +44,9 @@ @markersIndex = 0 @createMarkers(scope) - onWatch:(propNameToWatch,scope) => + onWatch:(propNameToWatch,scope,newValue,oldValue) => + if(propNameToWatch == 'models' and newValue.length == oldValue.length) + return @reBuildMarkers(scope) onDestroy:(scope)=> diff --git a/src/coffee/directives/api/models/parent/windows-parent-model.coffee b/src/coffee/directives/api/models/parent/windows-parent-model.coffee index cfbf5be78..9ab6d2a94 100644 --- a/src/coffee/directives/api/models/parent/windows-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/windows-parent-model.coffee @@ -39,7 +39,7 @@ watchModels:(scope) => scope.$watch('models', (newValue, oldValue) => - if (newValue != oldValue) + if (newValue != oldValue and newValue.length != oldValue.length) for model in @windows do(model) => model.destroy() @@ -74,7 +74,7 @@ ### @isIconVisibleOnClick = true if angular.isDefined(@linked.attrs.isiconvisibleonclick) - isIconVisibleOnClick = @linked.scope.isIconVisibleOnClick + @isIconVisibleOnClick = @linked.scope.isIconVisibleOnClick gMap = @linked.ctrls[0].getMap() markersScope = if @linked.ctrls.length > 1 and @linked.ctrls[1]? then @linked.ctrls[1].getMarkersScope() else undefined @@ -122,16 +122,26 @@ } ### childScope = @linked.scope.$new(false) - for name in @scopePropNames - do (name) => - nameKey = name + 'Key' - childScope[name] = if @[nameKey] == 'self' then model else model[@[nameKey]] + @setChildScope(childScope,model) + childScope.$watch('model',(newValue, oldValue) => + if(newValue != oldValue) + @setChildScope(childScope,newValue) + ,true) parsedContent = @interpolateContent(@linked.element.html(),model) opts = @createWindowOptions(gMarker,childScope,parsedContent,@DEFAULTS) @windows.push( new directives.api.models.child.WindowChildModel( childScope,opts,@isIconVisibleOnClick,gMap,gMarker,@$http,@$templateCache,@$compile,true) ) + setChildScope:(childScope,model) => + for name in @scopePropNames + do (name) => + nameKey = name + 'Key' + newValue = if @[nameKey] == 'self' then model else model[@[nameKey]] + if(newValue != childScope[name]) + childScope[name] = newValue + childScope.model = model + interpolateContent: (content,model) => if @contentKeys == undefined or @contentKeys.length == 0 return From dff6e2e12a5c579c6f0242e37454348d79809a90 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 13:51:18 -0400 Subject: [PATCH 34/41] having MarkersChildModel watch it's relevant model within its own scope. --- dist/angular-google-maps.js | 137 ++++++++++++------ dist/angular-google-maps.min.js | 2 +- .../models/child/marker-child-model.coffee | 18 ++- 3 files changed, 106 insertions(+), 51 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index e77d01b2f..7da3b431f 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -171,20 +171,25 @@ angular.module('google-maps', []);;(function() { this.watchDestroy = __bind(this.watchDestroy, this); this.watchIcon = __bind(this.watchIcon, this); this.watchCoords = __bind(this.watchCoords, this); + this.setIcon = __bind(this.setIcon, this); + this.setCoords = __bind(this.setCoords, this); this.destroy = __bind(this.destroy, this); + this.setMyScope = __bind(this.setMyScope, this); var _this = this; this.index = index; this.model = model; + this.parentScope = parentScope; this.iconKey = parentScope.icon; this.coordsKey = parentScope.coords; this.clickKey = parentScope.click(); this.animateKey = parentScope.animate; this.myScope = parentScope.$new(false); - this.myScope.icon = this.iconKey === 'self' ? model : model[this.iconKey]; - this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; - this.myScope.click = this.clickKey === 'self' ? model : model[this.clickKey]; - this.myScope.animate = this.animateKey === 'self' ? model : model[this.animateKey]; - this.myScope.animate = this.animateKey === void 0 ? false : this.myScope.animate; + this.setMyScope(model); + this.myScope.$watch('model', function(newValue, oldValue) { + if (newValue !== oldValue) { + return _this.setMyScope(newValue); + } + }, true); this.defaults = defaults; this.gMap = gMap; this.opts = this.createMarkerOptions(this.gMap, this.myScope.coords, this.myScope.icon, this.myScope.animate, this.defaults); @@ -196,6 +201,8 @@ angular.module('google-maps', []);;(function() { return _this.myScope.click(); } }); + this.setCoords(this.myScope); + this.setIcon(this.myScope); $timeout(function() { _this.watchCoords(_this.myScope); _this.watchIcon(_this.myScope); @@ -203,21 +210,50 @@ angular.module('google-maps', []);;(function() { }); } + MarkerChildModel.prototype.setMyScope = function(model) { + this.myScope.icon = this.iconKey === 'self' ? model : model[this.iconKey]; + this.myScope.coords = this.coordsKey === 'self' ? model : model[this.coordsKey]; + this.myScope.click = this.clickKey === 'self' ? model : model[this.clickKey]; + this.myScope.animate = this.animateKey === 'self' ? model : model[this.animateKey]; + this.myScope.animate = this.animateKey === void 0 ? false : this.myScope.animate; + return this.myScope.model = model; + }; + MarkerChildModel.prototype.destroy = function() { return this.myScope.$destroy(); }; + MarkerChildModel.prototype.setCoords = function(scope) { + if (scope.$id !== this.myScope.$id) { + return; + } + if ((scope.coords != null)) { + this.gMarker.setMap(this.gMap.getMap()); + this.gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); + return this.gMarker.setVisible((scope.coords.latitude != null) && (scope.coords.longitude != null)); + } else { + return this.gMarker.setMap(null); + } + }; + + MarkerChildModel.prototype.setIcon = function(scope) { + if (scope.$id !== this.myScope.$id) { + return; + } + this.gMarker.icon = scope.icon; + this.gMarker.setMap(null); + this.gMarker.setMap(this.gMap.getMap()); + this.gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); + return this.gMarker.setVisible(scope.coords.latitude && (scope.coords.longitude != null)); + }; + MarkerChildModel.prototype.watchCoords = function(scope) { var _this = this; return scope.$watch('coords', function(newValue, oldValue) { if (newValue !== oldValue) { - if (newValue) { - _this.gMarker.setMap(_this.gMap.getMap()); - _this.gMarker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - return _this.gMarker.setVisible((newValue.latitude != null) && (newValue.longitude != null)); - } else { - return _this.gMarker.setMap(null); - } + _this.parentScope.doRebuild = false; + _this.setCoords(newValue); + return _this.parentScope.doRebuild = true; } }, true); }; @@ -226,11 +262,9 @@ angular.module('google-maps', []);;(function() { var _this = this; return scope.$watch('icon', function(newValue, oldValue) { if (newValue !== oldValue) { - _this.gMarker.icon = newValue; - _this.gMarker.setMap(null); - _this.gMarker.setMap(_this.gMap.getMap()); - _this.gMarker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); - return _this.gMarker.setVisible(scope.coords.latitude && (scope.coords.longitude != null)); + _this.parentScope.doRebuild = false; + _this.setIcon(newValue); + return _this.parentScope.doRebuild = true; } }, true); }; @@ -386,8 +420,7 @@ angular.module('google-maps', []);;(function() { this.linkInit = __bind(this.linkInit, this); this.onDestroy = __bind(this.onDestroy, this); this.onWatch = __bind(this.onWatch, this); - this.watchShallow = __bind(this.watchShallow, this); - this.watchDeep = __bind(this.watchDeep, this); + this.watch = __bind(this.watch, this); this.validateScope = __bind(this.validateScope, this); this.onTimeOut = __bind(this.onTimeOut, this); var self, @@ -403,9 +436,9 @@ angular.module('google-maps', []);;(function() { this.$log = directives.api.utils.Logger; this.$timeout = $timeout; this.$timeout(function() { - _this.watchDeep('coords', scope); - _this.watchDeep('icon', scope); - _this.watchDeep('animate', scope); + _this.watch('coords', scope); + _this.watch('icon', scope); + _this.watch('animate', scope); _this.onTimeOut(scope); return scope.$on("$destroy", function() { return _this.onDestroy(scope); @@ -424,25 +457,16 @@ angular.module('google-maps', []);;(function() { return ret; }; - IMarkerParentModel.prototype.watchDeep = function(propNameToWatch, scope) { + IMarkerParentModel.prototype.watch = function(propNameToWatch, scope) { var _this = this; return scope.$watch(propNameToWatch, function(newValue, oldValue) { if (newValue !== oldValue) { - return _this.onWatch(propNameToWatch, scope); + return _this.onWatch(propNameToWatch, scope, newValue, oldValue); } }, true); }; - IMarkerParentModel.prototype.watchShallow = function(propNameToWatch, scope) { - var _this = this; - return scope.$watch(propNameToWatch, function(newValue, oldValue) { - if (newValue !== oldValue) { - return _this.onWatch(propNameToWatch, scope); - } - }, false); - }; - - IMarkerParentModel.prototype.onWatch = function(propNameToWatch, scope) { + IMarkerParentModel.prototype.onWatch = function(propNameToWatch, scope, newValue, oldValue) { throw new Exception("Not Implemented!!"); }; @@ -607,7 +631,7 @@ angular.module('google-maps', []);;(function() { } MarkersParentModel.prototype.onTimeOut = function(scope) { - this.watchShallow('models', scope); + this.watch('models', scope); return this.createMarkers(scope); }; @@ -625,6 +649,7 @@ angular.module('google-maps', []);;(function() { _this = this; _ref = scope.models; _fn = function(model) { + scope.doRebuild = true; _this.markers.push(new directives.api.models.child.MarkerChildModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, function(index) { return delete _this.markers[index]; }, _this.DEFAULTS, _this.doClick)); @@ -640,6 +665,9 @@ angular.module('google-maps', []);;(function() { MarkersParentModel.prototype.reBuildMarkers = function(scope) { var oldM, _fn, _i, _len, _ref, _this = this; + if (!scope.doRebuild && scope.doRebuild !== void 0) { + return; + } _ref = this.markers; _fn = function(oldM) { return oldM.destroy(); @@ -654,7 +682,10 @@ angular.module('google-maps', []);;(function() { return this.createMarkers(scope); }; - MarkersParentModel.prototype.onWatch = function(propNameToWatch, scope) { + MarkersParentModel.prototype.onWatch = function(propNameToWatch, scope, newValue, oldValue) { + if (propNameToWatch === 'models' && newValue.length === oldValue.length) { + return; + } return this.reBuildMarkers(scope); }; @@ -692,6 +723,7 @@ angular.module('google-maps', []);;(function() { function WindowsParentModel(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache, $interpolate) { this.interpolateContent = __bind(this.interpolateContent, this); + this.setChildScope = __bind(this.setChildScope, this); this.createWindow = __bind(this.createWindow, this); this.setContentKeys = __bind(this.setContentKeys, this); this.createChildScopesWindows = __bind(this.createChildScopesWindows, this); @@ -748,7 +780,7 @@ angular.module('google-maps', []);;(function() { var _this = this; return scope.$watch('models', function(newValue, oldValue) { var model, _fn, _i, _len, _ref; - if (newValue !== oldValue) { + if (newValue !== oldValue && newValue.length !== oldValue.length) { _ref = _this.windows; _fn = function(model) { return model.destroy(); @@ -805,11 +837,11 @@ angular.module('google-maps', []);;(function() { This may force redundant information into the model, but this appears to be the most flexible approach. */ - var gMap, isIconVisibleOnClick, markersScope, mm, model, modelsNotDefined, _fn, _i, _j, _len, _len1, _ref, _ref1, + var gMap, markersScope, mm, model, modelsNotDefined, _fn, _i, _j, _len, _len1, _ref, _ref1, _this = this; this.isIconVisibleOnClick = true; if (angular.isDefined(this.linked.attrs.isiconvisibleonclick)) { - isIconVisibleOnClick = this.linked.scope.isIconVisibleOnClick; + this.isIconVisibleOnClick = this.linked.scope.isIconVisibleOnClick; } gMap = this.linked.ctrls[0].getMap(); markersScope = this.linked.ctrls.length > 1 && (this.linked.ctrls[1] != null) ? this.linked.ctrls[1].getMarkersScope() : void 0; @@ -870,22 +902,37 @@ angular.module('google-maps', []);;(function() { } */ - var childScope, name, opts, parsedContent, _fn, _i, _len, _ref, + var childScope, opts, parsedContent, _this = this; childScope = this.linked.scope.$new(false); + this.setChildScope(childScope, model); + childScope.$watch('model', function(newValue, oldValue) { + if (newValue !== oldValue) { + return _this.setChildScope(childScope, newValue); + } + }, true); + parsedContent = this.interpolateContent(this.linked.element.html(), model); + opts = this.createWindowOptions(gMarker, childScope, parsedContent, this.DEFAULTS); + return this.windows.push(new directives.api.models.child.WindowChildModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$http, this.$templateCache, this.$compile, true)); + }; + + WindowsParentModel.prototype.setChildScope = function(childScope, model) { + var name, _fn, _i, _len, _ref, + _this = this; _ref = this.scopePropNames; _fn = function(name) { - var nameKey; + var nameKey, newValue; nameKey = name + 'Key'; - return childScope[name] = _this[nameKey] === 'self' ? model : model[_this[nameKey]]; + newValue = _this[nameKey] === 'self' ? model : model[_this[nameKey]]; + if (newValue !== childScope[name]) { + return childScope[name] = newValue; + } }; for (_i = 0, _len = _ref.length; _i < _len; _i++) { name = _ref[_i]; _fn(name); } - parsedContent = this.interpolateContent(this.linked.element.html(), model); - opts = this.createWindowOptions(gMarker, childScope, parsedContent, this.DEFAULTS); - return this.windows.push(new directives.api.models.child.WindowChildModel(childScope, opts, this.isIconVisibleOnClick, gMap, gMarker, this.$http, this.$templateCache, this.$compile, true)); + return childScope.model = model; }; WindowsParentModel.prototype.interpolateContent = function(content, model) { diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 274f7ae05..95db7f8bb 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.destroy=a(this.destroy,this);var j=this;this.index=b,this.model=c,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.myScope.icon="self"===this.iconKey?c:c[this.iconKey],this.myScope.coords="self"===this.coordsKey?c:c[this.coordsKey],this.myScope.click="self"===this.clickKey?c:c[this.clickKey],this.myScope.animate="self"===this.animateKey?c:c[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?a?(b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.latitude,a.longitude)),b.gMarker.setVisible(null!=a.latitude&&null!=a.longitude)):b.gMarker.setMap(null):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.gMarker.icon=c,b.gMarker.setMap(null),b.gMarker.setMap(b.gMap.getMap()),b.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),b.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watchShallow=a(this.watchShallow,this),this.watchDeep=a(this.watchDeep,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watchDeep("coords",b),h.watchDeep("icon",b),h.watchDeep("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watchDeep=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b):void 0},!0)},d.prototype.watchShallow=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b):void 0},!1)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watchShallow("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)},d.prototype.onWatch=function(a,b){return this.reBuildMarkers(b)},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(b=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),c=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,f=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,f&&(void 0===c||void 0===c.markerModels||void 0===c.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),l=this.linked.scope.models,h=0,j=l.length;j>h;h++)e=l[h],this.createWindow(e,void 0,a);else for(this.models=c.models,this.firstTime&&(this.watchModels(c),this.watchDestroy(c)),this.setContentKeys(c.models),m=c.markerModels,g=function(b){return n.createWindow(b.model,b.gMarker,a)},i=0,k=m.length;k>i;i++)d=m[i],g(d);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g,h,i,j,k,l=this;for(d=this.linked.scope.$new(!1),k=this.scopePropNames,h=function(b){var c;return c=b+"Key",d[b]="self"===l[c]?a:a[l[c]]},i=0,j=k.length;j>i;i++)e=k[i],h(e);return g=this.interpolateContent(this.linked.element.html(),a),f=this.createWindowOptions(b,d,g,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,f,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.setIcon=a(this.setIcon,this),this.setCoords=a(this.setCoords,this),this.destroy=a(this.destroy,this),this.setMyScope=a(this.setMyScope,this);var j=this;this.index=b,this.model=c,this.parentScope=d,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.setMyScope(c),this.myScope.$watch("model",function(a,b){return a!==b?j.setMyScope(a):void 0},!0),this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),this.setCoords(this.myScope),this.setIcon(this.myScope),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.setMyScope=function(a){return this.myScope.icon="self"===this.iconKey?a:a[this.iconKey],this.myScope.coords="self"===this.coordsKey?a:a[this.coordsKey],this.myScope.click="self"===this.clickKey?a:a[this.clickKey],this.myScope.animate="self"===this.animateKey?a:a[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.myScope.model=a},d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.setCoords=function(a){return a.$id===this.myScope.$id?null!=a.coords?(this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(null!=a.coords.latitude&&null!=a.coords.longitude)):this.gMarker.setMap(null):void 0},d.prototype.setIcon=function(a){return a.$id===this.myScope.$id?(this.gMarker.icon=a.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?(b.parentScope.doRebuild=!1,b.setCoords(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.parentScope.doRebuild=!1,b.setIcon(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watch=a(this.watch,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watch("coords",b),h.watch("icon",b),h.watch("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watch=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b,d,e):void 0},!0)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watch("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return a.doRebuild=!0,g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;if(a.doRebuild||void 0===a.doRebuild){for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b + if (newValue != oldValue) + @setMyScope(newValue) + ,true) @defaults = defaults @gMap = gMap @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,@myScope.animate,@defaults) @@ -33,6 +33,14 @@ @watchIcon(@myScope) @watchDestroy(@myScope) ) + setMyScope:(model)=> + @myScope.icon = if @iconKey == 'self' then model else model[@iconKey] + @myScope.coords = if @coordsKey == 'self' then model else model[@coordsKey] + @myScope.click = if @clickKey == 'self' then model else model[@clickKey] + @myScope.animate = if @animateKey == 'self' then model else model[@animateKey] + @myScope.animate = if @animateKey == undefined then false else @myScope.animate + @myScope.model = model + destroy:() => @myScope.$destroy() From 34c80c139c4bc78c8ab933ac4b21cfcb65dad3dc Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 13:59:06 -0400 Subject: [PATCH 35/41] update scope coords and icon correctly in markerchildmodel --- dist/angular-google-maps.js | 4 ++-- dist/angular-google-maps.min.js | 2 +- .../directives/api/models/child/marker-child-model.coffee | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 7da3b431f..9e4137909 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -252,7 +252,7 @@ angular.module('google-maps', []);;(function() { return scope.$watch('coords', function(newValue, oldValue) { if (newValue !== oldValue) { _this.parentScope.doRebuild = false; - _this.setCoords(newValue); + _this.setCoords(scope); return _this.parentScope.doRebuild = true; } }, true); @@ -263,7 +263,7 @@ angular.module('google-maps', []);;(function() { return scope.$watch('icon', function(newValue, oldValue) { if (newValue !== oldValue) { _this.parentScope.doRebuild = false; - _this.setIcon(newValue); + _this.setIcon(scope); return _this.parentScope.doRebuild = true; } }, true); diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 95db7f8bb..011622b68 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.setIcon=a(this.setIcon,this),this.setCoords=a(this.setCoords,this),this.destroy=a(this.destroy,this),this.setMyScope=a(this.setMyScope,this);var j=this;this.index=b,this.model=c,this.parentScope=d,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.setMyScope(c),this.myScope.$watch("model",function(a,b){return a!==b?j.setMyScope(a):void 0},!0),this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),this.setCoords(this.myScope),this.setIcon(this.myScope),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.setMyScope=function(a){return this.myScope.icon="self"===this.iconKey?a:a[this.iconKey],this.myScope.coords="self"===this.coordsKey?a:a[this.coordsKey],this.myScope.click="self"===this.clickKey?a:a[this.clickKey],this.myScope.animate="self"===this.animateKey?a:a[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.myScope.model=a},d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.setCoords=function(a){return a.$id===this.myScope.$id?null!=a.coords?(this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(null!=a.coords.latitude&&null!=a.coords.longitude)):this.gMarker.setMap(null):void 0},d.prototype.setIcon=function(a){return a.$id===this.myScope.$id?(this.gMarker.icon=a.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(a,c){return a!==c?(b.parentScope.doRebuild=!1,b.setCoords(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(a,c){return a!==c?(b.parentScope.doRebuild=!1,b.setIcon(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watch=a(this.watch,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watch("coords",b),h.watch("icon",b),h.watch("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watch=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b,d,e):void 0},!0)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watch("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return a.doRebuild=!0,g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;if(a.doRebuild||void 0===a.doRebuild){for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.setIcon=a(this.setIcon,this),this.setCoords=a(this.setCoords,this),this.destroy=a(this.destroy,this),this.setMyScope=a(this.setMyScope,this);var j=this;this.index=b,this.model=c,this.parentScope=d,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.setMyScope(c),this.myScope.$watch("model",function(a,b){return a!==b?j.setMyScope(a):void 0},!0),this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),this.setCoords(this.myScope),this.setIcon(this.myScope),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.setMyScope=function(a){return this.myScope.icon="self"===this.iconKey?a:a[this.iconKey],this.myScope.coords="self"===this.coordsKey?a:a[this.coordsKey],this.myScope.click="self"===this.clickKey?a:a[this.clickKey],this.myScope.animate="self"===this.animateKey?a:a[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.myScope.model=a},d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.setCoords=function(a){return a.$id===this.myScope.$id?null!=a.coords?(this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(null!=a.coords.latitude&&null!=a.coords.longitude)):this.gMarker.setMap(null):void 0},d.prototype.setIcon=function(a){return a.$id===this.myScope.$id?(this.gMarker.icon=a.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setCoords(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setIcon(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watch=a(this.watch,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watch("coords",b),h.watch("icon",b),h.watch("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watch=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b,d,e):void 0},!0)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watch("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return a.doRebuild=!0,g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;if(a.doRebuild||void 0===a.doRebuild){for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b if (newValue != oldValue) @parentScope.doRebuild = false - @setCoords(newValue) + @setCoords(scope) @parentScope.doRebuild = true , true) @@ -77,7 +77,7 @@ scope.$watch('icon', (newValue, oldValue) => if (newValue != oldValue) @parentScope.doRebuild = false - @setIcon(newValue) + @setIcon(scope) @parentScope.doRebuild = true , true) From ab3e8db0a2d2d8b8dbe57bc4f30315b463242c50 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Mon, 29 Jul 2013 20:02:54 -0400 Subject: [PATCH 36/41] wrapping scope.clicks in per @asabourin --- dist/angular-google-maps.js | 8 ++++++-- dist/angular-google-maps.min.js | 2 +- .../directives/api/models/child/marker-child-model.coffee | 4 +++- .../api/models/parent/marker-parent-model.coffee | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 9e4137909..8ccf7f1ba 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -198,7 +198,9 @@ angular.module('google-maps', []);;(function() { this.$log = directives.api.utils.Logger; google.maps.event.addListener(this.gMarker, 'click', function() { if (_this.doClick && (_this.myScope.click != null)) { - return _this.myScope.click(); + return $timeout(function() { + return _this.myScope.click(); + }); } }); this.setCoords(this.myScope); @@ -552,7 +554,9 @@ angular.module('google-maps', []);;(function() { this.scope = scope; google.maps.event.addListener(this.gMarker, 'click', function() { if (_this.doClick && (scope.click != null)) { - return _this.scope.click(); + return $timeout(function() { + return _this.scope.click(); + }); } }); this.$log.info(this); diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 011622b68..695dff436 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.setIcon=a(this.setIcon,this),this.setCoords=a(this.setCoords,this),this.destroy=a(this.destroy,this),this.setMyScope=a(this.setMyScope,this);var j=this;this.index=b,this.model=c,this.parentScope=d,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.setMyScope(c),this.myScope.$watch("model",function(a,b){return a!==b?j.setMyScope(a):void 0},!0),this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?j.myScope.click():void 0}),this.setCoords(this.myScope),this.setIcon(this.myScope),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.setMyScope=function(a){return this.myScope.icon="self"===this.iconKey?a:a[this.iconKey],this.myScope.coords="self"===this.coordsKey?a:a[this.coordsKey],this.myScope.click="self"===this.clickKey?a:a[this.clickKey],this.myScope.animate="self"===this.animateKey?a:a[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.myScope.model=a},d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.setCoords=function(a){return a.$id===this.myScope.$id?null!=a.coords?(this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(null!=a.coords.latitude&&null!=a.coords.longitude)):this.gMarker.setMap(null):void 0},d.prototype.setIcon=function(a){return a.$id===this.myScope.$id?(this.gMarker.icon=a.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setCoords(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setIcon(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watch=a(this.watch,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watch("coords",b),h.watch("icon",b),h.watch("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watch=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b,d,e):void 0},!0)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?j.scope.click():void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watch("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return a.doRebuild=!0,g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;if(a.doRebuild||void 0===a.doRebuild){for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;bb;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.setIcon=a(this.setIcon,this),this.setCoords=a(this.setCoords,this),this.destroy=a(this.destroy,this),this.setMyScope=a(this.setMyScope,this);var j=this;this.index=b,this.model=c,this.parentScope=d,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.setMyScope(c),this.myScope.$watch("model",function(a,b){return a!==b?j.setMyScope(a):void 0},!0),this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?f(function(){return j.myScope.click()}):void 0}),this.setCoords(this.myScope),this.setIcon(this.myScope),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.setMyScope=function(a){return this.myScope.icon="self"===this.iconKey?a:a[this.iconKey],this.myScope.coords="self"===this.coordsKey?a:a[this.coordsKey],this.myScope.click="self"===this.clickKey?a:a[this.clickKey],this.myScope.animate="self"===this.animateKey?a:a[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.myScope.model=a},d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.setCoords=function(a){return a.$id===this.myScope.$id?null!=a.coords?(this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(null!=a.coords.latitude&&null!=a.coords.longitude)):this.gMarker.setMap(null):void 0},d.prototype.setIcon=function(a){return a.$id===this.myScope.$id?(this.gMarker.icon=a.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setCoords(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setIcon(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watch=a(this.watch,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watch("coords",b),h.watch("icon",b),h.watch("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watch=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b,d,e):void 0},!0)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?g(function(){return j.scope.click()}):void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watch("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return a.doRebuild=!0,g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;if(a.doRebuild||void 0===a.doRebuild){for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b #this needs to be thought about as scope is not 1:1 on clicking..... hmmmmm :/ if @doClick and @myScope.click? - @myScope.click() + $timeout(=> + @myScope.click() + ) ) @setCoords(@myScope) @setIcon(@myScope) diff --git a/src/coffee/directives/api/models/parent/marker-parent-model.coffee b/src/coffee/directives/api/models/parent/marker-parent-model.coffee index 0c953a6cf..dbb2190d9 100644 --- a/src/coffee/directives/api/models/parent/marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/marker-parent-model.coffee @@ -16,7 +16,9 @@ @scope = scope google.maps.event.addListener(@gMarker, 'click', => if @doClick and scope.click? - @scope.click() + $timeout( => + @scope.click() + ) ) @$log.info(@) From 9386f41ee73bd509b68cd8fdf06c840966ffeb65 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 1 Aug 2013 09:11:32 -0400 Subject: [PATCH 37/41] Updates from my repository feature/many_markers --- dist/angular-google-maps.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 510ecb35d..7dcfce555 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -1,4 +1,4 @@ -/*! angular-google-maps 0.0.0 2013-07-29 +/*! angular-google-maps 0.0.0 2013-07-30 * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ From 81cfded9caa681b8fd0ad3beb1b1bb7dd0658ef9 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 7 Aug 2013 20:50:05 -0400 Subject: [PATCH 38/41] removed a dead directory as it has been replaced by the js/directives and coffee scheme. --- src/directives/marker.js | 144 --------------------------------------- 1 file changed, 144 deletions(-) delete mode 100644 src/directives/marker.js diff --git a/src/directives/marker.js b/src/directives/marker.js deleted file mode 100644 index 095373f6b..000000000 --- a/src/directives/marker.js +++ /dev/null @@ -1,144 +0,0 @@ -/**! - * The MIT License - * - * Copyright (c) 2010-2012 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 - * - * @author Nicolas Laplante https://plus.google.com/108189012221374960701 - */ - -/** - * Map marker directive - * - * This directive is used to create a marker on an existing map. - * This directive creates a new scope. - * - * {attribute coords required} object containing latitude and longitude properties - * {attribute icon optional} string url to image used for marker icon - * {attribute animate optional} if set to false, the marker won't be animated (on by default) - */ - -angular.module('google-maps') - .directive('marker', ['$log', '$timeout', function ($log, $timeout) { - - "use strict"; - - var DEFAULTS = { - // Animation is enabled by default - animation: google.maps.Animation.DROP - }; - - /** - * Check if a value is literally false - * @param value the value to test - * @returns {boolean} true if value is literally false, false otherwise - */ - function isFalse(value) { - return ['false', 'FALSE', 0, 'n', 'N', 'no', 'NO'].indexOf(value ) !== -1; - } - - return { - restrict: 'ECMA', - require: '^googleMap', - priority: -1, - transclude: true, - template: '', - replace: true, - scope: { - coords: '=coords', - icon: '=icon', - click: '&click' - }, - controller: function ($scope, $element) { - this.getMarker = function () { - return $element.data('instance'); - }; - }, - link: function (scope, element, attrs, mapCtrl) { - - // Validate required properties - if (angular.isUndefined(scope.coords) || - scope.coords === null || - angular.isUndefined(scope.coords.latitude) || - angular.isUndefined(scope.coords.longitude)) { - - $log.error("marker: no valid coords attribute found"); - return; - } - - // Wrap marker initialization inside a $timeout() call to make sure the map is created already - $timeout(function () { - var opts = angular.extend({}, DEFAULTS, { - position: new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude), - map: mapCtrl.getMap(), - icon: scope.icon, - visible: scope.coords.latitude !== null && scope.coords.longitude !== null - }); - - // Disable animations - if (angular.isDefined(attrs.animate) && isFalse(attrs.animate)) { - delete opts.animation; - } - - var marker = new google.maps.Marker(opts); - element.data('instance', marker); - - google.maps.event.addListener(marker, 'click', function () { - if (angular.isDefined(attrs.click) && scope.click !== null) - $timeout(function() { - scope.click(); - }); - }); - - scope.$watch('coords', function (newValue, oldValue) { - if (newValue !== oldValue) { - if (newValue) { - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(newValue.latitude, newValue.longitude)); - marker.setVisible(newValue.latitude !== null && newValue.longitude !== null); - } - else { - // Remove marker - marker.setMap(null); - } - } - }, true); - - scope.$watch('icon', function (newValue, oldValue) { - if (newValue !== oldValue) { - marker.icon = newValue; - marker.setMap(null); - marker.setMap(mapCtrl.getMap()); - marker.setPosition(new google.maps.LatLng(scope.coords.latitude, scope.coords.longitude)); - marker.setVisible(scope.coords.latitude !== null && scope.coords.longitude !== null); - } - }, true); - - // remove marker on scope $destroy - scope.$on("$destroy", function () { - marker.setMap(null); - }); - }); - } - }; - }]); From 99be652e7ff3eda48f592c2f253d44da2a870997 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 14 Aug 2013 11:24:40 -0400 Subject: [PATCH 39/41] AsyncProcessor to churn LargeArrays in chunks with timeouts to free the UI up. Renamed module to ngGmapModule --- Gruntfile.js | 2 +- dist/angular-google-maps.js | 97 +++++++++++++------ dist/angular-google-maps.min.js | 4 +- src/coffee/directives/api/i-marker.coffee | 2 +- src/coffee/directives/api/i-window.coffee | 2 +- src/coffee/directives/api/marker.coffee | 2 +- src/coffee/directives/api/markers.coffee | 2 +- .../models/child/marker-child-model.coffee | 2 +- .../models/child/window-child-model.coffee | 2 +- .../parent/i-marker-parent-model.coffee | 2 +- .../parent/i-window-parent-model.coffee | 2 +- .../models/parent/marker-parent-model.coffee | 2 +- .../models/parent/markers-parent-model.coffee | 21 ++-- .../models/parent/windows-parent-model.coffee | 23 +++-- .../api/utils/async-processor.coffee | 25 +++++ .../directives/api/utils/gmap-util.coffee | 2 +- src/coffee/directives/api/utils/linked.coffee | 2 +- src/coffee/directives/api/utils/logger.coffee | 2 +- src/coffee/directives/api/window.coffee | 2 +- src/coffee/directives/api/windows.coffee | 2 +- src/coffee/oo/base-object.coffee | 2 +- .../{module.coffee => ng-gmap-module.coffee} | 6 +- 22 files changed, 139 insertions(+), 69 deletions(-) create mode 100644 src/coffee/directives/api/utils/async-processor.coffee rename src/coffee/oo/{module.coffee => ng-gmap-module.coffee} (55%) diff --git a/Gruntfile.js b/Gruntfile.js index 388faf9ab..77e3ec3ce 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -38,7 +38,7 @@ module.exports = function(grunt) { files: { 'tmp/output_coffee.js': ['src/coffee/*.coffee', - 'src/coffee/oo/module.coffee', + 'src/coffee/oo/ng-gmap-module.coffee', 'src/coffee/oo/base-object.coffee', 'src/coffee/directives/api/utils/*.coffee', 'src/coffee/directives/api/models/child/*.coffee', diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index e317a72d4..3f66d3c8f 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -28,15 +28,15 @@ */ angular.module('google-maps', []);;(function() { - this.module = function(names, fn) { + this.ngGmapModule = function(names, fn) { var space, _name; if (typeof names === 'string') { names = names.split('.'); } space = this[_name = names.shift()] || (this[_name] = {}); - space.module || (space.module = this.module); + space.ngGmapModule || (space.ngGmapModule = this.ngGmapModule); if (names.length) { - return space.module(names, fn); + return space.ngGmapModule(names, fn); } else { return fn.call(space); } @@ -47,7 +47,7 @@ angular.module('google-maps', []);;(function() { (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; }; - this.module("oo", function() { + this.ngGmapModule("oo", function() { var baseObjectKeywords; baseObjectKeywords = ['extended', 'included']; return this.BaseObject = (function() { @@ -88,8 +88,52 @@ angular.module('google-maps', []);;(function() { }).call(this); +/* + Author: Nicholas McCready & jfriend00 + AsyncProcessor 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 +*/ + + +(function() { + this.ngGmapModule("directives.api.utils", function() { + return this.AsyncProcessor = { + handleLargeArray: function(array, callback, pausedCallBack, chunk, index) { + var doChunk; + if (chunk == null) { + chunk = 100; + } + if (index == null) { + index = 0; + } + if (array === void 0 || array.length <= 0) { + return; + } + doChunk = function() { + var cnt, i; + cnt = chunk; + i = index; + while (cnt-- && i < array.length) { + callback(array[i]); + ++i; + } + if (i < array.length) { + index = i; + if (pausedCallBack != null) { + pausedCallBack(); + } + return setTimeout(doChunk(), 1); + } + }; + return doChunk(); + } + }; + }); + +}).call(this); + (function() { - this.module("directives.api.utils", function() { + this.ngGmapModule("directives.api.utils", function() { return this.GmapUtil = { createMarkerOptions: function(map, coords, icon, animate, defaults) { var opts; @@ -119,7 +163,7 @@ angular.module('google-maps', []);;(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; }; - this.module("directives.api.utils", function() { + this.ngGmapModule("directives.api.utils", function() { return this.Linked = (function(_super) { __extends(Linked, _super); @@ -138,7 +182,7 @@ angular.module('google-maps', []);;(function() { }).call(this); (function() { - this.module("directives.api.utils", function() { + this.ngGmapModule("directives.api.utils", function() { return this.Logger = { logger: void 0, doLog: false, @@ -161,7 +205,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api.models.child", function() { + this.ngGmapModule("directives.api.models.child", function() { return this.MarkerChildModel = (function(_super) { __extends(MarkerChildModel, _super); @@ -293,7 +337,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api.models.child", function() { + this.ngGmapModule("directives.api.models.child", function() { return this.WindowChildModel = (function(_super) { __extends(WindowChildModel, _super); @@ -406,7 +450,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api.models.parent", function() { + this.ngGmapModule("directives.api.models.parent", function() { return this.IMarkerParentModel = (function(_super) { __extends(IMarkerParentModel, _super); @@ -496,7 +540,7 @@ angular.module('google-maps', []);;(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; }; - this.module("directives.api.models.parent", function() { + this.ngGmapModule("directives.api.models.parent", function() { return this.IWindowParentModel = (function(_super) { __extends(IWindowParentModel, _super); @@ -533,7 +577,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api.models.parent", function() { + this.ngGmapModule("directives.api.models.parent", function() { return this.MarkerParentModel = (function(_super) { __extends(MarkerParentModel, _super); @@ -613,7 +657,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api.models.parent", function() { + this.ngGmapModule("directives.api.models.parent", function() { return this.MarkersParentModel = (function(_super) { __extends(MarkersParentModel, _super); @@ -632,6 +676,7 @@ angular.module('google-maps', []);;(function() { this.markersIndex = 0; this.scope = scope; this.$log.info(this); + this.bigGulp = directives.api.utils.AsyncProcessor; } MarkersParentModel.prototype.onTimeOut = function(scope) { @@ -649,20 +694,14 @@ angular.module('google-maps', []);;(function() { }; MarkersParentModel.prototype.createMarkers = function(scope) { - var model, _fn, _i, _len, _ref, - _this = this; - _ref = scope.models; - _fn = function(model) { + var _this = this; + this.bigGulp.handleLargeArray(scope.models, function(model) { scope.doRebuild = true; _this.markers.push(new directives.api.models.child.MarkerChildModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, function(index) { return delete _this.markers[index]; }, _this.DEFAULTS, _this.doClick)); return _this.markersIndex++; - }; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - model = _ref[_i]; - _fn(model); - } + }); return scope.markerModels = this.markers; }; @@ -721,7 +760,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api.models.parent", function() { + this.ngGmapModule("directives.api.models.parent", function() { return this.WindowsParentModel = (function(_super) { __extends(WindowsParentModel, _super); @@ -976,7 +1015,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api", function() { + this.ngGmapModule("directives.api", function() { return this.IMarker = (function(_super) { __extends(IMarker, _super); @@ -1024,7 +1063,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api", function() { + this.ngGmapModule("directives.api", function() { return this.IWindow = (function(_super) { __extends(IWindow, _super); @@ -1075,7 +1114,7 @@ angular.module('google-maps', []);;(function() { __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; }; - this.module("directives.api", function() { + this.ngGmapModule("directives.api", function() { return this.Marker = (function(_super) { __extends(Marker, _super); @@ -1123,7 +1162,7 @@ not 1:1 in this setting. __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; }; - this.module("directives.api", function() { + this.ngGmapModule("directives.api", function() { return this.Markers = (function(_super) { __extends(Markers, _super); @@ -1167,7 +1206,7 @@ not 1:1 in this setting. __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; }; - this.module("directives.api", function() { + this.ngGmapModule("directives.api", function() { return this.Window = (function(_super) { __extends(Window, _super); @@ -1221,7 +1260,7 @@ not 1:1 in this setting. __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; }; - this.module("directives.api", function() { + this.ngGmapModule("directives.api", function() { return this.Windows = (function(_super) { __extends(Windows, _super); diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index b6486f5ce..90662d089 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -1,5 +1,5 @@ -/*! angular-google-maps 0.0.0 2013-08-08 +/*! angular-google-maps 0.0.0 2013-08-14 * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.module=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.module||(c.module=this.module),a.length?c.module(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.module("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.module("directives.api.utils",function(){return this.GmapUtil={createMarkerOptions:function(a,b,c,d,e){var f;return f=angular.extend({},e,{position:new google.maps.LatLng(b.latitude,b.longitude),map:a.getMap(),icon:c,visible:null!=b.latitude&&null!=b.longitude}),d||delete f.animation,f},createWindowOptions:function(a,b,c,d){return angular.extend({},d,{content:c,position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)})}}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.module("directives.api.utils",function(){return this.Logger={logger:void 0,doLog:!1,info:function(a){return directives.api.utils.Logger.doLog?null!=directives.api.utils.Logger.logger?directives.api.utils.Logger.logger.info(a):console.info(a):void 0}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i){this.watchDestroy=a(this.watchDestroy,this),this.watchIcon=a(this.watchIcon,this),this.watchCoords=a(this.watchCoords,this),this.setIcon=a(this.setIcon,this),this.setCoords=a(this.setCoords,this),this.destroy=a(this.destroy,this),this.setMyScope=a(this.setMyScope,this);var j=this;this.index=b,this.model=c,this.parentScope=d,this.iconKey=d.icon,this.coordsKey=d.coords,this.clickKey=d.click(),this.animateKey=d.animate,this.myScope=d.$new(!1),this.setMyScope(c),this.myScope.$watch("model",function(a,b){return a!==b?j.setMyScope(a):void 0},!0),this.defaults=h,this.gMap=e,this.opts=this.createMarkerOptions(this.gMap,this.myScope.coords,this.myScope.icon,this.myScope.animate,this.defaults),this.gMarker=new google.maps.Marker(this.opts),this.doClick=i,this.$log=directives.api.utils.Logger,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=j.myScope.click?f(function(){return j.myScope.click()}):void 0}),this.setCoords(this.myScope),this.setIcon(this.myScope),f(function(){return j.watchCoords(j.myScope),j.watchIcon(j.myScope),j.watchDestroy(j.myScope)})}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.setMyScope=function(a){return this.myScope.icon="self"===this.iconKey?a:a[this.iconKey],this.myScope.coords="self"===this.coordsKey?a:a[this.coordsKey],this.myScope.click="self"===this.clickKey?a:a[this.clickKey],this.myScope.animate="self"===this.animateKey?a:a[this.animateKey],this.myScope.animate=void 0===this.animateKey?!1:this.myScope.animate,this.myScope.model=a},d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.setCoords=function(a){return a.$id===this.myScope.$id?null!=a.coords?(this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(null!=a.coords.latitude&&null!=a.coords.longitude)):this.gMarker.setMap(null):void 0},d.prototype.setIcon=function(a){return a.$id===this.myScope.$id?(this.gMarker.icon=a.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.gMap.getMap()),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},d.prototype.watchCoords=function(a){var b=this;return a.$watch("coords",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setCoords(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchIcon=function(a){var b=this;return a.$watch("icon",function(c,d){return c!==d?(b.parentScope.doRebuild=!1,b.setIcon(a),b.parentScope.doRebuild=!0):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.gMarker.setMap(null),"undefined"!=typeof notifyLocalDestroy&&null!==notifyLocalDestroy?notifyLocalDestroy(b.index):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){null==j&&(j=!1),this.destroy=a(this.destroy,this),this.scope=b,this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.gWin=new google.maps.InfoWindow(c),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(this.scope,this.mapCtrl,this.markerCtrl,this.gWin,this.isIconVisibleOnClick,this.initialMarkerVisibility),this.watchShow(b,g,h,this.$compile,this.gWin,this.showWindow,this.hideWindow,this.mapCtrl),this.needToManualDestroy=j,this.$log.info(this)}return c(d,b),d.prototype.watchShow=function(a,b,c,d,e,f,g,h){return a.$watch("show",function(i,j){return i!==j?i?f(a,b,c,d,e,h):g(e):i&&!e.getMap()?f(a,b,c,d,e,h):void 0},!0)},d.prototype.handleClick=function(a,b,c,d,e,f){return null!=c?(google.maps.event.addListener(c,"click",function(){return d.setPosition(c.getPosition()),d.open(b),c.setVisible(e)}),google.maps.event.addListener(d,"closeclick",function(){return c.setVisible(f),a.closeClick()})):void 0},d.prototype.showWindow=function(a,b,c,d,e,f){return a.templateUrl?b.get(a.templateUrl,{cache:c}).then(function(b){var c,g;return g=a.$new(),angular.isDefined(a.templateParameter)&&(g.parameter=a.templateParameter),c=d(b.data)(g),e.setContent(c.get(0)),e.open(f)}):e.open(f)},d.prototype.hideWindow=function(a){return a.close()},d.prototype.destroy=function(){return this.hideWindow(this.gWin),null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,delete this},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watch=a(this.watch,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var g,h=this;g=this,this.validateScope(b)||(this.animate=angular.isDefined(d.animate)?!this.isFalse(d.animate):!1,this.doClick=angular.isDefined(d.click),this.mapCtrl=e,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=f,this.$timeout(function(){return h.watch("coords",b),h.watch("icon",b),h.watch("animate",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={animation:google.maps.Animation.DROP},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.coords)||void 0===a.coords,b&&this.$log.error(this.clsName+": no valid coords attribute found"),b},d.prototype.watch=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b,d,e):void 0},!0)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.module("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.clsName="directives.api.models.parent.IWindow",this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.validateScope=a(this.validateScope,this);var h,i,j=this;d.__super__.constructor.call(this,b,c,e,f,g),i=this,this.clsName="MarkerParentModel",h=this.createMarkerOptions(f,b.coords,b.icon,this.animate,this.DEFAULTS),this.gMarker=new google.maps.Marker(h),c.data("instance",this.gMarker),this.scope=b,google.maps.event.addListener(this.gMarker,"click",function(){return j.doClick&&null!=b.click?g(function(){return j.scope.click()}):void 0}),this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.validateScope=function(a){return d.__super__.validateScope.call(this,a)||angular.isUndefined(a.coords.latitude)||angular.isUndefined(a.coords.longitude)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.gMarker?(this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude)):this.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.gMarker)return this.gMarker.icon=b.icon,this.gMarker.setMap(null),this.gMarker.setMap(this.mapCtrl.getMap()),this.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"animate":}},d.prototype.onDestroy=function(){return void 0===this.gMarker?(delete this,void 0):(this.gMarker.setMap(null),delete this.gMarker,delete this)},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this,this.clsName="MarkersParentModel",this.markers=[],this.markersIndex=0,this.scope=b,this.$log.info(this)}return c(d,b),d.prototype.onTimeOut=function(a){return this.watch("models",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.clsName+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c,d,e,f,g=this;for(f=a.models,c=function(b){return a.doRebuild=!0,g.markers.push(new directives.api.models.child.MarkerChildModel(g.markersIndex,b,a,g.mapCtrl,g.$timeout,function(a){return delete g.markers[a]},g.DEFAULTS,g.doClick)),g.markersIndex++},d=0,e=f.length;e>d;d++)b=f[d],c(b);return a.markerModels=this.markers},d.prototype.reBuildMarkers=function(a){var b,c,d,e,f;if(a.doRebuild||void 0===a.doRebuild){for(f=this.markers,c=function(a){return a.destroy()},d=0,e=f.length;e>d;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.module("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events",bounds:"=bounds"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom,bounds:e.bounds})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),google.maps.event.addListener(k,"idle",function(){var a=k.getBounds(),c=a.getNorthEast(),d=a.getSouthWest();b(function(){e.$apply(function(a){null!==a.bounds&&void 0!==a.bounds&&void 0!==a.bounds&&(a.bounds.northeast={latitude:c.lat(),longitude:c.lng()},a.bounds.southwest={latitude:d.lat(),longitude:d.lng()})})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)}),e.$watch("bounds",function(a,b){if(a!==b){var c=new google.maps.LatLng(a.northeast.latitude,a.northeast.longitude),d=new google.maps.LatLng(a.southwest.latitude,a.southwest.longitude),e=new google.maps.LatLngBounds(d,c);k.fitBounds(e)}})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',replace:!0,scope:{show:"=show"},link:function(a,c,d,e){var f,g=new google.maps.TrafficLayer,h=!0;b(function(){f=e.getMap(),angular.isDefined(d.show)&&(h=a.show),null!==h&&h&&null!==f&&g.setMap(f),a.$watch("show",function(a,b){a!==b&&(h=a,a?g.setMap(f):g.setMap(null))},!0),a.$on("$destroy",function(){g.setMap(null)})})}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.ngGmapModule=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.ngGmapModule||(c.ngGmapModule=this.ngGmapModule),a.length?c.ngGmapModule(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.ngGmapModule("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.AsyncProcessor={handleLargeArray:function(a,b,c,d,e){var f;return null==d&&(d=100),null==e&&(e=0),void 0===a||a.length<=0?void 0:(f=function(){var g,h;for(g=d,h=e;g--&&hd;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events",bounds:"=bounds"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom,bounds:e.bounds})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),google.maps.event.addListener(k,"idle",function(){var a=k.getBounds(),c=a.getNorthEast(),d=a.getSouthWest();b(function(){e.$apply(function(a){null!==a.bounds&&void 0!==a.bounds&&void 0!==a.bounds&&(a.bounds.northeast={latitude:c.lat(),longitude:c.lng()},a.bounds.southwest={latitude:d.lat(),longitude:d.lng()})})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)}),e.$watch("bounds",function(a,b){if(a!==b){var c=new google.maps.LatLng(a.northeast.latitude,a.northeast.longitude),d=new google.maps.LatLng(a.southwest.latitude,a.southwest.longitude),e=new google.maps.LatLngBounds(d,c);k.fitBounds(e)}})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',replace:!0,scope:{show:"=show"},link:function(a,c,d,e){var f,g=new google.maps.TrafficLayer,h=!0;b(function(){f=e.getMap(),angular.isDefined(d.show)&&(h=a.show),null!==h&&h&&null!==f&&g.setMap(f),a.$watch("show",function(a,b){a!==b&&(h=a,a?g.setMap(f):g.setMap(null))},!0),a.$on("$destroy",function(){g.setMap(null)})})}}}]); \ No newline at end of file diff --git a/src/coffee/directives/api/i-marker.coffee b/src/coffee/directives/api/i-marker.coffee index 7a53eb1a0..c494b9472 100644 --- a/src/coffee/directives/api/i-marker.coffee +++ b/src/coffee/directives/api/i-marker.coffee @@ -6,7 +6,7 @@ - icon - implementation needed on watches ### -@module "directives.api", -> +@ngGmapModule "directives.api", -> class @IMarker extends oo.BaseObject constructor: ($timeout) -> self = @ diff --git a/src/coffee/directives/api/i-window.coffee b/src/coffee/directives/api/i-window.coffee index d6e7bea28..66ca455fe 100644 --- a/src/coffee/directives/api/i-window.coffee +++ b/src/coffee/directives/api/i-window.coffee @@ -1,7 +1,7 @@ ### - interface directive for all window(s) to derrive from ### -@module "directives.api", -> +@ngGmapModule "directives.api", -> class @IWindow extends oo.BaseObject constructor: ($timeout, $compile, $http, $templateCache) -> self = @ diff --git a/src/coffee/directives/api/marker.coffee b/src/coffee/directives/api/marker.coffee index bbb9103c2..a12fa1555 100644 --- a/src/coffee/directives/api/marker.coffee +++ b/src/coffee/directives/api/marker.coffee @@ -2,7 +2,7 @@ Basic Directive api for a marker. Basic in the sense that this directive contains 1:1 on scope and model. Thus there will be one html element per marker within the directive. ### -@module "directives.api", -> +@ngGmapModule "directives.api", -> class @Marker extends directives.api.IMarker constructor: ($timeout) -> super($timeout) diff --git a/src/coffee/directives/api/markers.coffee b/src/coffee/directives/api/markers.coffee index dff0baa1a..4716f308d 100644 --- a/src/coffee/directives/api/markers.coffee +++ b/src/coffee/directives/api/markers.coffee @@ -9,7 +9,7 @@ not 1:1 in this setting. - actual changes to a model are tracked inside directives.api.model.MarkerModel ### -@module "directives.api", -> +@ngGmapModule "directives.api", -> class @Markers extends directives.api.IMarker constructor: ($timeout) -> super($timeout) diff --git a/src/coffee/directives/api/models/child/marker-child-model.coffee b/src/coffee/directives/api/models/child/marker-child-model.coffee index 2044ef3a4..12d9dfb3f 100644 --- a/src/coffee/directives/api/models/child/marker-child-model.coffee +++ b/src/coffee/directives/api/models/child/marker-child-model.coffee @@ -1,4 +1,4 @@ -@module "directives.api.models.child", -> +@ngGmapModule "directives.api.models.child", -> class @MarkerChildModel extends oo.BaseObject @include directives.api.utils.GmapUtil constructor:(index,model,parentScope,gMap,$timeout,notifyLocalDestroy,defaults,doClick)-> diff --git a/src/coffee/directives/api/models/child/window-child-model.coffee b/src/coffee/directives/api/models/child/window-child-model.coffee index 7d8723323..5991669a1 100644 --- a/src/coffee/directives/api/models/child/window-child-model.coffee +++ b/src/coffee/directives/api/models/child/window-child-model.coffee @@ -1,4 +1,4 @@ -@module "directives.api.models.child", -> +@ngGmapModule "directives.api.models.child", -> class @WindowChildModel extends oo.BaseObject constructor:(scope,opts,isIconVisibleOnClick,mapCtrl, markerCtrl,$http,$templateCache,$compile,needToManualDestroy = false)-> @scope = scope diff --git a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee index bd6809c50..5585c805d 100644 --- a/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/i-marker-parent-model.coffee @@ -6,7 +6,7 @@ - icon - implementation needed on watches ### -@module "directives.api.models.parent", -> +@ngGmapModule "directives.api.models.parent", -> class @IMarkerParentModel extends oo.BaseObject # Animation is enabled by default DEFAULTS: { animation: google.maps.Animation.DROP } diff --git a/src/coffee/directives/api/models/parent/i-window-parent-model.coffee b/src/coffee/directives/api/models/parent/i-window-parent-model.coffee index 8ea86687c..4147c9788 100644 --- a/src/coffee/directives/api/models/parent/i-window-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/i-window-parent-model.coffee @@ -1,7 +1,7 @@ ### - interface directive for all window(s) to derrive from ### -@module "directives.api.models.parent", -> +@ngGmapModule "directives.api.models.parent", -> class @IWindowParentModel extends oo.BaseObject @include directives.api.utils.GmapUtil # Animation is enabled by default diff --git a/src/coffee/directives/api/models/parent/marker-parent-model.coffee b/src/coffee/directives/api/models/parent/marker-parent-model.coffee index dbb2190d9..2ee1f95d3 100644 --- a/src/coffee/directives/api/models/parent/marker-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/marker-parent-model.coffee @@ -2,7 +2,7 @@ Basic Directive api for a marker. Basic in the sense that this directive contains 1:1 on scope and model. Thus there will be one html element per marker within the directive. ### -@module "directives.api.models.parent", -> +@ngGmapModule "directives.api.models.parent", -> class @MarkerParentModel extends directives.api.models.parent.IMarkerParentModel @include directives.api.utils.GmapUtil constructor: (scope, element, attrs, mapCtrl,$timeout) -> diff --git a/src/coffee/directives/api/models/parent/markers-parent-model.coffee b/src/coffee/directives/api/models/parent/markers-parent-model.coffee index 76ed33ef5..f06cec6a4 100644 --- a/src/coffee/directives/api/models/parent/markers-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/markers-parent-model.coffee @@ -1,4 +1,4 @@ -@module "directives.api.models.parent", -> +@ngGmapModule "directives.api.models.parent", -> class @MarkersParentModel extends directives.api.models.parent.IMarkerParentModel constructor: (scope, element, attrs, mapCtrl,$timeout) -> super(scope, element, attrs, mapCtrl,$timeout) @@ -8,6 +8,7 @@ @markersIndex = 0 @scope = scope @$log.info(@) + @bigGulp = directives.api.utils.AsyncProcessor onTimeOut:(scope)=> @watch('models',scope) @@ -21,15 +22,15 @@ super(scope) or modelsNotDefined createMarkers:(scope) => - for model in scope.models - do(model) => - scope.doRebuild = true - @markers.push( - new directives.api.models.child.MarkerChildModel(@markersIndex,model,scope,@mapCtrl,@$timeout,(index) => - delete @markers[index] - ,@DEFAULTS,@doClick) - ) - @markersIndex++ + @bigGulp.handleLargeArray(scope.models,(model) => + scope.doRebuild = true + @markers.push( + new directives.api.models.child.MarkerChildModel(@markersIndex,model,scope,@mapCtrl,@$timeout,(index) => + delete @markers[index] + ,@DEFAULTS,@doClick) + ) + @markersIndex++ + ) #put MarkerModels into local scope scope.markerModels = @markers diff --git a/src/coffee/directives/api/models/parent/windows-parent-model.coffee b/src/coffee/directives/api/models/parent/windows-parent-model.coffee index 9ab6d2a94..fe77125b9 100644 --- a/src/coffee/directives/api/models/parent/windows-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/windows-parent-model.coffee @@ -1,7 +1,7 @@ ### Windows directive where many windows map to the models property ### -@module "directives.api.models.parent", -> +@ngGmapModule "directives.api.models.parent", -> class @WindowsParentModel extends directives.api.models.parent.IWindowParentModel constructor: (scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache,$interpolate) -> super(scope, element, attrs, ctrls, $timeout, $compile, $http, $templateCache,$interpolate) @@ -19,6 +19,7 @@ @contentKeys = undefined #model keys to parse html angular content @isIconVisibleOnClick = undefined @firstTime = true + @bigGulp = directives.api.utils.AsyncProcessor @$log.info(self) @$timeout( => @@ -40,9 +41,9 @@ watchModels:(scope) => scope.$watch('models', (newValue, oldValue) => if (newValue != oldValue and newValue.length != oldValue.length) - for model in @windows - do(model) => - model.destroy() + @bigGulp.handleLargeArray(@windows,(model) => + model.destroy() + ) # delete @windows @windows = [] @windowsIndex = 0 @@ -51,7 +52,9 @@ watchDestroy:(scope)=> scope.$on("$destroy", => - model.destroy() for model in @windows + @bigGulp.handleLargeArray(@windows,(model) => + model.destroy() + ) delete @windows @windows = [] @windowsIndex = 0 @@ -92,7 +95,9 @@ @watchModels(@linked.scope) @watchDestroy(@linked.scope) @setContentKeys(@linked.scope.models) #only setting content keys once per model array - @createWindow(model,undefined,gMap) for model in @linked.scope.models + @bigGulp.handleLargeArray(@linked.scope.models,(model) => + @createWindow(model,undefined,gMap) + ) else #creating windows with parent markers @models = markersScope.models @@ -100,9 +105,9 @@ @watchModels(markersScope) @watchDestroy(markersScope) @setContentKeys(markersScope.models) #only setting content keys once per model array - for mm in markersScope.markerModels - do(mm) => - @createWindow(mm.model,mm.gMarker,gMap) + @bigGulp.handleLargeArray(markersScope.markerModels,(mm) => + @createWindow(mm.model,mm.gMarker,gMap) + ) @firstTime = false setContentKeys:(models)=> diff --git a/src/coffee/directives/api/utils/async-processor.coffee b/src/coffee/directives/api/utils/async-processor.coffee new file mode 100644 index 000000000..6ba0df17f --- /dev/null +++ b/src/coffee/directives/api/utils/async-processor.coffee @@ -0,0 +1,25 @@ + +### + Author: Nicholas McCready & jfriend00 + AsyncProcessor 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 +### +@ngGmapModule "directives.api.utils", -> + @AsyncProcessor = + handleLargeArray:(array, callback, pausedCallBack ,chunk = 100, index = 0) -> + if array == undefined or array.length <= 0 + return + # set this to whatever number of items you can process at once + doChunk = () -> + cnt = chunk + i = index + + while cnt-- and i < array.length + # process array[index] here + callback(array[i]) + ++i + if i < array.length + index = i + pausedCallBack() if pausedCallBack? + setTimeout(doChunk(), 1) + doChunk() \ No newline at end of file diff --git a/src/coffee/directives/api/utils/gmap-util.coffee b/src/coffee/directives/api/utils/gmap-util.coffee index 7535fd121..57d3368ad 100644 --- a/src/coffee/directives/api/utils/gmap-util.coffee +++ b/src/coffee/directives/api/utils/gmap-util.coffee @@ -1,4 +1,4 @@ -@module "directives.api.utils", -> +@ngGmapModule "directives.api.utils", -> @GmapUtil = createMarkerOptions:(map,coords,icon,animate,defaults) -> opts = angular.extend({}, defaults, { diff --git a/src/coffee/directives/api/utils/linked.coffee b/src/coffee/directives/api/utils/linked.coffee index d840d3aab..d71579ca8 100644 --- a/src/coffee/directives/api/utils/linked.coffee +++ b/src/coffee/directives/api/utils/linked.coffee @@ -1,4 +1,4 @@ -@module "directives.api.utils", -> +@ngGmapModule "directives.api.utils", -> class @Linked extends oo.BaseObject constructor:(scope, element, attrs, ctrls)-> @scope = scope diff --git a/src/coffee/directives/api/utils/logger.coffee b/src/coffee/directives/api/utils/logger.coffee index 4452814eb..685773ca4 100644 --- a/src/coffee/directives/api/utils/logger.coffee +++ b/src/coffee/directives/api/utils/logger.coffee @@ -1,4 +1,4 @@ -@module "directives.api.utils", -> +@ngGmapModule "directives.api.utils", -> @Logger = logger: undefined doLog: false diff --git a/src/coffee/directives/api/window.coffee b/src/coffee/directives/api/window.coffee index e5b8ec684..2887084ad 100644 --- a/src/coffee/directives/api/window.coffee +++ b/src/coffee/directives/api/window.coffee @@ -2,7 +2,7 @@ Window directive for GoogleMap Info Windows, where ng-repeat is being used.... Where Html DOM element is 1:1 on Scope and a Model ### -@module "directives.api", -> +@ngGmapModule "directives.api", -> class @Window extends directives.api.IWindow @include directives.api.utils.GmapUtil constructor: ($timeout, $compile, $http, $templateCache) -> diff --git a/src/coffee/directives/api/windows.coffee b/src/coffee/directives/api/windows.coffee index 63668f96d..b09ba9c7c 100644 --- a/src/coffee/directives/api/windows.coffee +++ b/src/coffee/directives/api/windows.coffee @@ -1,7 +1,7 @@ ### Windows directive where many windows map to the models property ### -@module "directives.api", -> +@ngGmapModule "directives.api", -> class @Windows extends directives.api.IWindow constructor: ($timeout, $compile, $http, $templateCache,$interpolate) -> super($timeout, $compile, $http, $templateCache) diff --git a/src/coffee/oo/base-object.coffee b/src/coffee/oo/base-object.coffee index f414f7fcf..384ec359d 100644 --- a/src/coffee/oo/base-object.coffee +++ b/src/coffee/oo/base-object.coffee @@ -1,4 +1,4 @@ -@module "oo", -> +@ngGmapModule "oo", -> baseObjectKeywords = ['extended', 'included'] class @BaseObject diff --git a/src/coffee/oo/module.coffee b/src/coffee/oo/ng-gmap-module.coffee similarity index 55% rename from src/coffee/oo/module.coffee rename to src/coffee/oo/ng-gmap-module.coffee index a3ac1ce1c..49f6412e0 100644 --- a/src/coffee/oo/module.coffee +++ b/src/coffee/oo/ng-gmap-module.coffee @@ -1,8 +1,8 @@ -@module = (names, fn) -> +@ngGmapModule = (names, fn) -> names = names.split '.' if typeof names is 'string' space = @[names.shift()] ||= {} - space.module ||= @module + space.ngGmapModule ||= @ngGmapModule if names.length - space.module names, fn + space.ngGmapModule names, fn else fn.call space \ No newline at end of file From d703de425497d8efd40914784c8eb63dddd94ae2 Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Wed, 14 Aug 2013 17:22:49 -0400 Subject: [PATCH 40/41] This speeds things up a lot with no child scopes in markers --- dist/angular-google-maps.js | 90 ++++--------------- dist/angular-google-maps.min.js | 2 +- .../models/child/marker-child-model.coffee | 55 ++++++------ .../models/parent/markers-parent-model.coffee | 3 +- 4 files changed, 49 insertions(+), 101 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 3f66d3c8f..4ad460e07 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -212,9 +212,6 @@ angular.module('google-maps', []);;(function() { MarkerChildModel.include(directives.api.utils.GmapUtil); function MarkerChildModel(index, model, parentScope, gMap, $timeout, notifyLocalDestroy, defaults, doClick) { - this.watchDestroy = __bind(this.watchDestroy, this); - this.watchIcon = __bind(this.watchIcon, this); - this.watchCoords = __bind(this.watchCoords, this); this.setIcon = __bind(this.setIcon, this); this.setCoords = __bind(this.setCoords, this); this.destroy = __bind(this.destroy, this); @@ -222,18 +219,12 @@ angular.module('google-maps', []);;(function() { var _this = this; this.index = index; this.model = model; - this.parentScope = parentScope; this.iconKey = parentScope.icon; this.coordsKey = parentScope.coords; this.clickKey = parentScope.click(); this.animateKey = parentScope.animate; - this.myScope = parentScope.$new(false); + this.myScope = {}; this.setMyScope(model); - this.myScope.$watch('model', function(newValue, oldValue) { - if (newValue !== oldValue) { - return _this.setMyScope(newValue); - } - }, true); this.defaults = defaults; this.gMap = gMap; this.opts = this.createMarkerOptions(this.gMap, this.myScope.coords, this.myScope.icon, this.myScope.animate, this.defaults); @@ -266,7 +257,10 @@ angular.module('google-maps', []);;(function() { }; MarkerChildModel.prototype.destroy = function() { - return this.myScope.$destroy(); + this.gMarker.setMap(null); + if (typeof notifyLocalDestroy !== "undefined" && notifyLocalDestroy !== null) { + return notifyLocalDestroy(this.index); + } }; MarkerChildModel.prototype.setCoords = function(scope) { @@ -293,38 +287,6 @@ angular.module('google-maps', []);;(function() { return this.gMarker.setVisible(scope.coords.latitude && (scope.coords.longitude != null)); }; - MarkerChildModel.prototype.watchCoords = function(scope) { - var _this = this; - return scope.$watch('coords', function(newValue, oldValue) { - if (newValue !== oldValue) { - _this.parentScope.doRebuild = false; - _this.setCoords(scope); - return _this.parentScope.doRebuild = true; - } - }, true); - }; - - MarkerChildModel.prototype.watchIcon = function(scope) { - var _this = this; - return scope.$watch('icon', function(newValue, oldValue) { - if (newValue !== oldValue) { - _this.parentScope.doRebuild = false; - _this.setIcon(scope); - return _this.parentScope.doRebuild = true; - } - }, true); - }; - - MarkerChildModel.prototype.watchDestroy = function(scope) { - var _this = this; - return scope.$on("$destroy", function() { - _this.gMarker.setMap(null); - if (typeof notifyLocalDestroy !== "undefined" && notifyLocalDestroy !== null) { - return notifyLocalDestroy(_this.index); - } - }); - }; - return MarkerChildModel; })(oo.BaseObject); @@ -676,7 +638,6 @@ angular.module('google-maps', []);;(function() { this.markersIndex = 0; this.scope = scope; this.$log.info(this); - this.bigGulp = directives.api.utils.AsyncProcessor; } MarkersParentModel.prototype.onTimeOut = function(scope) { @@ -695,7 +656,7 @@ angular.module('google-maps', []);;(function() { MarkersParentModel.prototype.createMarkers = function(scope) { var _this = this; - this.bigGulp.handleLargeArray(scope.models, function(model) { + _.each(scope.models, function(model) { scope.doRebuild = true; _this.markers.push(new directives.api.models.child.MarkerChildModel(_this.markersIndex, model, scope, _this.mapCtrl, _this.$timeout, function(index) { return delete _this.markers[index]; @@ -793,6 +754,7 @@ angular.module('google-maps', []);;(function() { this.contentKeys = void 0; this.isIconVisibleOnClick = void 0; this.firstTime = true; + this.bigGulp = directives.api.utils.AsyncProcessor; this.$log.info(self); this.$timeout(function() { _this.watchOurScope(scope); @@ -822,16 +784,10 @@ angular.module('google-maps', []);;(function() { WindowsParentModel.prototype.watchModels = function(scope) { var _this = this; return scope.$watch('models', function(newValue, oldValue) { - var model, _fn, _i, _len, _ref; if (newValue !== oldValue && newValue.length !== oldValue.length) { - _ref = _this.windows; - _fn = function(model) { + _this.bigGulp.handleLargeArray(_this.windows, function(model) { return model.destroy(); - }; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - model = _ref[_i]; - _fn(model); - } + }); _this.windows = []; _this.windowsIndex = 0; return _this.createChildScopesWindows(); @@ -842,12 +798,9 @@ angular.module('google-maps', []);;(function() { WindowsParentModel.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { - var model, _i, _len, _ref; - _ref = _this.windows; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - model = _ref[_i]; - model.destroy(); - } + _this.bigGulp.handleLargeArray(_this.windows, function(model) { + return model.destroy(); + }); delete _this.windows; _this.windows = []; return _this.windowsIndex = 0; @@ -880,7 +833,7 @@ angular.module('google-maps', []);;(function() { This may force redundant information into the model, but this appears to be the most flexible approach. */ - var gMap, markersScope, mm, model, modelsNotDefined, _fn, _i, _j, _len, _len1, _ref, _ref1, + var gMap, markersScope, modelsNotDefined, _this = this; this.isIconVisibleOnClick = true; if (angular.isDefined(this.linked.attrs.isiconvisibleonclick)) { @@ -901,11 +854,9 @@ angular.module('google-maps', []);;(function() { this.watchDestroy(this.linked.scope); } this.setContentKeys(this.linked.scope.models); - _ref = this.linked.scope.models; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - model = _ref[_i]; - this.createWindow(model, void 0, gMap); - } + this.bigGulp.handleLargeArray(this.linked.scope.models, function(model) { + return _this.createWindow(model, void 0, gMap); + }); } else { this.models = markersScope.models; if (this.firstTime) { @@ -913,14 +864,9 @@ angular.module('google-maps', []);;(function() { this.watchDestroy(markersScope); } this.setContentKeys(markersScope.models); - _ref1 = markersScope.markerModels; - _fn = function(mm) { + this.bigGulp.handleLargeArray(markersScope.markerModels, function(mm) { return _this.createWindow(mm.model, mm.gMarker, gMap); - }; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - mm = _ref1[_j]; - _fn(mm); - } + }); } } return this.firstTime = false; diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index 90662d089..b6b8ffbe0 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.ngGmapModule=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.ngGmapModule||(c.ngGmapModule=this.ngGmapModule),a.length?c.ngGmapModule(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.ngGmapModule("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.AsyncProcessor={handleLargeArray:function(a,b,c,d,e){var f;return null==d&&(d=100),null==e&&(e=0),void 0===a||a.length<=0?void 0:(f=function(){var g,h;for(g=d,h=e;g--&&hd;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){var d,e,f,g,h;if(a!==c&&a.length!==c.length){for(h=b.windows,e=function(a){return a.destroy()},f=0,g=h.length;g>f;f++)d=h[f],e(d);return b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()}},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a,c,d,e;for(e=b.windows,c=0,d=e.length;d>c;c++)a=e[c],a.destroy();return delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,e=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,e&&(void 0===b||void 0===b.markerModels||void 0===b.models))return this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0;if(null!=a)if(null!=this.linked.scope.models)for(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),k=this.linked.scope.models,g=0,i=k.length;i>g;g++)d=k[g],this.createWindow(d,void 0,a);else for(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),l=b.markerModels,f=function(b){return m.createWindow(b.model,b.gMarker,a)},h=0,j=l.length;j>h;h++)c=l[h],f(c);return this.firstTime=!1},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events",bounds:"=bounds"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom,bounds:e.bounds})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),google.maps.event.addListener(k,"idle",function(){var a=k.getBounds(),c=a.getNorthEast(),d=a.getSouthWest();b(function(){e.$apply(function(a){null!==a.bounds&&void 0!==a.bounds&&void 0!==a.bounds&&(a.bounds.northeast={latitude:c.lat(),longitude:c.lng()},a.bounds.southwest={latitude:d.lat(),longitude:d.lng()})})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)}),e.$watch("bounds",function(a,b){if(a!==b){var c=new google.maps.LatLng(a.northeast.latitude,a.northeast.longitude),d=new google.maps.LatLng(a.southwest.latitude,a.southwest.longitude),e=new google.maps.LatLngBounds(d,c);k.fitBounds(e)}})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',replace:!0,scope:{show:"=show"},link:function(a,c,d,e){var f,g=new google.maps.TrafficLayer,h=!0;b(function(){f=e.getMap(),angular.isDefined(d.show)&&(h=a.show),null!==h&&h&&null!==f&&g.setMap(f),a.$watch("show",function(a,b){a!==b&&(h=a,a?g.setMap(f):g.setMap(null))},!0),a.$on("$destroy",function(){g.setMap(null)})})}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.ngGmapModule=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.ngGmapModule||(c.ngGmapModule=this.ngGmapModule),a.length?c.ngGmapModule(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.ngGmapModule("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.AsyncProcessor={handleLargeArray:function(a,b,c,d,e){var f;return null==d&&(d=100),null==e&&(e=0),void 0===a||a.length<=0?void 0:(f=function(){var g,h;for(g=d,h=e;g--&&hd;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.bigGulp=directives.api.utils.AsyncProcessor,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){return a!==c&&a.length!==c.length?(b.bigGulp.handleLargeArray(b.windows,function(a){return a.destroy()}),b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.bigGulp.handleLargeArray(b.windows,function(a){return a.destroy()}),delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d=this;return this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,c=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,!c||void 0!==b&&void 0!==b.markerModels&&void 0!==b.models?(null!=a&&(null!=this.linked.scope.models?(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),this.bigGulp.handleLargeArray(this.linked.scope.models,function(b){return d.createWindow(b,void 0,a)})):(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),this.bigGulp.handleLargeArray(b.markerModels,function(b){return d.createWindow(b.model,b.gMarker,a)}))),this.firstTime=!1):(this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0)},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events",bounds:"=bounds"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom,bounds:e.bounds})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),google.maps.event.addListener(k,"idle",function(){var a=k.getBounds(),c=a.getNorthEast(),d=a.getSouthWest();b(function(){e.$apply(function(a){null!==a.bounds&&void 0!==a.bounds&&void 0!==a.bounds&&(a.bounds.northeast={latitude:c.lat(),longitude:c.lng()},a.bounds.southwest={latitude:d.lat(),longitude:d.lng()})})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)}),e.$watch("bounds",function(a,b){if(a!==b){var c=new google.maps.LatLng(a.northeast.latitude,a.northeast.longitude),d=new google.maps.LatLng(a.southwest.latitude,a.southwest.longitude),e=new google.maps.LatLngBounds(d,c);k.fitBounds(e)}})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',replace:!0,scope:{show:"=show"},link:function(a,c,d,e){var f,g=new google.maps.TrafficLayer,h=!0;b(function(){f=e.getMap(),angular.isDefined(d.show)&&(h=a.show),null!==h&&h&&null!==f&&g.setMap(f),a.$watch("show",function(a,b){a!==b&&(h=a,a?g.setMap(f):g.setMap(null))},!0),a.$on("$destroy",function(){g.setMap(null)})})}}}]); \ No newline at end of file diff --git a/src/coffee/directives/api/models/child/marker-child-model.coffee b/src/coffee/directives/api/models/child/marker-child-model.coffee index 12d9dfb3f..838e0af77 100644 --- a/src/coffee/directives/api/models/child/marker-child-model.coffee +++ b/src/coffee/directives/api/models/child/marker-child-model.coffee @@ -4,17 +4,18 @@ constructor:(index,model,parentScope,gMap,$timeout,notifyLocalDestroy,defaults,doClick)-> @index = index @model = model - @parentScope = parentScope + # @parentScope = parentScope @iconKey = parentScope.icon @coordsKey = parentScope.coords @clickKey = parentScope.click() @animateKey = parentScope.animate - @myScope = parentScope.$new(false) + # @myScope = parentScope.$new(false) + @myScope = {} @setMyScope(model) - @myScope.$watch('model',(newValue, oldValue) => - if (newValue != oldValue) - @setMyScope(newValue) - ,true) + # @myScope.$watch('model',(newValue, oldValue) => + # if (newValue != oldValue) + # @setMyScope(newValue) + # ,true) @defaults = defaults @gMap = gMap @opts = @createMarkerOptions(@gMap,@myScope.coords,@myScope.icon,@myScope.animate,@defaults) @@ -44,7 +45,9 @@ @myScope.model = model destroy:() => - @myScope.$destroy() + @gMarker.setMap(null) + notifyLocalDestroy(@index) if notifyLocalDestroy? + #@myScope.$destroy() setCoords:(scope) => if(scope.$id != @myScope.$id) @@ -67,24 +70,24 @@ @gMarker.setVisible(scope.coords.latitude and scope.coords.longitude?) - watchCoords:(scope) => - scope.$watch('coords', (newValue, oldValue) => - if (newValue != oldValue) - @parentScope.doRebuild = false - @setCoords(scope) - @parentScope.doRebuild = true - , true) + # watchCoords:(scope) => + # scope.$watch('coords', (newValue, oldValue) => + # if (newValue != oldValue) + # @parentScope.doRebuild = false + # @setCoords(scope) + # @parentScope.doRebuild = true + # , true) - watchIcon:(scope) => - scope.$watch('icon', (newValue, oldValue) => - if (newValue != oldValue) - @parentScope.doRebuild = false - @setIcon(scope) - @parentScope.doRebuild = true - , true) + # watchIcon:(scope) => + # scope.$watch('icon', (newValue, oldValue) => + # if (newValue != oldValue) + # @parentScope.doRebuild = false + # @setIcon(scope) + # @parentScope.doRebuild = true + # , true) - watchDestroy:(scope)=> - scope.$on("$destroy", => - @gMarker.setMap(null) - notifyLocalDestroy(@index) if notifyLocalDestroy? - ) \ No newline at end of file + # watchDestroy:(scope)=> + # scope.$on("$destroy", => + # @gMarker.setMap(null) + # notifyLocalDestroy(@index) if notifyLocalDestroy? + # ) \ No newline at end of file diff --git a/src/coffee/directives/api/models/parent/markers-parent-model.coffee b/src/coffee/directives/api/models/parent/markers-parent-model.coffee index f06cec6a4..54d1af81e 100644 --- a/src/coffee/directives/api/models/parent/markers-parent-model.coffee +++ b/src/coffee/directives/api/models/parent/markers-parent-model.coffee @@ -8,7 +8,6 @@ @markersIndex = 0 @scope = scope @$log.info(@) - @bigGulp = directives.api.utils.AsyncProcessor onTimeOut:(scope)=> @watch('models',scope) @@ -22,7 +21,7 @@ super(scope) or modelsNotDefined createMarkers:(scope) => - @bigGulp.handleLargeArray(scope.models,(model) => + _.each(scope.models,(model) => scope.doRebuild = true @markers.push( new directives.api.models.child.MarkerChildModel(@markersIndex,model,scope,@mapCtrl,@$timeout,(index) => From d0fafb8ecd6ae5652c7bad1ab2250bc590653d7c Mon Sep 17 00:00:00 2001 From: Nick McCready Date: Thu, 15 Aug 2013 09:44:31 -0400 Subject: [PATCH 41/41] merge of feature/speed --- dist/angular-google-maps.js | 9 +++++---- dist/angular-google-maps.min.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dist/angular-google-maps.js b/dist/angular-google-maps.js index 3346cfedc..495c18e12 100644 --- a/dist/angular-google-maps.js +++ b/dist/angular-google-maps.js @@ -789,6 +789,7 @@ angular.module('google-maps', []);;(function() { this.contentKeys = void 0; this.isIconVisibleOnClick = void 0; this.firstTime = true; + this.bigGulp = directives.api.utils.AsyncProcessor; this.$log.info(self); this.$timeout(function() { _this.watchOurScope(scope); @@ -819,7 +820,7 @@ angular.module('google-maps', []);;(function() { var _this = this; return scope.$watch('models', function(newValue, oldValue) { if (newValue !== oldValue && newValue.length !== oldValue.length) { - _.each(_this.windows, function(model) { + _this.bigGulp.handleLargeArray(_this.windows, function(model) { return model.destroy(); }); _this.windows = []; @@ -832,7 +833,7 @@ angular.module('google-maps', []);;(function() { WindowsParentModel.prototype.watchDestroy = function(scope) { var _this = this; return scope.$on("$destroy", function() { - _.each(_this.windows, function(model) { + _this.bigGulp.handleLargeArray(_this.windows, function(model) { return model.destroy(); }); delete _this.windows; @@ -888,7 +889,7 @@ angular.module('google-maps', []);;(function() { this.watchDestroy(this.linked.scope); } this.setContentKeys(this.linked.scope.models); - _.each(this.linked.scope.models, function(model) { + this.bigGulp.handleLargeArray(this.linked.scope.models, function(model) { return _this.createWindow(model, void 0, gMap); }); } else { @@ -898,7 +899,7 @@ angular.module('google-maps', []);;(function() { this.watchDestroy(markersScope); } this.setContentKeys(markersScope.models); - _.each(markersScope.markerModels, function(mm) { + this.bigGulp.handleLargeArray(markersScope.markerModels, function(mm) { return _this.createWindow(mm.model, mm.gMarker, gMap); }); } diff --git a/dist/angular-google-maps.min.js b/dist/angular-google-maps.min.js index ef9b04051..70dfb760d 100644 --- a/dist/angular-google-maps.min.js +++ b/dist/angular-google-maps.min.js @@ -2,4 +2,4 @@ * AngularJS directives for Google Maps * git: https://github.com/nlaplante/angular-google-maps.git */ -angular.module("google-maps",[]),function(){this.ngGmapModule=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.ngGmapModule||(c.ngGmapModule=this.ngGmapModule),a.length?c.ngGmapModule(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.ngGmapModule("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.AsyncProcessor={handleLargeArray:function(a,b,c,d,e){var f;return null==d&&(d=100),null==e&&(e=0),void 0===a||a.length<=0?void 0:(f=function(){var g,h;for(g=d,h=e;g--&&hd;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){return a!==c&&a.length!==c.length?(_.each(b.windows,function(a){return a.destroy()}),b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return _.each(b.windows,function(a){return a.destroy()}),delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d=this;return this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,c=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,!c||void 0!==b&&void 0!==b.markerModels&&void 0!==b.models?(null!=a&&(null!=this.linked.scope.models?(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),_.each(this.linked.scope.models,function(b){return d.createWindow(b,void 0,a)})):(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),_.each(b.markerModels,function(b){return d.createWindow(b.model,b.gMarker,a)}))),this.firstTime=!1):(this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0)},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events",bounds:"=bounds"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom,bounds:e.bounds})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),google.maps.event.addListener(k,"idle",function(){var a=k.getBounds(),c=a.getNorthEast(),d=a.getSouthWest();b(function(){e.$apply(function(a){null!==a.bounds&&void 0!==a.bounds&&void 0!==a.bounds&&(a.bounds.northeast={latitude:c.lat(),longitude:c.lng()},a.bounds.southwest={latitude:d.lat(),longitude:d.lng()})})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)}),e.$watch("bounds",function(a,b){if(a!==b){var c=new google.maps.LatLng(a.northeast.latitude,a.northeast.longitude),d=new google.maps.LatLng(a.southwest.latitude,a.southwest.longitude),e=new google.maps.LatLngBounds(d,c);k.fitBounds(e)}})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',replace:!0,scope:{show:"=show"},link:function(a,c,d,e){var f,g=new google.maps.TrafficLayer,h=!0;b(function(){f=e.getMap(),angular.isDefined(d.show)&&(h=a.show),null!==h&&h&&null!==f&&g.setMap(f),a.$watch("show",function(a,b){a!==b&&(h=a,a?g.setMap(f):g.setMap(null))},!0),a.$on("$destroy",function(){g.setMap(null)})})}}}]); \ No newline at end of file +angular.module("google-maps",[]),function(){this.ngGmapModule=function(a,b){var c,d;return"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.ngGmapModule||(c.ngGmapModule=this.ngGmapModule),a.length?c.ngGmapModule(a,b):b.call(c)}}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.ngGmapModule("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.AsyncProcessor={handleLargeArray:function(a,b,c,d,e){var f;return null==d&&(d=100),null==e&&(e=0),void 0===a||a.length<=0?void 0:(f=function(){var g,h;for(g=d,h=e;g--&&hd;d++)b=f[d],c(b);return delete this.markers,this.markers=[],this.markersIndex=0,this.createMarkers(a)}},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||c.length!==d.length?this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(){var a,b,c,d,e;for(d=this.markers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(a.destroy());return e},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.watchOurScope=a(this.watchOurScope,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.clsName="WindowsParentModel",this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.bigGulp=directives.api.utils.AsyncProcessor,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){var f,g,h,i,j;if(a!==e){for(d[c]="function"==typeof a?a():a,i=d.windows,j=[],g=0,h=i.length;h>g;g++)f=i[g],j.push(function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]}(f));return j}},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){return a!==c&&a.length!==c.length?(b.bigGulp.handleLargeArray(b.windows,function(a){return a.destroy()}),b.windows=[],b.windowsIndex=0,b.createChildScopesWindows()):void 0},!0)},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.bigGulp.handleLargeArray(b.windows,function(a){return a.destroy()}),delete b.windows,b.windows=[],b.windowsIndex=0})},d.prototype.watchOurScope=function(a){var b,c,d,e,f,g=this;for(e=this.scopePropNames,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(function(b){var c;return c=b+"Key",g[c]="function"==typeof a[b]?a[b]():a[b],g.watch(a,b,c)}(b));return f},d.prototype.createChildScopesWindows=function(){var a,b,c,d=this;return this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),a=this.linked.ctrls[0].getMap(),b=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,c=angular.isUndefined(this.linked.scope.models)||void 0===scope.models,!c||void 0!==b&&void 0!==b.markerModels&&void 0!==b.models?(null!=a&&(null!=this.linked.scope.models?(this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),this.bigGulp.handleLargeArray(this.linked.scope.models,function(b){return d.createWindow(b,void 0,a)})):(this.models=b.models,this.firstTime&&(this.watchModels(b),this.watchDestroy(b)),this.setContentKeys(b.models),this.bigGulp.handleLargeArray(b.markerModels,function(b){return d.createWindow(b.model,b.gMarker,a)}))),this.firstTime=!1):(this.$log.info("No models to create windows from! Need direct models or models derrived from markers!"),void 0)},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.clsName="IMarker",this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click"}}return c(d,b),d.prototype.controller=function(){throw new Exception("Not Implemented!!")},d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){this.link=a(this.link,this);var f;f=this,this.clsName="IWindow",this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick"},this.$log=directives.api.utils.Logger,this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Marker",this.$log.info(this)}return c(d,b),d.prototype.controller=function(a,b){return this.getMarker=function(){return b.data("instance")}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Markers=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='',this.clsName="Markers",this.scope.models="=models",this.$timeout=b,this.$log.info(this)}return c(d,b),d.prototype.controller=function(a){return this.getMarkersScope=function(){return a}},d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.clsName="Window",this.require=["^googleMap","^?marker"],this.template='',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j;return f=!0,angular.isDefined(c.isiconvisibleonclick)&&(f=a.isIconVisibleOnClick),g=d[0].getMap(),h=d.length>1&&null!=d[1]?d[1].getMarker():void 0,i=e.createWindowOptions(h,a,b.html(),e.DEFAULTS),null!=g&&(j=new directives.api.models.child.WindowChildModel(a,i,f,g,h,e.$http,e.$templateCache,e.$compile)),a.$on("$destroy",function(){return j.destroy()})},50)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.clsName="Windows",this.require=["^googleMap","^?markers"],this.template='',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a,b){"use strict";function c(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a}directives.api.utils.Logger.logger=a;var d={mapTypeId:google.maps.MapTypeId.ROADMAP};return{restrict:"ECMA",transclude:!0,replace:!1,template:'
',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",markers:"=markers",refresh:"&refresh",windows:"=windows",events:"=events",bounds:"=bounds"},controller:["$scope",function(a){this.getMap=function(){return a.map}}],link:function(e,f,g){if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return a.error("angular-google-maps: could not find a valid center property"),void 0;if(!angular.isDefined(e.zoom))return a.error("angular-google-maps: map zoom property not set"),void 0;var h=angular.element(f);h.addClass("angular-google-map");var i={options:{}};if(g.options&&(i.options=angular.fromJson(g.options)),g.type){var j=g.type.toUpperCase();google.maps.MapTypeId.hasOwnProperty(j)?i.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')}var k=new google.maps.Map(h.find("div")[1],angular.extend({},d,i,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:c(g.draggable),zoom:e.zoom,bounds:e.bounds})),l=!1;google.maps.event.addListener(k,"dragstart",function(){l=!0,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"dragend",function(){l=!1,b(function(){e.$apply(function(a){a.dragging=l})})}),google.maps.event.addListener(k,"drag",function(){var a=k.center;b(function(){e.$apply(function(b){b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(k,"zoom_changed",function(){e.zoom!=k.zoom&&b(function(){e.$apply(function(a){a.zoom=k.zoom})})});var m=!1;if(google.maps.event.addListener(k,"center_changed",function(){var a=k.center;m||b(function(){e.$apply(function(b){k.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude!==a.lng()&&(b.center.longitude=a.lng()))})})}),google.maps.event.addListener(k,"idle",function(){var a=k.getBounds(),c=a.getNorthEast(),d=a.getSouthWest();b(function(){e.$apply(function(a){null!==a.bounds&&void 0!==a.bounds&&void 0!==a.bounds&&(a.bounds.northeast={latitude:c.lat(),longitude:c.lng()},a.bounds.southwest={latitude:d.lat(),longitude:d.lng()})})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){var n=function(a){return function(){e.events[a].apply(e,[k,a,arguments])}};for(var o in e.events)e.events.hasOwnProperty(o)&&angular.isFunction(e.events[o])&&google.maps.event.addListener(k,o,n(o))}e.map=k,google.maps.event.trigger(k,"resize"),angular.isUndefined(e.refresh())||e.$watch("refresh()",function(a,b){if(a&&!b){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}}),e.$watch("center",function(a,b){if(a!==b){if(m=!0,!l){var d=new google.maps.LatLng(a.latitude,a.longitude);c(g.pan)?k.panTo(d):k.setCenter(d)}m=!1}},!0),e.$watch("zoom",function(a,b){a!==b&&k.setZoom(a)}),e.$watch("bounds",function(a,b){if(a!==b){var c=new google.maps.LatLng(a.northeast.latitude,a.northeast.longitude),d=new google.maps.LatLng(a.southwest.latitude,a.southwest.longitude),e=new google.maps.LatLngBounds(d,c);k.fitBounds(e)}})}}}]),angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}]),angular.module("google-maps").directive("markers",["$timeout",function(a){return new directives.api.Markers(a)}]),angular.module("google-maps").directive("polyline",["$log","$timeout",function(a,b){"use strict";function c(a){for(var b=0;b',replace:!0,scope:{show:"=show"},link:function(a,c,d,e){var f,g=new google.maps.TrafficLayer,h=!0;b(function(){f=e.getMap(),angular.isDefined(d.show)&&(h=a.show),null!==h&&h&&null!==f&&g.setMap(f),a.$watch("show",function(a,b){a!==b&&(h=a,a?g.setMap(f):g.setMap(null))},!0),a.$on("$destroy",function(){g.setMap(null)})})}}}]); \ No newline at end of file