diff --git a/bower.json b/bower.json index 015aac0..2dd7f84 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "r360", - "version": "0.0.12", + "version": "0.0.13", "authors": [ "gerber@motionintelligence.net", "hollburg@motionintelligence.net" diff --git a/dist/r360-src.js b/dist/r360-src.js index 74d8359..05a0717 100644 --- a/dist/r360-src.js +++ b/dist/r360-src.js @@ -1,5 +1,5 @@ /* - Route360° JavaScript API v0.0.9 (4f9ae63), a JS library for leaflet maps. http://route360.net + Route360° JavaScript API v0.0.9 (8488ac8), a JS library for leaflet maps. http://route360.net (c) 2014 Henning Hollburg and Daniel Gerber, (c) 2014 Motion Intelligence GmbH */ (function (window, document, undefined) { @@ -119,7 +119,7 @@ r360.config = { defaultPlaceAutoCompleteOptions : { serviceUrl : "http://geocode.route360.net/solr/select?", - serviceUrl : "http://148.251.160.52/api?", + // serviceUrl : "http://148.251.160.52/api?", position : 'topleft', reset : false, reverse : false, @@ -142,7 +142,7 @@ r360.config = { backgroundOpacity : 0.5, inverse : false, - animate : true, + animate : false, animationDuration : 1 }, @@ -542,8 +542,8 @@ r360.TravelOptions = function(){ // validate each source _.each(this.getSources(), function(source){ - if ( !_.has(source, 'lat') ) this.getErrors().push('Sources contains source with undefined latitude!'); - if ( !_.has(source, 'lon') ) this.getErrors().push('Sources contains source with undefined longitude!'); + if ( !_.has(source, 'lat') && typeof source.getLatLng !== 'function' ) this.getErrors().push('Sources contains source with undefined latitude!'); + if ( !_.has(source, 'lon') && typeof source.getLatLng !== 'function' ) this.getErrors().push('Sources contains source with undefined longitude!'); }); } } @@ -618,8 +618,8 @@ r360.TravelOptions = function(){ // validate each source _.each(this.getTargets(), function(target){ - if ( !_.has(target, 'lat') ) this.getErrors().push('Targets contains target with undefined latitude!'); - if ( !_.has(target, 'lon') ) this.getErrors().push('Targets contains target with undefined longitude!'); + if ( !_.has(target, 'lat') && typeof target.getLatLng !== 'function' ) this.getErrors().push('Targets contains target with undefined latitude!'); + if ( !_.has(target, 'lon') && typeof target.getLatLng !== 'function' ) this.getErrors().push('Targets contains target with undefined longitude!'); }); } } @@ -3252,7 +3252,7 @@ r360.Route360PolygonLayer = L.Class.extend({ return true; var val = (p1.x * (p2.y -p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y)); - if(val < 1 && val > -1) + if(val < 1 && val > -1 && p1.x != p3.x && p1.y != p3.y) return true; return false; }, @@ -3576,7 +3576,7 @@ r360.Route360PolygonLayer = L.Class.extend({ var svgStart = "
" + " style='fill:" + r360.config.defaultPolygonLayerOptions.backgroundColor + " ; opacity: "+ r360.config.defaultPolygonLayerOptions.opacity + "; stroke-linejoin:round; stroke-linecap:round; fill-rule: evenodd' xmlns='http://www.w3.org/2000/svg'>" var svgEnd = "
"; var gees = ""; diff --git a/dist/r360.js b/dist/r360.js index c946afd..f9ba965 100644 --- a/dist/r360.js +++ b/dist/r360.js @@ -1,6 +1,6 @@ /* - Route360° JavaScript API v0.0.9 (4f9ae63), a JS library for leaflet maps. http://route360.net + Route360° JavaScript API v0.0.9 (8488ac8), a JS library for leaflet maps. http://route360.net (c) 2014 Henning Hollburg and Daniel Gerber, (c) 2014 Motion Intelligence GmbH */ -!function(t){function e(){var e=t.r360;o.noConflict=function(){return t.r360=e,this},t.r360=o}var o={version:"v0.0.9"};"object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd?define(o):e(),Function.prototype.bind||(Function.prototype.bind=function(t){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var e=Array.prototype.slice.call(arguments,1),o=this,i=function(){},n=function(){return o.apply(this instanceof i&&t?this:t,e.concat(Array.prototype.slice.call(arguments)))};return i.prototype=this.prototype,n.prototype=new i,n}),o.config={serviceUrl:"http://api.route360.net/api_dev/",nominatimUrl:"http://geocode.route360.net/",serviceVersion:"v1",pathSerializer:"compact",maxRoutingTime:3600,bikeSpeed:15,bikeUphill:20,bikeDownhill:-10,walkSpeed:5,walkUphill:10,walkDownhill:0,travelTimes:[300,600,900,1200,1500,1800],travelType:"walk",logging:!1,utm:!0,defaultTravelTimeControlOptions:{travelTimes:[{time:300,color:"#006837",opacity:.1},{time:600,color:"#39B54A"},{time:900,color:"#8CC63F"},{time:1200,color:"#F7931E"},{time:1500,color:"#F15A24"},{time:1800,color:"#C1272D"}],position:"topright",label:"travel time",initValue:30},routeTypes:[{routeType:"WALK",color:"#558D54",halo:"#558D54"},{routeType:"BIKE",color:"#558D54",halo:"#558D54"},{routeType:"CAR",color:"#558D54",halo:"#558D54"},{routeType:"TRANSFER",color:"#558D54",halo:"#558D54"},{routeType:102,color:"#006837",halo:"#006837"},{routeType:400,color:"#156ab8",halo:"#156ab8"},{routeType:900,color:"red",halo:"red"},{routeType:700,color:"#A3007C",halo:"#A3007C"},{routeType:1e3,color:"blue",halo:"blue"},{routeType:109,color:"#006F35",halo:"#006F35"},{routeType:100,color:"red",halo:"red"},{routeType:1,color:"red",halo:"red"},{routeType:2,color:"blue",halo:"blue"},{routeType:3,color:"yellow",halo:"yellow"},{routeType:0,color:"green",halo:"green"},{routeType:4,color:"orange",halo:"orange"},{routeType:5,color:"red",halo:"red"},{routeType:6,color:"blue",halo:"blue"},{routeType:7,color:"yellow",halo:"yellow"}],defaultPlaceAutoCompleteOptions:{serviceUrl:"http://geocode.route360.net/solr/select?",serviceUrl:"http://148.251.160.52/api?",position:"topleft",reset:!1,reverse:!1,placeholder:"Select source",maxRows:5,width:300},defaultRadioOptions:{position:"topright"},defaultPolygonLayerOptions:{opacity:.4,strokeWidth:30,backgroundColor:"black",backgroundOpacity:.5,inverse:!1,animate:!0,animationDuration:1},i18n:{language:"de",departure:{en:"Departure",de:"Abfahrt"},line:{en:"Line",de:"Linie"},arrival:{en:"Arrival",de:"Ankunft"},from:{en:"From",de:"Von"},to:{en:"To",de:"Nach"},travelTime:{en:"Travel time",de:"Reisezeit"},totalTime:{en:"Total time",de:"Gesamtzeit"},distance:{en:"Distance",de:"Distanz"},wait:{en:"Please wait!",de:"Bitte warten!"},elevation:{en:"Elevation",de:"Höhenunterschied"},timeFormat:{en:"a.m.",de:"Uhr"},reset:{en:"Reset input",de:"Eingeben löschen"},reverse:{en:"Switch source and target",de:"Start und Ziel tauschen"},noRouteFound:{en:"No route found!",de:"Keine Route gefunden!"},monthNames:{de:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"]},dayNames:{de:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"]},dayNamesMin:{de:["So","Mo","Di","Mi","Do","Fr","Sa"]},get:function(t){var e;return _.each(_.keys(o.config.i18n),function(i){t==i&&(e=o.config.i18n[t][o.config.i18n.language])}),e}}},o.Util={getTimeInSeconds:function(){var t=new Date;return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()},getHoursAndMinutesInSeconds:function(){var t=new Date;return 3600*t.getHours()+60*t.getMinutes()},getCurrentDate:function(){var t=new Date,e=t.getFullYear(),o=t.getMonth()+1<10?"0"+(t.getMonth()+1):t.getMonth()+1,i=t.getDate()<10?"0"+t.getDate():t.getDate();return e+""+o+i},getTimeFormat:function(t){var e=o.config.i18n;return"en"==e.language&&t>=43200?"p.m.":e.get("timeFormat")},secondsToHoursAndMinutes:function(t){var e=(t/60).toFixed(0),o=Math.floor(e/60);e-=60*o;var i="";return 0!=o&&(i+=o+"h "),i+=e+"min"},secondsToTimeOfDay:function(t){var e=Math.floor(t/3600),o=Math.floor(t/60)-60*e;return t=t-3600*e-60*o,e+":"+("0"+o).slice(-2)+":"+("0"+t).slice(-2)},generateId:function(t){var e="",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";return _.each(_.range(t?t:10),function(){e+=o.charAt(Math.floor(Math.random()*o.length))}),e},parseLatLonArray:function(t){for(var e=new Array,o=0;o0&&i.push(e.join(" ")),o.length>0&&i.push(o.join(", ")),0==e.length&&0==o.length&&i.push(t.display_name),i.join(", ")},parsePolygons:function(t){if(t.error)return errorMessage;if(o.config.logging)var e=(new Date).getTime();var i=Array();return _.each(t,function(t){var e={id:t.id,polygons:[]};_.each(t.polygons,function(t){var i=o.polygon();i.setTravelTime(t.travelTime),i.setColor(_.findWhere(o.config.defaultTravelTimeControlOptions.travelTimes,{time:i.getTravelTime()}).color),i.setOpacity(_.findWhere(o.config.defaultTravelTimeControlOptions.travelTimes,{time:i.getTravelTime()}).opacity),i.setOuterBoundary(o.Util.parseLatLonArray(t.outerBoundary)),i.setBoundingBox(),_.each(t.innerBoundary,function(t){i.addInnerBoundary(o.Util.parseLatLonArray(t))}),e.polygons.push(i)}),i.push(e)}),o.config.logging&&console.log("Polygon parsing took: "+((new Date).getTime()-e)+"ms"),i},parseRoutes:function(t){var e=new Array;return _.each(t.routes,function(t){var i=o.route(t.travelTime);_.each(t.segments,function(t){i.addRouteSegment(o.routeSegment(t))}),e.push(i)}),e},getMarker:function(t,e){var o=_.has(e,"color")?"-"+e.color:"-blue";return e.icon=L.icon({iconSize:[25,41],iconUrl:e.iconPath+"marker-icon"+o+".png",iconAnchor:[12,41],shadowSize:[41,41],shadowUrl:e.iconPath+"marker-shadow.png",shadowAnchor:[41/3,41],popupAnchor:[0,-35]}),L.marker(t,e)},webMercatorToLeaflet:function(t){return t.x/=6378137,t.y/=6378137,L.CRS.EPSG3857.transformation._transform(t),t},webMercatorToLatLng:function(t){return t.x/=6378137,t.y/=6378137,L.CRS.EPSG3857.projection.unproject(t)}},o.TravelOptions=function(){this.sources=[],this.targets=[],this.service,this.bikeSpeed=15,this.bikeUphill=20,this.bikeDownhill=-10,this.walkSpeed=5,this.walkUphill=10,this.walkDownhill=0,this.travelTimes=[300,600,900,1200,1500,1800],this.travelType="walk",this.time=o.Util.getTimeInSeconds(),this.date=o.Util.getCurrentDate(),this.errors=[],this.intersectionMode="union",this.pathSerializer=o.config.pathSerializer,this.maxRoutingTime=o.config.maxRoutingTime,this.waitControl,this.isValidPolygonServiceOptions=function(){return this.errors=[],"[object Array]"===Object.prototype.toString.call(this.getSources())?0==this.getSources().length?this.getErrors().push("Sources do not contain any points!"):_.each(this.getSources(),function(t){_.has(t,"lat")||this.getErrors().push("Sources contains source with undefined latitude!"),_.has(t,"lon")||this.getErrors().push("Sources contains source with undefined longitude!")}):this.getErrors().push("Sources are not of type array!"),_.contains(["bike","transit","walk","car"],this.getTravelType())?"car"==this.getTravelType()||("bike"==this.getTravelType()?((this.getBikeUphill()<0||this.getBikeDownhill()>0||this.getBikeUphill()<-this.getBikeDownhill())&&this.getErrors().push("Uphill cycle speed has to be larger then 0. Downhill cycle speed has to be smaller then 0. Absolute value of downhill cycle speed needs to be smaller then uphill cycle speed."),this.getBikeSpeed()<=0&&this.getErrors().push("Bike speed needs to be larger then 0.")):"walk"==this.getTravelType()?((this.getWalkUphill()<0||this.getWalkDownhill()>0||this.getWalkUphill()<-this.getWalkDownhill())&&this.getErrors().push("Uphill walking speed has to be larger then 0. Downhill walking speed has to be smaller then 0. Absolute value of downhill walking speed needs to be smaller then uphill walking speed."),this.getWalkSpeed()<=0&&this.getErrors().push("Walk speed needs to be larger then 0.")):"transit"==this.getTravelType()&&(this.getTime()<0&&this.getErrors().push("Start time for transit routing needs to larger than 0: "+this.getTime()),8!=this.getDate().length&&this.getErrors().push("Date has to have format YYYYMMDD: "+this.getDate()))):this.getErrors().push("Not supported travel type given: "+this.getTravelType()),"[object Array]"!==Object.prototype.toString.call(this.getTravelTimes())?this.getErrors().push("Travel times have to be an array!"):_.reject(this.getTravelTimes(),function(t){return"number"==typeof t}).length>0&&this.getErrors().push("Travel times contain non number entries: "+this.getTravelTimes()),_.contains(["union","average","intersection","none"],this.getIntersectionMode())||this.getErrors().push("Not supported intersection mode given: "+this.getIntersectionMode()),0==this.errors.length},this.isValidRouteServiceOptions=function(){return this.isValidPolygonServiceOptions(),"[object Array]"===Object.prototype.toString.call(this.getTargets())?0==this.getTargets().length?this.getErrors().push("Sources do not contain any points!"):_.each(this.getTargets(),function(t){_.has(t,"lat")||this.getErrors().push("Targets contains target with undefined latitude!"),_.has(t,"lon")||this.getErrors().push("Targets contains target with undefined longitude!")}):this.getErrors().push("Targets are not of type array!"),_.contains(["travelTime","compact","detailed"],this.getPathSerializer())||this.getErrors().push("Path serializer not supported: "+this.getPathSerializer()),0==this.errors.length},this.isValidTimeServiceOptions=function(){return this.isValidRouteServiceOptions(),_.contains(["travelTime","compact","detailed"],this.getPathSerializer())||this.getErrors().push("Path serializer not supported: "+this.getPathSerializer()),0==this.errors.length},this.getErrors=function(){return this.errors},this.getSources=function(){return this.sources},this.addSource=function(t){this.sources.push(t)},this.addTarget=function(t){this.targets.push(t)},this.getTargets=function(){return this.targets},this.getBikeSpeed=function(){return this.bikeSpeed},this.getBikeUphill=function(){return this.bikeUphill},this.getBikeDownhill=function(){return this.bikeDownhill},this.getWalkSpeed=function(){return this.walkSpeed},this.getWalkUphill=function(){return this.walkUphill},this.getWalkDownhill=function(){return this.walkDownhill},this.getTravelTimes=function(){return this.travelTimes},this.getTravelType=function(){return this.travelType},this.getTime=function(){return this.time},this.getDate=function(){return this.date},this.getWaitControl=function(){return this.waitControl},this.getService=function(){return this.service},this.getPathSerializer=function(){return this.pathSerializer},this.getMaxRoutingTime=function(){return this.maxRoutingTime},this.getIntersectionMode=function(){return this.intersectionMode},this.setIntersectionMode=function(t){this.intersectionMode=t},this.setMaxRoutingTime=function(t){this.maxRoutingTime=t},this.setPathSerializer=function(t){this.pathSerializer=t},this.setService=function(t){this.service=t},this.setSources=function(t){this.sources=t},this.setTargets=function(t){this.targets=t},this.setBikeSpeed=function(t){this.bikeSpeed=t},this.setBikeUphill=function(t){this.bikeUphill=t},this.setBikeDownhill=function(t){this.bikeDownhill=t},this.setWalkSpeed=function(t){this.walkSpeed=t},this.setWalkUphill=function(t){this.walkUphill=t},this.setWalkDownhill=function(t){this.walkDownhill=t},this.setTravelTimes=function(t){this.travelTimes=t},this.setTravelType=function(t){this.travelType=t},this.setTime=function(t){this.time=t},this.setDate=function(t){this.date=t},this.setWaitControl=function(t){this.waitControl=t}},o.travelOptions=function(){return new o.TravelOptions},o.PolygonService={cache:{},getTravelTimePolygons:function(t,e){if(t.isValidPolygonServiceOptions()){t.getWaitControl()&&t.getWaitControl().show();var i={polygon:{values:t.getTravelTimes(),intersectionMode:t.getIntersectionMode()},sources:[]};_.each(t.getSources(),function(e){var o={lat:_.has(e,"lat")?e.lat:e.getLatLng().lat,lon:_.has(e,"lon")?e.lon:e.getLatLng().lng,id:_.has(e,"id")?e.id:e.lat+";"+e.lon,tm:{}},n=_.has(e,"travelType")?e.travelType:t.getTravelType();o.tm[n]={},"transit"==n&&(o.tm.transit.frame={time:t.getTime(),date:t.getDate()}),"bike"==n&&(o.tm.bike={speed:t.getBikeSpeed(),uphill:t.getBikeUphill(),downhill:t.getBikeDownhill()}),"walk"==n&&(o.tm.walk={speed:t.getWalkSpeed(),uphill:t.getWalkUphill(),downhill:t.getWalkDownhill()}),i.sources.push(o)}),_.has(o.PolygonService.cache,JSON.stringify(i))?(t.getWaitControl()&&t.getWaitControl().hide(),e(o.Util.parsePolygons(o.PolygonService.cache[JSON.stringify(i)]))):$.getJSON(o.config.serviceUrl+o.config.serviceVersion+"/polygon?cfg="+encodeURIComponent(JSON.stringify(i))+"&cb=?&key="+o.config.serviceKey,function(n){o.PolygonService.cache[JSON.stringify(i)]=n,t.getWaitControl()&&t.getWaitControl().hide(),e(o.Util.parsePolygons(n))})}else alert("Travel options are not valid!"),console.log(t.getErrors())}},o.RouteService={cache:{},getRoutes:function(t,e){if(t.isValidRouteServiceOptions()){t.getWaitControl()&&t.getWaitControl().show();var i={sources:[],targets:[],pathSerializer:t.getPathSerializer()};_.each(t.getSources(),function(e){var o={lat:_.has(e,"lat")?e.lat:e.getLatLng().lat,lon:_.has(e,"lon")?e.lon:e.getLatLng().lng,id:_.has(e,"id")?e.id:e.lat+";"+e.lon,tm:{}},n=_.has(e,"travelType")?e.travelType:t.getTravelType();o.tm[n]={},"transit"==n&&(o.tm.transit.frame={time:t.getTime(),date:t.getDate()}),"bike"==n&&(o.tm.bike={speed:t.getBikeSpeed(),uphill:t.getBikeUphill(),downhill:t.getBikeDownhill()}),"walk"==n&&(o.tm.walk={speed:t.getWalkSpeed(),uphill:t.getWalkUphill(),downhill:t.getWalkDownhill()}),i.sources.push(o)}),i.targets=[],_.each(t.getTargets(),function(t){i.targets.push({lat:_.has(t,"lat")?t.lat:t.getLatLng().lat,lon:_.has(t,"lon")?t.lon:t.getLatLng().lng,id:_.has(t,"id")?t.id:t.lat+";"+t.lon})}),_.has(o.RouteService.cache,JSON.stringify(i))?(t.getWaitControl()&&t.getWaitControl().hide(),e(o.Util.parseRoutes(o.RouteService.cache[JSON.stringify(i)]))):$.getJSON(o.config.serviceUrl+o.config.serviceVersion+"/route?cfg="+encodeURIComponent(JSON.stringify(i))+"&cb=?&key="+o.config.serviceKey,function(n){o.RouteService.cache[JSON.stringify(i)]=n,t.getWaitControl()&&t.getWaitControl().hide(),e(o.Util.parseRoutes(n))})}else alert("Travel options are not valid!"),console.log(t.getErrors())}},o.TimeService={cache:{},getRouteTime:function(t,e){if(t.isValidTimeServiceOptions()){t.getWaitControl()&&t.getWaitControl().show();var i={sources:[],targets:[],pathSerializer:t.getPathSerializer(),maxRoutingTime:t.getMaxRoutingTime()};_.each(t.getSources(),function(e){console.log(e);var o={lat:_.has(e,"lat")?e.lat:e.getLatLng().lat,lon:_.has(e,"lon")?e.lon:e.getLatLng().lng,id:_.has(e,"id")?e.id:e.lat+";"+e.lon,tm:{}},n=_.has(e,"travelType")?e.travelType:t.getTravelType();o.tm[n]={},"transit"==n&&(o.tm.transit.frame={time:t.getTime(),date:t.getDate()}),"bike"==n&&(o.tm.bike={speed:t.getBikeSpeed(),uphill:t.getBikeUphill(),downhill:t.getBikeDownhill()}),"walk"==n&&(o.tm.walk={speed:t.getWalkSpeed(),uphill:t.getWalkUphill(),downhill:t.getWalkDownhill()}),i.sources.push(o)}),_.each(t.getTargets(),function(t){i.targets.push({lat:_.has(t,"lat")?t.lat:t.getLatLng().lat,lon:_.has(t,"lon")?t.lon:t.getLatLng().lng,id:_.has(t,"id")?t.id:t.lat+";"+t.lon})}),_.has(o.TimeService.cache,JSON.stringify(i))?(t.getWaitControl()&&t.getWaitControl().hide(),e(o.TimeService.cache[JSON.stringify(i)])):$.ajax({url:o.config.serviceUrl+o.config.serviceVersion+"/time?key="+o.config.serviceKey,type:"POST",data:JSON.stringify(i),contentType:"application/json",dataType:"json",success:function(n){o.TimeService.cache[JSON.stringify(i)]=n,t.getWaitControl()&&t.getWaitControl().hide(),e(n)},error:function(t,e,o){console.log(t.status),console.log(o)}})}else alert("Travel options are not valid!"),console.log(t.getErrors())}},o.placeAutoCompleteControl=function(t){return new o.PlaceAutoCompleteControl(t)},o.PlaceAutoCompleteControl=L.Control.extend({initialize:function(t){this.options=JSON.parse(JSON.stringify(o.config.defaultPlaceAutoCompleteOptions)),"undefined"!=typeof t&&(_.has(t,"position")&&(this.options.position=t.position),_.has(t,"label")&&(this.options.label=t.label),_.has(t,"country")&&(this.options.country=t.country),_.has(t,"reset")&&(this.options.reset=t.reset),_.has(t,"reverse")&&(this.options.reverse=t.reverse),_.has(t,"placeholder")&&(this.options.placeholder=t.placeholder),_.has(t,"width")&&(this.options.width=t.width),_.has(t,"maxRows")&&(this.options.maxRows=t.maxRows),_.has(t,"image")&&(this.options.image=t.image),_.has(t,"options")&&(this.options.options=t.options,this.options.travelType=_.has(this.options.options,"init")?this.options.options.init:"walk"))},onAdd:function(t){var e=this,i=o.config.i18n,n="",r=L.DomUtil.create("div",e._container);e.options.map=t,e.options.id=$(t._container).attr("id")+o.Util.generateId(10),t.on("resize",e.onResize.bind(e));var a=e.options.width;e.options.reset&&(a+=44),e.options.reverse&&(a+=37);var s='style="width:'+a+'px;"';e.options.input='
',e.options.image&&(e.options.input+=' ');var l=[];return e.options.options&&(e.options.input+=' ',l.push('")),e.options.reset&&(e.options.input+=' '),e.options.reverse&&(e.options.input+=' '),e.options.input+="
",e.options.options&&(e.options.input+=l.join("")),$(r).append(e.options.input),$(r).find("#"+e.options.id+"-reset").click(function(){e.options.onReset()}),$(r).find("#"+e.options.id+"-reverse").click(function(){e.options.onReverse()}),$(r).find("#"+e.options.id+"-options-button").click(function(){$("#"+e.options.id+"-options").slideToggle()}),$(r).find(".travel-type-button").click(function(){$(r).find(".travel-type-button").removeClass("active"),$(this).addClass("active"),setTimeout(function(){$("#"+e.options.id+"-options").slideToggle()},300),e.options.travelType=$(this).attr("travel-type"),e.options.onTravelTypeChange()}),L.DomEvent.disableClickPropagation(r),_.has(e.options,"country")&&(n+=" AND country:"+e.options.country),$(r).find("#autocomplete-"+e.options.id).autocomplete({source:function(t,o){e.source=this;for(var i=t.term.split(" "),r=new Array,a="",s="",l=0;l0){s+=" OR ";for(var p=0;p$&"):e.firstRow,n=e.term?e.secondRow.replace(new RegExp(o(e.term),"gi"),"$&"):e.secondRow,r=""+i+"
"+n+"
";return $("
  • ").append(r).appendTo(t)},this.onResize(),r},onSelect:function(t){this.options.onSelect=t},onReset:function(t){this.options.onReset=t},onReverse:function(t){this.options.onReverse=t},onTravelTypeChange:function(t){this.options.onTravelTypeChange=t},reset:function(){this.options.value={},this.setFieldValue("")},update:function(t,e){this.setLatLng(t),this.setFieldValue(e)},setLatLng:function(t){this.options.value.latlng=t},setFieldValue:function(t){var e=this;$("#autocomplete-"+e.options.id).val(t)},getFieldValue:function(){var t=this;return $("#autocomplete-"+t.options.id).val()},getTravelType:function(){return this.options.travelType},setValue:function(t){this.options.value=t},getValue:function(){return this.options.value},onResize:function(){var t=this;$(t.options.input).css(this.options.map.getSize().x<550?{width:"45px"}:{width:""})}}),o.TravelStartDateControl=L.Control.extend({options:{position:"topright",dateFormat:"yy-mm-dd",minDate:0},initialize:function(t){L.Util.setOptions(this,t)},onChange:function(t){this.options.onChange=t},onAdd:function(t){var e=this;e.options.map=t;var i=L.DomUtil.create("div","startDatePicker",this._container);e.datepicker=$("
    "),$(i).append(e.datepicker);var n={onSelect:function(){e.options.onChange(e.getValue())},firstDay:1},r=o.config.i18n;return"en"!=r.language&&(n.monthNames=r.monthNames[r.language],n.dayNames=r.dayNames[r.language],n.dayNamesMin=r.dayNamesMin[r.language]),$(e.datepicker).datepicker(n),L.DomEvent.disableClickPropagation(i),i},getValue:function(){var t=this,e=$(t.datepicker).datepicker({dateFormat:"dd-mm-yy"}).val(),o=e.split("/"),i=o[2]+""+o[0]+o[1];return i}}),o.travelStartDateControl=function(){return new o.TravelStartDateControl},o.TravelStartTimeControl=L.Control.extend({options:{position:"topright",range:!1,min:0,max:86400,step:600,initValue:28800,value:0},initialize:function(t){this.options.value=o.Util.getHoursAndMinutesInSeconds(),L.Util.setOptions(this,t)},onSlideStop:function(t){this.options.slideStop=t},minToString:function(t){t/=60;var e=Math.floor(t/60),o=t-60*e;return e>24&&(e-=24),10>e&&(e="0"+e),10>o&&(o="0"+o),0==o&&(o="00"),e+":"+o},onAdd:function(t){var e=this;e.options.map=t,e.options.mapId=$(t._container).attr("id"),t.on("resize",this.onResize.bind(this));var i=L.DomUtil.create("div","startTimeSlider",this._container);return e.miBox=$("
    ",{"class":"mi-box"}),e.startTimeInfo=$("
    "),e.label=$(""),e.slider=$("
    "),$(i).append(e.miBox.append(e.startTimeInfo.append(e.label)).append(e.slider)),$(e.label).text(o.config.i18n.get("departure")+": "+e.minToString(this.options.value)+" "+o.Util.getTimeFormat(e.options.value)),$(e.slider).slider({range:e.options.range,value:e.options.value,min:e.options.min,max:e.options.max,step:e.options.step,slide:function(t,i){$(e.label).text(o.config.i18n.get("departure")+": "+e.minToString(i.value)+" "+o.Util.getTimeFormat(i.value)),e.options.value=i.value},stop:function(t,o){e.options.slideStop(o.value)}}),this.onResize(),L.DomEvent.disableClickPropagation(i),i},onResize:function(){this.options.map.getSize().x<550?(this.removeAndAddClass(this.miBox,"leaflet-traveltime-slider-container-max","leaflet-traveltime-slider-container-min"),this.removeAndAddClass(this.startTimeInfo,"travel-time-info-max","travel-time-info-min"),this.removeAndAddClass(this.slider,"leaflet-traveltime-slider-max","leaflet-traveltime-slider-min")):(this.removeAndAddClass(this.miBox,"leaflet-traveltime-slider-container-min","leaflet-traveltime-slider-container-max"),this.removeAndAddClass(this.startTimeInfo,"travel-time-info-min","travel-time-info-max"),this.removeAndAddClass(this.slider,"leaflet-traveltime-slider-min","leaflet-traveltime-slider-max"))},removeAndAddClass:function(t,e,o){$(t).addClass(o),$(t).removeClass(e)},getValue:function(){return this.options.value}}),o.travelStartTimeControl=function(){return new o.TravelStartTimeControl},o.TravelTimeControl=L.Control.extend({initialize:function(t){this.options=JSON.parse(JSON.stringify(o.config.defaultTravelTimeControlOptions)),"undefined"!=typeof t&&(_.has(t,"position")&&(this.options.position=t.position),_.has(t,"initValue")&&(this.options.initValue=t.initValue),_.has(t,"label")&&(this.options.label=t.label),_.has(t,"travelTimes")&&(this.options.travelTimes=t.travelTimes),_.has(t,"icon")&&(this.options.icon=t.icon)),this.options.maxValue=_.max(this.options.travelTimes,function(t){return t.time}).time/60,this.options.step=(this.options.travelTimes[1].time-this.options.travelTimes[0].time)/60},onAdd:function(t){var e=this;this.options.map=t,t.on("resize",this.onResize.bind(this));for(var o="",i=100/this.options.travelTimes.length,n=0;n
    ':n
    ':n==this.options.travelTimes.length-1&&(o+='
    ');this.options.sliderContainer=L.DomUtil.create("div",this._container),this.options.miBox=$("
    ",{"class":"mi-box"}),this.options.travelTimeInfo=$("
    "),this.options.travelTimeSlider=$("
    ",{"class":"no-border"}).append(o);var r=$("
    ",{"class":"ui-slider-handle"});this.options.labelSpan='TraveltimeReisezeit: ',"undefined"!=this.options.icon&&(this.options.iconHTML=$("",{src:this.options.icon})),this.options.travelTimeSpan=$("",{text:this.options.initValue});var a=$("",{text:"min"});return $(this.options.sliderContainer).append(this.options.miBox),this.options.miBox.append(this.options.travelTimeInfo),this.options.miBox.append(this.options.travelTimeSlider),this.options.travelTimeSlider.append(r),this.options.travelTimeInfo.append(this.options.iconHTML).append(this.options.labelSpan).append(this.options.travelTimeSpan).append(a),$(this.options.travelTimeSlider).slider({range:!1,value:e.options.initValue,min:0,max:e.options.maxValue,step:e.options.step,slide:function(t,o){return 0==o.value?!1:void $(e.options.travelTimeSpan).text(o.value)},stop:function(t,o){for(var i=new Array,n=0;n '+o.config.i18n.get("wait")+"
    "),e -},show:function(){$("#wait-control-"+this.options.mapId).show()},hide:function(){$("#wait-control-"+this.options.mapId).hide()}}),o.htmlControl=function(t){return new L.Control.HtmlControl(t)},L.Control.HtmlControl=L.Control.extend({options:{position:"topleft"},initialize:function(t){L.Util.setOptions(this,t)},onAdd:function(t){this.options.id=$(t._container).attr("id")+o.Util.generateId();var e=L.DomUtil.create("div","leaflet-control-html");return $(e).append('
    '),$(e).on("mouseover",function(){t.scrollWheelZoom.disable()}),$(e).on("mouseout",function(){t.scrollWheelZoom.enable()}),e},setHtml:function(t){$("#html-control-"+this.options.id).html(t)},show:function(){$("#html-control-"+this.options.id).show()},hide:function(){$("#html-control-"+this.options.id).hide()},toggle:function(){$("#html-control-"+this.options.id).toggle()}}),o.RadioButtonControl=L.Control.extend({initialize:function(t){this.options=JSON.parse(JSON.stringify(o.config.defaultRadioOptions)),"undefined"!=typeof t&&("undefined"!=typeof t.position&&(this.options.position=t.position),"undefined"!=typeof t.buttons?this.options.buttons=t.buttons:alert("No buttons supplied!"))},onAdd:function(t){var e=this;this.options.map=t;var o=L.DomUtil.create("div",this._container);return this.options.input=this.getRadioButtonHTML(),$(o).append(this.options.input),$(this.options.input).buttonset({}).change(function(){e.options.checked=$("input[name='r360_radiobuttongroup_"+e.options.buttonGroupId+"']:checked").attr("key"),e.options.onChange(e.options.checked)}),$(this.options.input).each(function(){$(this).tooltip({position:{my:"center top+10",at:"center bottom",using:function(t,e){$(this).css(t),$("
    ").addClass("arrow top").addClass(e.vertical).addClass(e.horizontal).appendTo(this)}}})}),L.DomEvent.addListener(o,"click",L.DomEvent.stopPropagation),o},onChange:function(t){this.options.onChange=t},getValue:function(){return this.options.checked},getRadioButtonHTML:function(){var t=this;t.options.buttonGroupId=o.Util.generateId(5);var e=$("
    ",{id:t.options.buttonGroupId});return _.each(t.options.buttons,function(i){var n=o.Util.generateId(),r=$("",{type:"radio",id:"r360_"+n,value:i.key,key:i.key,name:"r360_radiobuttongroup_"+t.options.buttonGroupId}),a=$("
  • ").append(r).appendTo(t)},this.onResize(),r},onSelect:function(t){this.options.onSelect=t},onReset:function(t){this.options.onReset=t},onReverse:function(t){this.options.onReverse=t},onTravelTypeChange:function(t){this.options.onTravelTypeChange=t},reset:function(){this.options.value={},this.setFieldValue("")},update:function(t,e){this.setLatLng(t),this.setFieldValue(e)},setLatLng:function(t){this.options.value.latlng=t},setFieldValue:function(t){var e=this;$("#autocomplete-"+e.options.id).val(t)},getFieldValue:function(){var t=this;return $("#autocomplete-"+t.options.id).val()},getTravelType:function(){return this.options.travelType},setValue:function(t){this.options.value=t},getValue:function(){return this.options.value},onResize:function(){var t=this;$(t.options.input).css(this.options.map.getSize().x<550?{width:"45px"}:{width:""})}}),o.TravelStartDateControl=L.Control.extend({options:{position:"topright",dateFormat:"yy-mm-dd",minDate:0},initialize:function(t){L.Util.setOptions(this,t)},onChange:function(t){this.options.onChange=t},onAdd:function(t){var e=this;e.options.map=t;var i=L.DomUtil.create("div","startDatePicker",this._container);e.datepicker=$("
    "),$(i).append(e.datepicker);var n={onSelect:function(){e.options.onChange(e.getValue())},firstDay:1},r=o.config.i18n;return"en"!=r.language&&(n.monthNames=r.monthNames[r.language],n.dayNames=r.dayNames[r.language],n.dayNamesMin=r.dayNamesMin[r.language]),$(e.datepicker).datepicker(n),L.DomEvent.disableClickPropagation(i),i},getValue:function(){var t=this,e=$(t.datepicker).datepicker({dateFormat:"dd-mm-yy"}).val(),o=e.split("/"),i=o[2]+""+o[0]+o[1];return i}}),o.travelStartDateControl=function(){return new o.TravelStartDateControl},o.TravelStartTimeControl=L.Control.extend({options:{position:"topright",range:!1,min:0,max:86400,step:600,initValue:28800,value:0},initialize:function(t){this.options.value=o.Util.getHoursAndMinutesInSeconds(),L.Util.setOptions(this,t)},onSlideStop:function(t){this.options.slideStop=t},minToString:function(t){t/=60;var e=Math.floor(t/60),o=t-60*e;return e>24&&(e-=24),10>e&&(e="0"+e),10>o&&(o="0"+o),0==o&&(o="00"),e+":"+o},onAdd:function(t){var e=this;e.options.map=t,e.options.mapId=$(t._container).attr("id"),t.on("resize",this.onResize.bind(this));var i=L.DomUtil.create("div","startTimeSlider",this._container);return e.miBox=$("
    ",{"class":"mi-box"}),e.startTimeInfo=$("
    "),e.label=$(""),e.slider=$("
    "),$(i).append(e.miBox.append(e.startTimeInfo.append(e.label)).append(e.slider)),$(e.label).text(o.config.i18n.get("departure")+": "+e.minToString(this.options.value)+" "+o.Util.getTimeFormat(e.options.value)),$(e.slider).slider({range:e.options.range,value:e.options.value,min:e.options.min,max:e.options.max,step:e.options.step,slide:function(t,i){$(e.label).text(o.config.i18n.get("departure")+": "+e.minToString(i.value)+" "+o.Util.getTimeFormat(i.value)),e.options.value=i.value},stop:function(t,o){e.options.slideStop(o.value)}}),this.onResize(),L.DomEvent.disableClickPropagation(i),i},onResize:function(){this.options.map.getSize().x<550?(this.removeAndAddClass(this.miBox,"leaflet-traveltime-slider-container-max","leaflet-traveltime-slider-container-min"),this.removeAndAddClass(this.startTimeInfo,"travel-time-info-max","travel-time-info-min"),this.removeAndAddClass(this.slider,"leaflet-traveltime-slider-max","leaflet-traveltime-slider-min")):(this.removeAndAddClass(this.miBox,"leaflet-traveltime-slider-container-min","leaflet-traveltime-slider-container-max"),this.removeAndAddClass(this.startTimeInfo,"travel-time-info-min","travel-time-info-max"),this.removeAndAddClass(this.slider,"leaflet-traveltime-slider-min","leaflet-traveltime-slider-max"))},removeAndAddClass:function(t,e,o){$(t).addClass(o),$(t).removeClass(e)},getValue:function(){return this.options.value}}),o.travelStartTimeControl=function(){return new o.TravelStartTimeControl},o.TravelTimeControl=L.Control.extend({initialize:function(t){this.options=JSON.parse(JSON.stringify(o.config.defaultTravelTimeControlOptions)),"undefined"!=typeof t&&(_.has(t,"position")&&(this.options.position=t.position),_.has(t,"initValue")&&(this.options.initValue=t.initValue),_.has(t,"label")&&(this.options.label=t.label),_.has(t,"travelTimes")&&(this.options.travelTimes=t.travelTimes),_.has(t,"icon")&&(this.options.icon=t.icon)),this.options.maxValue=_.max(this.options.travelTimes,function(t){return t.time}).time/60,this.options.step=(this.options.travelTimes[1].time-this.options.travelTimes[0].time)/60},onAdd:function(t){var e=this;this.options.map=t,t.on("resize",this.onResize.bind(this));for(var o="",i=100/this.options.travelTimes.length,n=0;n
    ':n
    ':n==this.options.travelTimes.length-1&&(o+='
    ');this.options.sliderContainer=L.DomUtil.create("div",this._container),this.options.miBox=$("
    ",{"class":"mi-box"}),this.options.travelTimeInfo=$("
    "),this.options.travelTimeSlider=$("
    ",{"class":"no-border"}).append(o);var r=$("
    ",{"class":"ui-slider-handle"});this.options.labelSpan='TraveltimeReisezeit: ',"undefined"!=this.options.icon&&(this.options.iconHTML=$("",{src:this.options.icon})),this.options.travelTimeSpan=$("",{text:this.options.initValue});var a=$("",{text:"min"});return $(this.options.sliderContainer).append(this.options.miBox),this.options.miBox.append(this.options.travelTimeInfo),this.options.miBox.append(this.options.travelTimeSlider),this.options.travelTimeSlider.append(r),this.options.travelTimeInfo.append(this.options.iconHTML).append(this.options.labelSpan).append(this.options.travelTimeSpan).append(a),$(this.options.travelTimeSlider).slider({range:!1,value:e.options.initValue,min:0,max:e.options.maxValue,step:e.options.step,slide:function(t,o){return 0==o.value?!1:void $(e.options.travelTimeSpan).text(o.value)},stop:function(t,o){for(var i=new Array,n=0;n '+o.config.i18n.get("wait")+"
    "),e},show:function(){$("#wait-control-"+this.options.mapId).show()},hide:function(){$("#wait-control-"+this.options.mapId).hide()}}),o.htmlControl=function(t){return new L.Control.HtmlControl(t)},L.Control.HtmlControl=L.Control.extend({options:{position:"topleft"},initialize:function(t){L.Util.setOptions(this,t)},onAdd:function(t){this.options.id=$(t._container).attr("id")+o.Util.generateId();var e=L.DomUtil.create("div","leaflet-control-html");return $(e).append('
    '),$(e).on("mouseover",function(){t.scrollWheelZoom.disable()}),$(e).on("mouseout",function(){t.scrollWheelZoom.enable()}),e},setHtml:function(t){$("#html-control-"+this.options.id).html(t)},show:function(){$("#html-control-"+this.options.id).show()},hide:function(){$("#html-control-"+this.options.id).hide()},toggle:function(){$("#html-control-"+this.options.id).toggle()}}),o.RadioButtonControl=L.Control.extend({initialize:function(t){this.options=JSON.parse(JSON.stringify(o.config.defaultRadioOptions)),"undefined"!=typeof t&&("undefined"!=typeof t.position&&(this.options.position=t.position),"undefined"!=typeof t.buttons?this.options.buttons=t.buttons:alert("No buttons supplied!"))},onAdd:function(t){var e=this;this.options.map=t;var o=L.DomUtil.create("div",this._container);return this.options.input=this.getRadioButtonHTML(),$(o).append(this.options.input),$(this.options.input).buttonset({}).change(function(){e.options.checked=$("input[name='r360_radiobuttongroup_"+e.options.buttonGroupId+"']:checked").attr("key"),e.options.onChange(e.options.checked)}),$(this.options.input).each(function(){$(this).tooltip({position:{my:"center top+10",at:"center bottom",using:function(t,e){$(this).css(t),$("
    ").addClass("arrow top").addClass(e.vertical).addClass(e.horizontal).appendTo(this)}}})}),L.DomEvent.addListener(o,"click",L.DomEvent.stopPropagation),o},onChange:function(t){this.options.onChange=t},getValue:function(){return this.options.checked},getRadioButtonHTML:function(){var t=this;t.options.buttonGroupId=o.Util.generateId(5);var e=$("
    ",{id:t.options.buttonGroupId});return _.each(t.options.buttons,function(i){var n=o.Util.generateId(),r=$("",{type:"radio",id:"r360_"+n,value:i.key,key:i.key,name:"r360_radiobuttongroup_"+t.options.buttonGroupId}),a=$("