Widget:Karte/JS
/**
* Awesome wiki maps by Smiley * * based on Cliff's example * http://jsfiddle.net/cliff/CRRGC/ * * and Dr. Ishmaels proof of concept * http://wiki.guildwars2.com/wiki/User:Dr_ishmael/leaflet * * included in this file: * * (minified) excerpts from phpJS * http://phpjs.org * * Leaflet polyline decorator * https://github.com/bbecquet/Leaflet.PolylineDecorator *(c) 2013 Benjamin Becquet * */
var GW2Maps={init:function(c){if("object"!==typeof c)return!1;var b=GW2Maps.options(c),a={map:L.map(c,{maxZoom:b.max_zoom,crs:L.CRS.Simple,zoomControl:b.map_controls,attributionControl:!1}),layers:{},linkbox:$('
a.layers[b.i18n.event]=L.layerGroup();a.layers[b.i18n.landmark]=L.layerGroup();a.layers[b.i18n.markers]=L.layerGroup();a.layers[b.i18n.polylines]=L.layerGroup();a.layers[b.i18n.skill]=L.layerGroup();a.layers[b.i18n.task]=L.layerGroup();a.layers[b.i18n.vista]=L.layerGroup();a.layers[b.i18n.waypoint]=L.layerGroup();a.layers[b.i18n.sector]=L.layerGroup();2<a.map.getZoom()&&a.layers[b.i18n.marker].addTo(a.map);3<a.map.getZoom()&&(a.layers[b.i18n.landmark].addTo(a.map),a.layers[b.i18n.skill].addTo(a.map),
a.layers[b.i18n.vista].addTo(a.map),a.layers[b.i18n.waypoint].addTo(a.map));4<a.map.getZoom()&&(a.layers[b.i18n.polylines].addTo(a.map),a.layers[b.i18n.task].addTo(a.map));if(b.region_id&&b.map_id||5<a.map.getZoom())a.layers[b.i18n.sector].addTo(a.map),a.layers[b.i18n.event].addTo(a.map);b.map_controls&&L.control.layers(null,a.layers).addTo(a.map);b.polyline&&7<b.polyline.length&&GW2Maps.parse_polylines(a,b);b.markers&&2<b.markers.length&&GW2Maps.parse_markers(a,b);a.map.on("zoomend",function(){var c=
a.map.getZoom();5<c?a.layers[b.i18n.event].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.event]);5<c?a.layers[b.i18n.sector].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.sector]);4<c?a.layers[b.i18n.polylines].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.polylines]);4<c?a.layers[b.i18n.task].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.task]);3<c?a.layers[b.i18n.landmark].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.landmark]);3<c?a.layers[b.i18n.skill].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.skill]);
3<c?a.layers[b.i18n.vista].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.vista]);3<c?a.layers[b.i18n.waypoint].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.waypoint]);2<c?a.layers[b.i18n.markers].addTo(a.map):a.map.removeLayer(a.layers[b.i18n.markers])});a.map.on("click",function(c){console.log(a.map.project(c.latlng,b.max_zoom).toString())});$.ajax({url:"https://api.guildwars2.com/v1/map_floor.json?continent_id="+b.continent_id+"&floor="+b.floor_id+"&lang="+b.i18n.lang,dataType:"json",success:function(c){b.event_data?
$.ajax({url:"https://api.guildwars2.com/v1/event_details.json?lang="+b.i18n.lang,dataType:"json",success:function(d){var e={};$.each(d.events,function(b,a){"undefined"===typeof e[a.map_id]&&(e[a.map_id]={});e[a.map_id][b]=a});GW2Maps.parse_response(a,b,c,e)}}):GW2Maps.parse_response(a,b,c,!1)}}).fail(function(){b.region_id=!1;GW2Maps.parse_response(a,b,{texture_dims:1===b.continent_id?[32768,32768]:[16384,16384],regions:[]},{})});return a},parse_response:function(c,b,a,d){var e,f=function(a){return c.map.unproject(a,
b.max_zoom)};a.clamped_view?(e=a.clamped_view,e=(new L.LatLngBounds(f([e[0][0],e[1][1]]),f([e[1][0],e[0][1]]))).pad(0.2)):b.region_id&&b.map_id?(e=a.regions[b.region_id].maps[b.map_id].continent_rect,e=(new L.LatLngBounds(f([e[0][0],e[1][1]]),f([e[1][0],e[0][1]]))).pad(0.4)):e=(new L.LatLngBounds(f([0,a.texture_dims[1]]),f([a.texture_dims[0],0]))).pad(0.1);c.map.setMaxBounds(e).fitBounds(e);b.region_id&&b.map_id?(e="undefined"!==typeof d[b.map_id]?d[b.map_id]:!1,GW2Maps.parse_map(c,b,a.regions[b.region_id].maps[b.map_id],
e)):$.each(a.regions,function(){$.each(this.maps,function(a){GW2Maps.parse_map(c,b,this,"undefined"!==typeof d[a]?d[a]:!1)})})},parse_map:function(c,b,a,d){var e={task:[],event:[],landmark:[],skill:[],vista:[],waypoint:[],sector:[]},f={task:[],event:[],landmark:[],skill:[],vista:[],waypoint:[],sector:[]};$.each(a.points_of_interest,function(){"waypoint"==this.type&&(f.waypoint.push(this.name),e.waypoint.push({id:this.poi_id,type:this.type,coords:this.coord,title:this.name,text:this.name,popup:this.name+
"
id:"+this.poi_id}));"landmark"==this.type&&(f.landmark.push(this.name),e.landmark.push({id:this.poi_id,type:this.type,coords:this.coord,title:this.name,text:this.name,popup:'<a href="'+b.i18n.wiki+encodeURIComponent(this.name)+'" target="_blank">'+this.name+"</a>
id:"+this.poi_id}));"vista"==this.type&&(f.vista.push(this.poi_id),e.vista.push({type:this.type,coords:this.coord,title:"id:"+this.poi_id,text:this.name+" "+this.poi_id,popup:"id:"+this.poi_id}))});$.each(a.tasks,function(){f.task.push(this.level);
e.task.push({id:this.task_id,type:"task",coords:this.coord,title:this.objective+" ("+this.level+")",text:"("+this.level+") "+this.objective,popup:'<a href="'+b.i18n.wiki+encodeURIComponent(this.objective.replace(/\.$/,""))+'" target="_blank">'+this.objective+"</a> ("+this.level+")
id:"+this.task_id})});$.each(a.skill_challenges,function(){f.skill.push(this.coord.toString());e.skill.push({id:null,type:"skill",coords:this.coord,title:this.coord.toString(),text:this.name+" "+this.coord.toString(),
popup:this.name+" "+this.coord.toString()})});$.each(a.sectors,function(){f.sector.push(this.name);e.sector.push({id:this.sector_id,type:"sector",coords:this.coord,title:this.name+", id:"+this.sector_id,icon_text:this.name,icon_text_class:"sector_text",text:this.name,popup:'<a href="'+b.i18n.wiki+encodeURIComponent(this.name)+'" target="_blank">'+this.name+"</a>
id:"+this.sector_id})});d&&$.each(d,function(c){f.event.push(this.level);e.event.push({id:c,type:"event",coords:[a.continent_rect[0][0]+
(a.continent_rect[1][0]-a.continent_rect[0][0])*(this.location.center[0]-a.map_rect[0][0])/(a.map_rect[1][0]-a.map_rect[0][0]),a.continent_rect[0][1]+(a.continent_rect[1][1]-a.continent_rect[0][1])*(1-(this.location.center[1]-a.map_rect[0][1])/(a.map_rect[1][1]-a.map_rect[0][1]))],title:this.name+" ("+this.level+")",text:"("+this.level+") "+this.name,popup:'<a href="'+b.i18n.wiki+encodeURIComponent(this.name.replace(/\.$/,""))+'" target="_blank">'+this.name+"</a> ("+this.level+")
id:"+c})});
(a.id===b.poi_id&&b.poi_type&&a.type===b.poi_type)&&(d({data:{coords:a.coords,text:a.popup}}),c.map.setZoom(b.max_zoom))},parse_polylines:function(c,b){var a=b.polyline.split(";");$.each(a,function(){var a=this.split(" "),e=[],f={};$.each(a,function(a,d){if(d.match(/\d{1,5},\d{1,5}/)){var g=d.split(",");e.push(c.map.unproject(g,b.max_zoom))}d.match(/(color|width|opacity|style|type)=(([0-9a-f]{3}){1,2}|\d{1,3}|(arrow|marker|dash))/i)&&(g=d.toLowerCase().split("="),f[g[0]]=g[1])});var a="undefined"!== typeof f.color?"#"+f.color:"#ffe500",k="undefined"!==typeof f.width?phpjs.intval(f.width):3,h="undefined"!==typeof f.opacity?phpjs.intval(f.opacity)/100:0.8,e=L.polyline(e,{color:a,weight:k,opacity:h,dashArray:"dash"===f.style?"30,15,10,15":""});c.layers[b.i18n.polylines].addLayer(e);if("undefined"!==typeof f.type){var g=[];"arrow"===f.type&&g.push({offset:50,repeat:"150px",symbol:new L.Symbol.ArrowHead({pixelSize:15,polygon:!1,pathOptions:{stroke:!0,color:a,weight:k,opacity:h}})});"marker"===f.type&& g.push({offset:0,repeat:"100%",symbol:new L.Symbol.Marker});c.layers[b.i18n.polylines].addLayer(L.polylineDecorator(e,{patterns:g}))}})},parse_markers:function(c,b){var a=b.markers.split(";");$.each(a,function(){var a=this.split(" ");$.each(a,function(a,d){if(d.match(/\d{1,5},\d{1,5}/)){var k=d.split(","),k=L.marker(c.map.unproject(k,b.max_zoom)).addTo(c.map);c.layers[b.i18n.markers].addLayer(k)}})})},options:function(c){var b={};$.each(c.attributes,function(){this.name.match(/^data-/)&&(b[this.name.substr(5)]= "data-polyline"===this.name||"data-markers"===this.name?this.value:phpjs.intval(this.value))});c=["en","de","en","es","fr"];var a=[!1,"landmark","sector","skill","task","vista","waypoint"],d="number"===typeof b.continent_id&&1<=b.continent_id&&2>=b.continent_id?b.continent_id:1;return{max_zoom:1==d?7:6,continent_id:d,floor_id:"number"===typeof b.floor_id?b.floor_id:2,region_id:"number"===typeof b.region_id&&0<b.region_id?b.region_id:!1,map_id:"number"===typeof b.map_id&&0<b.map_id?b.map_id:!1,poi_id:"number"=== typeof b.poi_id&&0<b.poi_id?b.poi_id:!1,poi_type:"number"===typeof b.poi_type&&0<b.poi_type&&6>=b.poi_type?a[b.poi_type]:!1,width:"number"===typeof b.width&&0<b.width?b.width+(!0==b.w_percent?"%":"px"):"800px",height:"number"===typeof b.height&&0<b.height?b.height+(!0==b.h_percent?"%":"px"):"450px",map_controls:!0!=b.disable_controls,event_data:!0!=b.disable_eventdata,linkbox:"number"===typeof b.linkbox&&100<=b.linkbox?b.linkbox+"px":!1,polyline:b.polyline&&7<b.polyline.length?b.polyline:!1,markers:b.markers&& 2<b.markers.length?b.markers:!1,i18n:"number"===typeof b.language&&1<=b.language&&4>=b.language?GW2Maps.i18n[c[b.language]]:GW2Maps.i18n[c[0]]}},i18n:{de:{lang:"de",wiki:"http://wiki-de.guildwars2.com/wiki/",icon_event:{link:"http://wiki-de.guildwars2.com/images/7/7a/Event_Angriff_Icon.png",size:[24,24]},icon_landmark:{link:"http://wiki-de.guildwars2.com/images/0/0f/Sehensw\u00fcrdigkeit_Icon.png",size:[16,16]},icon_skill:{link:"http://wiki-de.guildwars2.com/images/1/14/Heldenpunkt_Icon.png", size:[20,20]},icon_task:{link:"http://wiki-de.guildwars2.com/images/b/b7/Aufgabe_Icon.png",size:[20,20]},icon_vista:{link:"http://wiki-de.guildwars2.com/images/b/b2/Panorama_Icon.png",size:[20,20]},icon_waypoint:{link:"http://wiki-de.guildwars2.com/images/d/df/Wegmarke_Icon.png",size:[24,24]},errortile:"http://wiki-de.guildwars2.com/images/6/6f/Kartenhintergrund.png",event:"Events",landmark:"Sehensw\u00fcrdigkeiten",markers:"Marker",polylines:"Polylinien",sector:"Gegenden",skill:"Heldenpunkte", task:"Aufgaben",vista:"Panoramen",waypoint:"Wegmarken",attribution:"Kartendaten und -bilder"},en:{lang:"en",wiki:"http://wiki.guildwars2.com/wiki/",icon_event:{link:"http://wiki-de.guildwars2.com/images/7/7a/Event_Angriff_Icon.png",size:[24,24]},icon_landmark:{link:"http://wiki.guildwars2.com/images/f/fb/Point_of_interest.png",size:[20,20]},icon_skill:{link:"http://wiki.guildwars2.com/images/8/84/Skill_point.png",size:[20,20]},icon_task:{link:"http://wiki.guildwars2.com/images/f/f8/Complete_heart_(map_icon).png", size:[20,20]},icon_vista:{link:"http://wiki.guildwars2.com/images/d/d9/Vista.png",size:[20,20]},icon_waypoint:{link:"http://wiki.guildwars2.com/images/d/d2/Waypoint_(map_icon).png",size:[20,20]},errortile:"http://wiki-de.guildwars2.com/images/6/6f/Kartenhintergrund.png",event:"Events",landmark:"Points of Interest",markers:"Markers",polylines:"Polylines",sector:"Sector Names",skill:"Skill Challenges",task:"Tasks",vista:"Vistas",waypoint:"Waypoints",attribution:"Map data and imagery"},es:{lang:"es", wiki:"http://wiki-es.guildwars2.com/wiki/",icon_event:{link:"http://wiki-de.guildwars2.com/images/7/7a/Event_Angriff_Icon.png",size:[24,24]},icon_landmark:{link:"http://wiki.guildwars2.com/images/f/fb/Point_of_interest.png",size:[20,20]},icon_skill:{link:"http://wiki.guildwars2.com/images/8/84/Skill_point.png",size:[20,20]},icon_task:{link:"http://wiki.guildwars2.com/images/f/f8/Complete_heart_(map_icon).png",size:[20,20]},icon_vista:{link:"http://wiki.guildwars2.com/images/d/d9/Vista.png",size:[20, 20]},icon_waypoint:{link:"http://wiki.guildwars2.com/images/d/d2/Waypoint_(map_icon).png",size:[20,20]},errortile:"http://wiki-de.guildwars2.com/images/6/6f/Kartenhintergrund.png",event:"event-es",landmark:"poi-es",markers:"markers-es",polylines:"polyline-es",sector:"sector-es",skill:"skill-es",task:"task-es",vista:"vista-es",waypoint:"waypoint-es",attribution:"attribution-es"},fr:{lang:"fr",wiki:"http://wiki-fr.guildwars2.com/wiki/",icon_event:{link:"http://wiki-de.guildwars2.com/images/7/7a/Event_Angriff_Icon.png", size:[24,24]},icon_landmark:{link:"http://wiki-fr.guildwars2.com/images/d/d2/Ic\u00f4ne_site_remarquable_d\u00e9couvert.png",size:[20,20]},icon_skill:{link:"http://wiki-fr.guildwars2.com/images/5/5c/Progression_d\u00e9fi.png",size:[20,20]},icon_task:{link:"http://wiki-fr.guildwars2.com/images/a/af/Ic\u00f4ne_coeur_plein.png",size:[20,20]},icon_vista:{link:"http://wiki-fr.guildwars2.com/images/8/82/Ic\u00f4ne_panorama.png",size:[20,20]},icon_waypoint:{link:"http://wiki-fr.guildwars2.com/images/5/56/Progression_passage.png", size:[20,20]},errortile:"http://wiki-de.guildwars2.com/images/6/6f/Kartenhintergrund.png",event:"event-fr",landmark:"Sites remarquables",markers:"markers-fr",polylines:"polyline-fr",sector:"Secteurs",skill:"D\u00e9fis de comp\u00e9tences",task:"C\u0153urs",vista:"Panoramas",waypoint:"Points de passage",attribution:"attribution-fr"}}},phpjs={intval:function(c,b){var a;a=typeof c;return"boolean"===a?+c:"string"===a?(a=parseInt(c,b||10),isNaN(a)||!isFinite(a)?0:a):"number"===a&&isFinite(c)?c|0:0},parse_url:function(c, b){var a;a="source scheme authority userInfo user pass host port relative path directory file query fragment".split(" ");for(var d=this.php_js&&this.php_js.ini||{},e=d["phpjs.parse_url.mode"]&&d["phpjs.parse_url.mode"].local_value||"php",f={php:/^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},f=f[e].exec(c),k={},h=14;h--;)f[h]&&(k[a[h]]=f[h]);if(b)return k[b.replace("PHP_URL_","").toLowerCase()];if("php"!==e){var g=d["phpjs.parse_url.queryKey"]&&d["phpjs.parse_url.queryKey"].local_value||"queryKey",f=/(?:^|&)([^&=]*)=?([^&]*)/g;k[g]={};a=k[a[12]]||"";a.replace(f,function(a,b,c){b&&(k[g][b]= c)})}delete k.source;return k},array_multisort:function(c){var b={SORT_REGULAR:16,SORT_NUMERIC:17,SORT_STRING:18,SORT_ASC:32,SORT_DESC:40},a=0,d=[[]],e=[[]],f=[0],k=0,h=0,g,q="",a=0,t=[],n=0,a=null,s=[],r=[],n=[],m=[],p=0,u=function(){return s.shift()},v=[[function(a,b){r.push(a>b?1:a<b?-1:0);return a>b?1:a<b?-1:0},function(a,b){r.push(b>a?1:b<a?-1:0);return b>a?1:b<a?-1:0}],[function(a,b){r.push(a-b);return a-b},function(a,b){r.push(b-a);return b-a}],[function(a,b){r.push(a+"">b+""?1:a+""<b+""?-1: 0);return a+"">b+""?1:a+""<b+""?-1:0},function(a,b){r.push(b+"">a+""?1:b+""<a+""?-1:0);return b+"">a+""?1:b+""<a+""?-1:0}]];if("[object Array]"===Object.prototype.toString.call(c))d[0]=c;else if(c&&"object"===typeof c)for(h in c)c.hasOwnProperty(h)&&(e[0].push(h),d[0].push(c[h]));else return!1;var a=d[0].length,l=[0,a];for(g=1;g<arguments.length;g++)if("[object Array]"===Object.prototype.toString.call(arguments[g])){if(d[g]=arguments[g],f[g]=0,arguments[g].length!==a)return!1}else if(arguments[g]&& "object"===typeof arguments[g]){e[g]=[];d[g]=[];f[g]=0;for(h in arguments[g])arguments[g].hasOwnProperty(h)&&(e[g].push(h),d[g].push(arguments[g][h]));if(d[g].length!==a)return!1}else if("string"===typeof arguments[g]){n=f.pop();if("undefined"===typeof b[arguments[g]]||0<(b[arguments[g]]>>>4&n>>>4))return!1;f.push(n+b[arguments[g]])}else return!1;for(h=0;h!==a;h++)t.push(!0);for(h in d)if(d.hasOwnProperty(h)){n=[];m=[];p=0;s=[];r=[];if(0===l.length)if("[object Array]"===Object.prototype.toString.call(arguments[h]))arguments[h]= d[h];else{for(q in arguments[h])arguments[h].hasOwnProperty(q)&&delete arguments[h][q];a=d[h].length;for(n=g=0;g<a;g++)n=e[h][g],arguments[h][n]=d[h][g]}else{b=v[f[h]&3][0<(f[h]&8)?1:0];for(a=0;a!==l.length;a+=2)for(k in m=d[h].slice(l[a],l[a+1]+1),m.sort(b),n[a]=[].concat(r),p=l[a],m)m.hasOwnProperty(k)&&(d[h][p]=m[k],p++);b=u;for(g in d)if(d.hasOwnProperty(g)&&d[g]!==d[h])for(a=0;a!==l.length;a+=2)for(k in m=d[g].slice(l[a],l[a+1]+1),s=[].concat(n[a]),m.sort(b),p=l[a],m)m.hasOwnProperty(k)&&(d[g][p]= m[k],p++);for(g in e)if(e.hasOwnProperty(g))for(a=0;a!==l.length;a+=2)for(k in m=e[g].slice(l[a],l[a+1]+1),s=[].concat(n[a]),m.sort(b),p=l[a],m)m.hasOwnProperty(k)&&(e[g][p]=m[k],p++);a=null;l=[];for(g in d[h])d[h].hasOwnProperty(g)&&(t[g]?l.length&1?d[h][g]!==a&&(l.push(g-1),a=d[h][g]):(null!==a&&(d[h][g]===a?l.push(g-1):t[g]=!1),a=d[h][g]):(l.length&1&&l.push(g-1),a=null));l.length&1&&l.push(g);if("[object Array]"===Object.prototype.toString.call(arguments[h]))arguments[h]=d[h];else{for(g in arguments[h])arguments[h].hasOwnProperty(g)&& delete arguments[h][g];a=d[h].length;for(n=g=0;g<a;g++)n=e[h][g],arguments[h][n]=d[h][g]}}delete d[h];delete e[h]}return!0}}; L.GeometryUtil={computeAngle:function(c,b){return 180*Math.atan2(b.y-c.y,b.x-c.x)/Math.PI+90},getPointPathPixelLength:function(c){if(2>c.length)return 0;for(var b=0,a=c[0],d=1,e=c.length;d<e;d++)b+=a.distanceTo(a=c[d]);return b},getPixelLength:function(c,b){var a=c instanceof L.Polyline?c.getLatLngs():c;if(2>a.length)return 0;for(var d=0,e=b.latLngToLayerPoint(a[0]),f=1,k=a.length;f<k;f++)d+=e.distanceTo(e=b.latLngToLayerPoint(a[f]));return d},projectPatternOnPath:function(c,b,a,d){var e=[],f,k;f= 0;for(k=c.length;f<k;f++)e[f]=d.latLngToLayerPoint(c[f]);c=this.projectPatternOnPointPath(e,b,a);f=0;for(k=c.length;f<k;f++)c[f].latLng=d.layerPointToLatLng(c[f].pt);return c},projectPatternOnPointPath:function(c,b,a){var d=[],e=L.GeometryUtil.getPointPathPixelLength(c)*a;b=L.GeometryUtil.interpolateOnPointPath(c,b);d.push(b);if(0<a)for(c=c.slice(b.predecessor),c[0]=b.pt,a=L.GeometryUtil.getPointPathPixelLength(c);e<=a;)b=L.GeometryUtil.interpolateOnPointPath(c,e/a),d.push(b),c=c.slice(b.predecessor), c[0]=b.pt,a=L.GeometryUtil.getPointPathPixelLength(c);return d},interpolateOnPointPath:function(c,b){var a=c.length;if(2>a)return null;if(0>=b)return{pt:c[0],predecessor:0,heading:L.GeometryUtil.computeAngle(c[0],c[1])};if(1<=b)return{pt:c[a-1],predecessor:a-1,heading:L.GeometryUtil.computeAngle(c[a-2],c[a-1])};if(2==a)return{pt:L.GeometryUtil.interpolateBetweenPoints(c[0],c[1],b),predecessor:0,heading:L.GeometryUtil.computeAngle(c[0],c[1])};var d,e,f,k,h=0,g=L.GeometryUtil.getPointPathPixelLength(c); d=e=c[0];f=k=0;for(var q=1;q<a&&k<b;q++)d=e,f=k,e=c[q],h+=d.distanceTo(e),k=h/g;return{pt:L.GeometryUtil.interpolateBetweenPoints(d,e,(b-f)/(k-f)),predecessor:q-2,heading:L.GeometryUtil.computeAngle(d,e)}},interpolateBetweenPoints:function(c,b,a){return b.x!=c.x?new L.Point(c.x*(1-a)+a*b.x,c.y*(1-a)+a*b.y):new L.Point(c.x,c.y+(b.y-c.y)*a)}}; L.RotatedMarker=L.Marker.extend({options:{angle:0},statics:{bestTransform:L.DomUtil.testProp(["transform","WebkitTransform","msTransform","MozTransform","OTransform"])},_setPos:function(c){L.Marker.prototype._setPos.call(this,c);c=" rotate("+this.options.angle+"deg)";if(L.RotatedMarker.bestTransform)this._icon.style[L.RotatedMarker.bestTransform]+=c;else if(L.Browser.ie){var b=this.options.angle*L.LatLng.DEG_TO_RAD;c=Math.cos(b);b=Math.sin(b);this._icon.style.filter+=" progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11="+ c+", M12="+-b+", M21="+b+", M22="+c+")"}}});L.Symbol=L.Symbol||{}; L.Symbol.Dash=L.Class.extend({isZoomDependant:!0,options:{pixelSize:10,pathOptions:{}},initialize:function(c){L.Util.setOptions(this,c);this.options.pathOptions.clickable=!1},buildSymbol:function(c,b,a){b=this.options;if(1>=b.pixelSize)return new L.Polyline([c.latLng,c.latLng],b.pathOptions);var d=a.project(c.latLng);c=-(c.heading-90)*L.LatLng.DEG_TO_RAD;c=new L.Point(d.x+b.pixelSize*Math.cos(c+Math.PI)/2,d.y+b.pixelSize*Math.sin(c)/2);d=d.add(d.subtract(c));return new L.Polyline([a.unproject(c), a.unproject(d)],b.pathOptions)}}); L.Symbol.ArrowHead=L.Class.extend({isZoomDependant:!0,options:{polygon:!0,pixelSize:10,headAngle:60,pathOptions:{stroke:!1,weight:2}},initialize:function(c){L.Util.setOptions(this,c);this.options.pathOptions.clickable=!1},buildSymbol:function(c,b,a){b=this.options;return b.polygon?new L.Polygon(this._buildArrowPath(c,a),b.pathOptions):new L.Polyline(this._buildArrowPath(c,a),b.pathOptions)},_buildArrowPath:function(c,b){var a=b.project(c.latLng),d=-(c.heading-90)*L.LatLng.DEG_TO_RAD,e=this.options.headAngle/ 2*L.LatLng.DEG_TO_RAD,f=d+e,d=d-e,f=new L.Point(a.x-this.options.pixelSize*Math.cos(f),a.y+this.options.pixelSize*Math.sin(f)),a=new L.Point(a.x-this.options.pixelSize*Math.cos(d),a.y+this.options.pixelSize*Math.sin(d));return[b.unproject(f),c.latLng,b.unproject(a)]}}); L.Symbol.Marker=L.Class.extend({isZoomDependant:!1,options:{markerOptions:{},rotate:!1},initialize:function(c){L.Util.setOptions(this,c);this.options.markerOptions.clickable=!1;this.options.markerOptions.draggable=!1;this.isZoomDependant=L.Browser.ie&&this.options.rotate},buildSymbol:function(c){return this.options.rotate?(this.options.markerOptions.angle=c.heading,new L.RotatedMarker(c.latLng,this.options.markerOptions)):new L.Marker(c.latLng,this.options.markerOptions)}}); L.PolylineDecorator=L.LayerGroup.extend({options:{patterns:[]},initialize:function(c,b){L.LayerGroup.prototype.initialize.call(this);L.Util.setOptions(this,b);this._polyline=c;this._directionPointCache=[];this._initPatterns()},_initPatterns:function(){this._directionPointCache=[];this._isZoomDependant=!1;this._patterns=[];for(var c,b=0;b<this.options.patterns.length;b++)c=this._parsePatternDef(this.options.patterns[b]),this._patterns.push(c),this._isZoomDependant=this._isZoomDependant||c.isOffsetInPixels|| c.isRepeatInPixels||c.symbolFactory.isZoomDependant},setPatterns:function(c){this.options.patterns=c;this._initPatterns();this._softRedraw()},_parsePatternDef:function(c){var b={cache:[],symbolFactory:c.symbol,isOffsetInPixels:!1,isRepeatInPixels:!1};"string"===typeof c.offset&&-1!=c.offset.indexOf("%")?b.offset=parseFloat(c.offset)/100:(b.offset=parseFloat(c.offset),b.isOffsetInPixels=0<b.offset);"string"===typeof c.repeat&&-1!=c.repeat.indexOf("%")?b.repeat=parseFloat(c.repeat)/100:(b.repeat=parseFloat(c.repeat), b.isRepeatInPixels=0<b.repeat);return b},onAdd:function(c){this._map=c;this._draw();if(this._isZoomDependant)this._map.on("zoomend",this._softRedraw,this)},onRemove:function(c){this._map.off("zoomend",this._softRedraw,this);L.LayerGroup.prototype.onRemove.call(this,c)},_buildSymbols:function(c,b){for(var a=[],d=0,e=b.length;d<e;d++)a.push(c.buildSymbol(b[d],this._latLngs,this._map,d,e));return a},_getDirectionPoints:function(c){var b=c.cache[this._map.getZoom()];if("undefined"!=typeof b)return b; this._latLngs=this._polyline instanceof L.Polyline?this._polyline.getLatLngs():this._polyline;if(2>this._latLngs.length)return[];this._polyline instanceof L.Polygon&&this._latLngs.push(this._latLngs[0]);var a;a=null;c.isOffsetInPixels?(a=L.GeometryUtil.getPixelLength(this._latLngs,this._map),b=c.offset/a):b=c.offset;c.isRepeatInPixels?(a=null!=a?a:L.GeometryUtil.getPixelLength(this._latLngs,this._map),a=c.repeat/a):a=c.repeat;b=L.GeometryUtil.projectPatternOnPath(this._latLngs,b,a,this._map);return c.cache[this._map.getZoom()]= b},redraw:function(){this._redraw(!0)},_softRedraw:function(){this._redraw(!1)},_redraw:function(c){this.clearLayers();if(c)for(c=0;c<this._patterns.length;c++)this._patterns[c].cache=[];this._draw()},_drawPattern:function(c){var b=this._getDirectionPoints(c);c=this._buildSymbols(c.symbolFactory,b);for(b=0;b<c.length;b++)this.addLayer(c[b])},_draw:function(){for(var c=0;c<this._patterns.length;c++)this._drawPattern(this._patterns[c])}}); L.polylineDecorator=function(c,b){return new L.PolylineDecorator(c,b)};