ffffng/app/bower_components/angular-leaflet-directive/dist/angular-leaflet-directive.min.js

32 lines
47 KiB
JavaScript
Raw Normal View History

/**!
* The MIT License
*
* Copyright (c) 2013 the angular-leaflet-directive Team, http://tombatossals.github.io/angular-leaflet-directive
*
* 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-leaflet-directive
* https://github.com/tombatossals/angular-leaflet-directive
*
* @authors https://github.com/tombatossals/angular-leaflet-directive/graphs/contributors
*/
/*! angular-leaflet-directive 06-05-2014 */
!function(){"use strict";angular.module("leaflet-directive",[]).directive("leaflet",["$q","leafletData","leafletMapDefaults","leafletHelpers","leafletEvents",function(a,b,c,d,e){var f;return{restrict:"EA",replace:!0,scope:{center:"=center",defaults:"=defaults",maxbounds:"=maxbounds",bounds:"=bounds",markers:"=markers",legend:"=legend",geojson:"=geojson",paths:"=paths",tiles:"=tiles",layers:"=layers",controls:"=controls",eventBroadcast:"=eventBroadcast"},template:'<div class="angular-leaflet-map"></div>',controller:["$scope",function(b){f=a.defer(),this.getMap=function(){return f.promise},this.getLeafletScope=function(){return b}}],link:function(a,g,h){var i=d.isDefined,j=c.setDefaults(a.defaults,h.id),k=e.genDispatchMapEvent,l=e.getAvailableMapEvents();i(h.width)&&(isNaN(h.width)?g.css("width",h.width):g.css("width",h.width+"px")),i(h.height)&&(isNaN(h.height)?g.css("height",h.height):g.css("height",h.height+"px"));var m=new L.Map(g[0],c.getMapCreationDefaults(h.id));if(f.resolve(m),i(h.center)||m.setView([j.center.lat,j.center.lng],j.center.zoom),!i(h.tiles)&&!i(h.layers)){var n=L.tileLayer(j.tileLayer,j.tileLayerOptions);n.addTo(m),b.setTiles(n,h.id)}if(i(m.zoomControl)&&i(j.zoomControlPosition)&&m.zoomControl.setPosition(j.zoomControlPosition),i(m.zoomControl)&&j.zoomControl===!1&&m.zoomControl.removeFrom(m),i(m.zoomsliderControl)&&i(j.zoomsliderControl)&&j.zoomsliderControl===!1&&m.zoomsliderControl.removeFrom(m),!i(h.eventBroadcast))for(var o="broadcast",p=0;p<l.length;p++){var q=l[p];m.on(q,k(a,q,o),{eventName:q})}m.whenReady(function(){b.setMap(m,h.id)}),a.$on("$destroy",function(){b.unresolveMap(h.id)})}}}]),angular.module("leaflet-directive").directive("center",["$log","$q","$location","leafletMapDefaults","leafletHelpers","leafletBoundsHelpers","leafletEvents",function(a,b,c,d,e,f,g){var h,i=e.isDefined,j=e.isNumber,k=e.isSameCenterOnMap,l=e.safeApply,m=e.isValidCenter,n=e.isEmpty,o=e.isUndefinedOrEmpty,p=function(a,b){return i(a)&&!n(a)&&o(b)};return{restrict:"A",scope:!1,replace:!1,require:"leaflet",controller:function(){h=b.defer(),this.getCenter=function(){return h.promise}},link:function(b,e,n,o){var q=o.getLeafletScope(),r=q.center;o.getMap().then(function(b){var e=d.getDefaults(n.id);if(-1!==n.center.search("-"))return a.error('The "center" variable can\'t use a "-" on his key name: "'+n.center+'".'),void b.setView([e.center.lat,e.center.lng],e.center.zoom);if(p(q.bounds,r))b.fitBounds(f.createLeafletBounds(q.bounds)),r=b.getCenter(),l(q,function(a){a.center={lat:b.getCenter().lat,lng:b.getCenter().lng,zoom:b.getZoom(),autoDiscover:!1}}),l(q,function(a){var c=b.getBounds(),d={northEast:{lat:c._northEast.lat,lng:c._northEast.lng},southWest:{lat:c._southWest.lat,lng:c._southWest.lng}};a.bounds=d});else{if(!i(r))return a.error('The "center" property is not defined in the main scope'),void b.setView([e.center.lat,e.center.lng],e.center.zoom);i(r.lat)&&i(r.lng)||i(r.autoDiscover)||angular.copy(e.center,r)}var o,s;if("yes"===n.urlHashCenter){var t=function(){var a,b=c.search();if(i(b.c)){var d=b.c.split(":");3===d.length&&(a={lat:parseFloat(d[0]),lng:parseFloat(d[1]),zoom:parseInt(d[2],10)})}return a};o=t(),q.$on("$locationChangeSuccess",function(a){var c=a.currentScope,d=t();i(d)&&!k(d,b)&&(c.center={lat:d.lat,lng:d.lng,zoom:d.zoom})})}q.$watch("center",function(c){return i(o)&&(angular.copy(o,c),o=void 0),m(c)||c.autoDiscover===!0?c.autoDiscover===!0?(j(c.zoom)||b.setView([e.center.lat,e.center.lng],e.center.zoom),void b.locate(j(c.zoom)&&c.zoom>e.center.zoom?{setView:!0,maxZoom:c.zoom}:i(e.maxZoom)?{setView:!0,maxZoom:e.maxZoom}:{setView:!0})):void(s&&k(c,b)||(b.setView([c.lat,c.lng],c.zoom),g.notifyCenterChangedToBounds(q,b))):void a.warn("[AngularJS - Leaflet] invalid 'center'")},!0),b.whenReady(function(){s=!0}),b.on("moveend",function(){h.resolve(),g.notifyCenterUrlHashChanged(q,b,n,c.search()),k(r,b)||l(q,function(a){a.center={lat:b.getCenter().lat,lng:b.getCenter().lng,zoom:b.getZoom(),autoDiscover:!1},g.notifyCenterChangedToBounds(q,b)})}),r.autoDiscover===!0&&b.on("locationerror",function(){a.warn(
h(a[f])?d[f]=a[f]:h(b.path[f])&&(d[f]=b.path[f])}return d}var h=c.isDefined,i=c.isArray,j=c.isNumber,k=c.isValidPoint,l=function(a,b){h(b.weight)&&a.setStyle({weight:b.weight}),h(b.color)&&a.setStyle({color:b.color}),h(b.opacity)&&a.setStyle({opacity:b.opacity})},m=function(a){if(!i(a))return!1;for(var b in a){var c=a[b];if(!k(c))return!1}return!0},n={polyline:{isValid:function(a){var b=a.latlngs;return m(b)},createPath:function(a){return new L.Polyline([],a)},setPath:function(a,b){a.setLatLngs(d(b.latlngs)),l(a,b)}},multiPolyline:{isValid:function(a){var b=a.latlngs;if(!i(b))return!1;for(var c in b){var d=b[c];if(!m(d))return!1}return!0},createPath:function(a){return new L.multiPolyline([[[0,0],[1,1]]],a)},setPath:function(a,b){a.setLatLngs(f(b.latlngs)),l(a,b)}},polygon:{isValid:function(a){var b=a.latlngs;return m(b)},createPath:function(a){return new L.Polygon([],a)},setPath:function(a,b){a.setLatLngs(d(b.latlngs)),l(a,b)}},multiPolygon:{isValid:function(a){var b=a.latlngs;if(!i(b))return!1;for(var c in b){var d=b[c];if(!m(d))return!1}return!0},createPath:function(a){return new L.MultiPolygon([[[0,0],[1,1],[0,1]]],a)},setPath:function(a,b){a.setLatLngs(f(b.latlngs)),l(a,b)}},rectangle:{isValid:function(a){var b=a.latlngs;if(!i(b)||2!==b.length)return!1;for(var c in b){var d=b[c];if(!k(d))return!1}return!0},createPath:function(a){return new L.Rectangle([[0,0],[1,1]],a)},setPath:function(a,b){a.setBounds(new L.LatLngBounds(d(b.latlngs))),l(a,b)}},circle:{isValid:function(a){var b=a.latlngs;return k(b)&&j(a.radius)},createPath:function(a){return new L.Circle([0,0],1,a)},setPath:function(a,b){a.setLatLng(e(b.latlngs)),h(b.radius)&&a.setRadius(b.radius),l(a,b)}},circleMarker:{isValid:function(a){var b=a.latlngs;return k(b)&&j(a.radius)},createPath:function(a){return new L.CircleMarker([0,0],a)},setPath:function(a,b){a.setLatLng(e(b.latlngs)),h(b.radius)&&a.setRadius(b.radius),l(a,b)}}},o=function(a){var b={};return a.latlngs&&(b.latlngs=a.latlngs),a.radius&&(b.radius=a.radius),b};return{setPathOptions:function(a,b,c){h(b)||(b="polyline"),n[b].setPath(a,c)},createPath:function(a,c,d){h(c.type)||(c.type="polyline");var e=g(c,d),f=o(c);return n[c.type].isValid(f)?n[c.type].createPath(e):void b.error("[AngularJS - Leaflet] Invalid data passed to the "+c.type+" path")}}}]),angular.module("leaflet-directive").factory("leafletBoundsHelpers",["$log","leafletHelpers",function(a,b){function c(a){return angular.isDefined(a)&&angular.isDefined(a.southWest)&&angular.isDefined(a.northEast)&&angular.isNumber(a.southWest.lat)&&angular.isNumber(a.southWest.lng)&&angular.isNumber(a.northEast.lat)&&angular.isNumber(a.northEast.lng)}var d=b.isArray,e=b.isNumber;return{createLeafletBounds:function(a){return c(a)?L.latLngBounds([a.southWest.lat,a.southWest.lng],[a.northEast.lat,a.northEast.lng]):void 0},isValidBounds:c,createBoundsFromArray:function(b){return d(b)&&2===b.length&&d(b[0])&&d(b[1])&&2===b[0].length&&2===b[1].length&&e(b[0][0])&&e(b[0][1])&&e(b[1][0])&&e(b[1][1])?{northEast:{lat:b[0][0],lng:b[0][1]},southWest:{lat:b[1][0],lng:b[1][1]}}:void a.error("[AngularJS - Leaflet] The bounds array is not valid.")}}}]),angular.module("leaflet-directive").factory("leafletMarkersHelpers",["$rootScope","leafletHelpers","$log",function(a,b,c){var d=b.isDefined,e=b.MarkerClusterPlugin,f=b.AwesomeMarkersPlugin,g=b.safeApply,h=b,i=b.isString,j=b.isNumber,k=b.isObject,l={},m=function(a){if(d(a)&&d(a.type)&&"awesomeMarker"===a.type)return f.isLoaded()||c.error("[AngularJS - Leaflet] The AwesomeMarkers Plugin is not loaded."),new L.AwesomeMarkers.icon(a);if(d(a)&&d(a.type)&&"div"===a.type)return new L.divIcon(a);var b="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAGmklEQVRYw7VXeUyTZxjvNnfELFuyIzOabermMZEeQC/OclkO49CpOHXOLJl/CAURuYbQi3KLgEhbrhZ1aDwmaoGqKII6odATmH/scDFbdC7LvFqOCc+e95s2VG50X/LLm/f4/Z7neY/ne18aANCmAr5E/xZf1uDOkTcGcWR6hl9247tT5U7Y6SNvWsKT63P58qbfeLJG8M5qcgTknrvvrdDbsT7Ml+tv82X6vVxJE33aRmgSyYtcWVMqX97Yv2JvW39UhRE2HuyBL+t+gK1116ly06EeWFNlAmHxlQE0OMiV6mQCScusKRlhS3QLeVJdl1+23h5dY4FNB3thrbYboqptEFlphTC1hSpJnbRvxP4NWgsE5