<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">var map_lib=function(t){function e(o){if(i[o])return i[o].exports;var n=i[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){t.exports=i},,,,function(t,e,i){"use strict";i(28),i(13),i(9),i(14),i(12),i(16),i(15),i(11),i(10),i(26),i(17)},,,function(t,e){"use strict";!function(){var e,i,o,n;e=function(t,e){this.name="Default",this.undo=e,this.execute=t,this.next=this.prev=null},i=function(t,e){this.name="RouteSnapshot",this.map=t,this.serialized=e},i.prototype.restore=function(){if(this.map.clearMap(),this.map.routes=[],this.serialized.routes){var t=this.map;_.each(this.serialized.routes,function(e){var i=new rwgps.Route(e,this.map,{planning:!0});i.routeData=e.routeData,i.tripData=e.tripData,e.active?t.addRoute(i,!0):t.addRoute(i)},this)}else this.map.loadRouteForEdit(this.serialized,!0);this.map.saveSnapshotLocally(this)},i.prototype.execute=i.prototype.restore,o=function(){this.actions=_.toArray(arguments),this.next=this.prev=null},_.extend(o.prototype,{undo:function(){for(var t=this.actions.length-1;t&gt;=0;--t)this.actions[t].undo()},execute:function(){for(var t=0;t&lt;this.actions.length;++t)this.actions[t].execute()}}),n=function(){this.curr=null},_.extend(n.prototype,{printDebug:function(){var t,e=this.curr;if(!e)return void console.log("EMPTY ACTIONS");for(;e.prev;)e=e.prev;do t=this.curr===e,console.log("NAME "+e.name,"UNDO "+!!e.undo,"REDO "+!!e.execute,"NEXT "+!!e.next,"PREV "+!!e.prev,"ISLAST? "+t);while(e=e.next)},execute:function(t){t.execute(),this.add(t)},clear:function(){this.curr=null},chain:function(t){this.curr?this.curr.restore&amp;&amp;t.restore?this.curr.serialized=t.serialized:console.warn("Need to implement use of ActionChain for non-snapshot chaining"):this.add(t)},add:function(t){(t.undo||this.curr&amp;&amp;this.curr.restore)&amp;&amp;(t.prev=this.curr,this.curr&amp;&amp;(this.curr.next=t)),this.curr=t},manualUndoTo:function(t){this.curr&amp;&amp;(this.curr.prev&amp;&amp;(this.curr.prev.next=t,t.prev=this.curr.prev),this.curr.prev=t,t.next=this.curr),this.curr=t},noopAction:function t(i){var t=new e(function(){});return t.name="noop",t.next=i,t},canUndo:function(){return this.curr&amp;&amp;(this.curr.prev&amp;&amp;this.curr.prev.restore||this.curr.undo)},revert:function(){this.curr&amp;&amp;this.curr.restore&amp;&amp;this.curr.restore()},undo:function(){this.curr&amp;&amp;(this.curr.prev&amp;&amp;this.curr.prev.restore?(this.curr=this.curr.prev,this.curr.restore()):this.curr.undo&amp;&amp;(this.curr.undo(),this.curr.prev?this.curr=this.curr.prev:this.curr=this.noopAction(this.curr)))},redo:function(){this.curr&amp;&amp;this.curr.next&amp;&amp;(this.curr=this.curr.next,this.curr.execute())}}),t.exports={Action:e,RouteSnapshot:i,ActionChain:o,ActionsManager:n}}()},,function(t,e){"use strict";rwgps=window.rwgps||{},rwgps.BaseMap=function(){},rwgps.BaseMap.prototype={setProvider:function(t,e){this.provider=t,this.map=e,rwgps.Events.trigger("maps:provider:changed",t,e)}}},function(t,e){"use strict";rwgps=window.rwgps||{},rwgps.Bitmask=function(){},rwgps.Bitmask.prototype={getSetGroupOption:function(t){var e;return _.each(this.stuff,function(i,o){i.group==t&amp;&amp;i.val&gt;0&amp;&amp;(e=o)}),e},setOptions:function(t){_.each(this.stuff,function(e){e.val=t&amp;e.mask})},getOptions:function(){var t=0;return _.each(this.stuff,function(e){t|=e.val}),t},setOption:function(t,e){var i=this.stuff[t];i&amp;&amp;(i.group&amp;&amp;_.each(this.stuff,function(t){t.group==i.group&amp;&amp;(t.val=0)}),i.val=e?i.mask:0)},getOption:function(t){return this.stuff[t].val&amp;this.stuff[t].mask}},rwgps.Bitmask.Planner=function(t){this.stuff={roadmap:{mask:1,val:1,group:"basemaps"},terrain:{mask:2,val:0,group:"basemaps"},satellite:{mask:4,val:0,group:"basemaps"},hybrid:{mask:8,val:0,group:"basemaps"},rwgps:{mask:16,val:0,group:"basemaps"},osm:{mask:32,val:0,group:"basemaps"},osmCycle:{mask:64,val:0,group:"basemaps"},esriTopo:{mask:128,val:0,group:"basemaps"},usgsTopo:{mask:256,val:0,group:"basemaps"},giTopo:{mask:512,val:0,group:"basemaps"},osmOutdoor:{mask:1024,val:0,group:"basemaps"},usgsTopoLegacy:{mask:2048,val:0,group:"basemaps"},gmapsBikeOverlay:{mask:8192,val:0},giSkiOverlay:{mask:16384,val:0},overrideUnits:{mask:32768,val:0},metricUnits:{mask:65536,val:0}},t&amp;&amp;this.setOptions(t)},rwgps.Bitmask.Planner.prototype=new rwgps.Bitmask,rwgps.ClickOptions=function(t){this.CYCLING_MODE_MASK=1,this.WALKING_MODE_MASK=2,this.DRIVING_MODE_MASK=4,this.AVOID_HIGHWAYS_MASK=8,this.FOLLOW_ROADS_MASK=16,this.AVOID_TUNNELS_MASK=32,this.GMAPS_MASK=64,this.OSM_MASK=128,this.ARCGIS_MASK=256,this.GI_MASK=512,this.AVOID_CARS_ONLY_MASK=1024,this.AVOID_FERRIES_MASK=2048,this.AVOID_ONEWAYS_MASK=4096,this.AVOID_DIRT_ROADS_MASK=8192,this.AVOID_TRAILS_MASK=16384,this.AVOID_WATER_MASK=32768,this.CYCLING_EXPERIMENT_MODE_MASK=65536,this._cyclingMode=this.CYCLING_MODE_MASK,this._cyclingExperimentMode=0,this._walkingMode=0,this._drivingMode=0,this._avoidHighways=0,this._avoidTunnels=0,this._avoidCarsOnly=0,this._avoidFerries=0,this._avoidOneWays=0,this._avoidTrails=0,this._avoidDirtRoads=0,this._avoidWater=0,this._followRoads=this.FOLLOW_ROADS_MASK,this._gmaps=this.GMAPS_MASK,this._osm=0,this._arcgis=0,this._gi=0,void 0!==t&amp;&amp;this.setOptions(t)},rwgps.ClickOptions.prototype={setOptions:function(t){this._cyclingMode=t&amp;this.CYCLING_MODE_MASK,this._cyclingExperimentMode=t&amp;this.CYCLING_EXPERIMENT_MODE_MASK,this._walkingMode=t&amp;this.WALKING_MODE_MASK,this._drivingMode=t&amp;this.DRIVING_MODE_MASK,this._avoidOneWays=t&amp;this.AVOID_ONEWAYS_MASK,this._avoidHighways=t&amp;this.AVOID_HIGHWAYS_MASK,this._avoidTunnels=t&amp;this.AVOID_TUNNELS_MASK,this._avoidFerries=t&amp;this.AVOID_FERRIES_MASK,this._avoidDirtRoads=t&amp;this.AVOID_DIRT_ROADS_MASK,this._avoidTrails=t&amp;this.AVOID_TRAILS_MASK,this._avoidCarsOnly=t&amp;this.AVOID_CARS_ONLY_MASK,this._avoidWater=t&amp;this.AVOID_WATER_MASK,this._followRoads=t&amp;this.FOLLOW_ROADS_MASK,this._gmaps=t&amp;this.GMAPS_MASK,this._osm=t&amp;this.OSM_MASK,this._arcgis=t&amp;this.ARCGIS_MASK,this._gi=t&amp;this.GI_MASK,0==(this._cyclingMode|this._cyclingExperimentMode|this._walkingMode|this._drivingMode)&amp;&amp;(this._drivingMode=1),0==(this._gi|this._arcgis|this._osm|this._gmaps)&amp;&amp;(this._gmaps=this.GMAPS_MASK)},setPartialOptions:function(t){t&amp;this.CYCLING_MODE_MASK&amp;&amp;(this._cyclingMode=t&amp;this.CYCLING_MODE_MASK),t&amp;this.CYCLING_EXPERIMENT_MODE_MASK&amp;&amp;(this._cyclingExperimentMode=t&amp;this.CYCLING_EXPERIMENT_MODE_MASK),t&amp;this.WALKING_MODE_MASK&amp;&amp;(this._walkingMode=t&amp;this.WALKING_MODE_MASK),t&amp;this.DRIVING_MODE_MASK&amp;&amp;(this._drivingMode=t&amp;this.DRIVING_MODE_MASK),t&amp;this.AVOID_ONEWAYS_MASK&amp;&amp;(this._avoidOneWays=t&amp;this.AVOID_ONEWAYS_MASK),t&amp;this.AVOID_HIGHWAYS_MASK&amp;&amp;(this._avoidHighways=t&amp;this.AVOID_HIGHWAYS_MASK),t&amp;this.AVOID_TUNNELS_MASK&amp;&amp;(this._avoidTunnels=t&amp;this.AVOID_TUNNELS_MASK),t&amp;this.AVOID_FERRIES_MASK&amp;&amp;(this._avoidFerries=t&amp;this.AVOID_FERRIES_MASK),t&amp;this.AVOID_DIRT_ROADS_MASK&amp;&amp;(this._avoidDirtRoads=t&amp;this.AVOID_DIRT_ROADS_MASK),t&amp;this.AVOID_TRAILS_MASK&amp;&amp;(this._avoidTrails=t&amp;this.AVOID_TRAILS_MASK),t&amp;this.AVOID_CARS_ONLY_MASK&amp;&amp;(this._avoidCarsOnly=t&amp;this.AVOID_CARS_ONLY_MASK),t&amp;this.AVOID_WATER_MASK&amp;&amp;(this._avoidWater=t&amp;this.AVOID_WATER_MASK),t&amp;this.FOLLOW_ROADS_MASK&amp;&amp;(this._followRoads=t&amp;this.FOLLOW_ROADS_MASK),t&amp;this.GMAPS_MASK&amp;&amp;(this._gmaps=t&amp;this.GMAPS_MASK),t&amp;this.OSM_MASK&amp;&amp;(this._osm=t&amp;this.OSM_MASK),t&amp;this.ARCGIS_MASK&amp;&amp;(this._arcgis=t&amp;this.ARCGIS_MASK),t&amp;this.GI_MASK&amp;&amp;(this._gi=t&amp;this.GI_MASK)},getProviderOptions:function(){return this._gmaps&amp;this.GMAPS_MASK|this._osm&amp;this.OSM_MASK|this._arcgis&amp;this.ARCGIS_MASK|this._gi&amp;this.GI_MASK},getRestrictionOptions:function(){return this._avoidOneWays&amp;this.AVOID_ONEWAYS_MASK|this._avoidHighways&amp;this.AVOID_HIGHWAYS_MASK|this._avoidTunnels&amp;this.AVOID_TUNNELS_MASK|this._avoidFerries&amp;this.AVOID_FERRIES_MASK|this._avoidDirtRoads&amp;this.AVOID_DIRT_ROADS_MASK|this._avoidTrails&amp;this.AVOID_TRAILS_MASK|this._avoidCarsOnly&amp;this.AVOID_CARS_ONLY_MASK|this._avoidWater&amp;this.AVOID_WATER_MASK},getModeOptions:function(){return this._cyclingMode&amp;this.CYCLING_MODE_MASK|this._cyclingExperimentMode&amp;this.CYCLING_EXPERIMENT_MODE_MASK|this._walkingMode&amp;this.WALKING_MODE_MASK|this._drivingMode&amp;this.DRIVING_MODE_MASK|this._followRoads&amp;this.FOLLOW_ROADS_MASK},getOptions:function(){return this.getModeOptions()|this.getRestrictionOptions()|this.getProviderOptions()},getOption:function(t){switch(t){case"avoidHighways":return this._avoidHighways&amp;this.AVOID_HIGHWAYS_MASK;case"avoidTunnels":return this._avoidTunnels&amp;this.AVOID_TUNNELS_MASK;case"avoidOneWays":return this._avoidOneWays&amp;this.AVOID_ONEWAYS_MASK;case"avoidFerries":return this._avoidFerries&amp;this.AVOID_FERRIES_MASK;case"avoidDirtRoads":return this._avoidDirtRoads&amp;this.AVOID_DIRT_ROADS_MASK;case"avoidTrails":return this._avoidTrails&amp;this.AVOID_TRAILS_MASK;case"avoidCarsOnly":return this._avoidCarsOnly&amp;this.AVOID_CARS_ONLY_MASK;case"avoidWater":return this._avoidWater&amp;this.AVOID_WATER_MASK}return!1},setOption:function(t,e){switch(t){case"avoidHighways":this._avoidHighways=e?this.AVOID_HIGHWAYS_MASK:0;break;case"avoidTunnels":this._avoidTunnels=e?this.AVOID_TUNNELS_MASK:0;break;case"avoidOneWays":this._avoidOneWays=e?this.AVOID_ONEWAYS_MASK:0;break;case"avoidFerries":this._avoidFerries=e?this.AVOID_FERRIES_MASK:0;break;case"avoidDirtRoads":this._avoidDirtRoads=e?this.AVOID_DIRT_ROADS:0;break;case"avoidTrails":this._avoidTrails=e?this.AVOID_TRAILS_MASK:0;break;case"avoidCarsOnly":this._avoidCarsOnly=e?this.AVOID_CARS_ONLY_MASK:0;break;case"avoidWater":this._avoidWater=e?this.AVOID_WATER_MASK:0}},getEnabledRestrictions:function(){var t=[];return this._avoidHighways&amp;&amp;t.push("avoidHighways"),this._avoidTunnels&amp;&amp;t.push("avoidTunnels"),this._avoidOneWays&amp;&amp;t.push("avoidTunnels"),this._avoidFerries&amp;&amp;t.push("avoidFerries"),this._avoidDirtRoads&amp;&amp;t.push("avoidDirtRoads"),this._avoidTrails&amp;&amp;t.push("avoidTrails"),this._avoidCarsOnly&amp;&amp;t.push("avoidCarsOnly"),this._avoidWater&amp;&amp;t.push("avoidWater"),t},avoidWater:function(t){return void 0===t?this._avoidWater&gt;0:void(this._avoidWater=t?this.AVOID_WATER_MASK:0)},avoidOneWays:function(t){return void 0===t?this._avoidOneWays&gt;0:void(this._avoidOneWays=t?this.AVOID_ONEWAYS_MASK:0)},avoidHighways:function(t){return void 0===t?this._avoidHighways&gt;0:void(this._avoidHighways=t?this.AVOID_HIGHWAYS_MASK:0)},avoidTunnels:function(t){return void 0===t?this._avoidTunnels&gt;0:void(this._avoidTunnels=t?this.AVOID_TUNNELS_MASK:0)},avoidFerries:function(t){return void 0===t?this._avoidFerries&gt;0:void(this._avoidFerries=t?this.AVOID_FERRIES_MASK:0)},avoidDirtRoads:function(t){return void 0===t?this._avoidDirtRoads&gt;0:void(this._avoidDirtRoads=t?this.AVOID_DIRT_ROADS_MASK:0)},avoidTrails:function(t){return void 0===t?this._avoidTrails&gt;0:void(this._avoidTrails=t?this.AVOID_TRAILS_MASK:0)},avoidCarsOnly:function(t){return void 0===t?this._avoidCarsOnly&gt;0:void(this._avoidCarsOnly=t?this.AVOID_CARS_ONLY_MASK:0)},followRoads:function(t){return void 0===t?this._followRoads&gt;0:void(this._followRoads=t?this.FOLLOW_ROADS_MASK:0)},walkingMode:function(t){return void 0===t?this._walkingMode&gt;0:void(t&amp;&amp;(this._walkingMode=this.WALKING_MODE_MASK,this._cyclingExperimentMode=0,this._cyclingMode=0,this._drivingMode=0))},cyclingMode:function(t){return void 0===t?this._cyclingMode&gt;0:void(t&amp;&amp;(this._walkingMode=0,this._cyclingExperimentMode=0,this._cyclingMode=this.CYCLING_MODE_MASK,this._drivingMode=0))},cyclingExperimentMode:function(t){return void 0===t?this._cyclingExperimentMode&gt;0:void(t&amp;&amp;(this._walkingMode=0,this._cyclingExperimentMode=this.CYCLING_EXPERIMENT_MODE_MASK,this._cyclingMode=0,this._drivingMode=0))},drivingMode:function(t){return void 0===t?this._drivingMode&gt;0:void(t&amp;&amp;(this._walkingMode=0,this._cyclingMode=0,this._cyclingExperimentMode=0,this._drivingMode=this.DRIVING_MODE_MASK))},googleRouting:function(t){return void 0===t?this._gmaps&gt;0:(this._gmaps=this.GMAPS_MASK,this._osm=0,this._gi=0,void(this._arcgis=0))},osmRouting:function(t){return void 0===t?this._osm&gt;0:(this._gmaps=0,this._osm=this.OSM_MASK,this._gi=0,void(this._arcgis=0))},arcgisRouting:function(t){return void 0===t?this._arcgis&gt;0:(this._gmaps=0,this._osm=0,this._gi=0,void(this._arcgis=this.ARCGIS_MASK))},giRouting:function(t){return void 0===t?this._gi&gt;0:(this._gmaps=0,this._osm=0,this._gi=this.GI_MASK,void(this._arcgis=0))}}},function(t,e){"use strict";rwgps=window.rwgps||{},rwgps.Router=function(t){if(this.opts=t,t)switch(t.type){case"google":if(!window.rwgps.config.labs.always_graph_hopper)return new rwgps.Router.Google(t);case"rwgps":return new rwgps.Router.RWGPSCombined(t);case"arcgis":return new rwgps.Router.ArcGIS(t)}},rwgps.Router.euclideanDistance=function(t,e){return Math.pow(Math.pow(t.lat-e.lat,2)+Math.pow(t.lng-e.lng,2),.5)},rwgps.Router.prototype={cleanupNotes:function(t){var e=/&lt;div.*?&gt;(.*?)&lt;\/div&gt;/gi,i=/&lt;\/?b&gt;/gi,o=/take the (.*?) (right|left)/gi,n=/&lt;wbr\/&gt;/g;return t=t.replace(e,"").replace(i,"").replace(o,"Turn $2").replace(n,"â€‹")},extractTypeFromNotes:function(t){var e=t.split(" "),i=null,o=!0,n=!1,s=void 0;try{for(var r,a=e[Symbol.iterator]();!(o=(r=a.next()).done);o=!0){var l=r.value;if(l.match(/^(left|venstre|vÃ¤nster|vasemmalle|linksaf|links|Î±ÏÎ¹ÏƒÏ„ÎµÏÎ¬|izquierda|esquerda|gauche|sinistra|Ð»ÐµÐ²Ð¾|Ð½Ð°Ð»ÐµÐ²Ð¾|leve|levo|lewo|å·¦)[\.,]?$/i)||l.match(/å·¦/i)){i="Left";break}if(l.match(/^(right|hÃ¸yre|hÃ¸jre|hÃ¶ger|oikealle|rechtsaf|rechts|Î´ÎµÎ¾Î¹Î¬|derecha|direita|droite|destra|Ð¿Ñ€Ð²Ð¾|Ð½Ð°Ð¿Ñ€Ð°Ð²Ð¾|Ð´ÐµÑÐ½Ð¾|desno|desne|prawo|å³)[\.,]?$/i)||l.match(/å³/i)){i="Right";break}}}catch(t){n=!0,s=t}finally{try{!o&amp;&amp;a.return&amp;&amp;a.return()}finally{if(n)throw s}}return null==i&amp;&amp;(i="Straight"),i},removeDuplicates:function(t){for(var e=[],i=0;i&lt;t.length;i++){var o=t[i],n=t[i-1];n&amp;&amp;n.point.lat==o.point.lat&amp;&amp;n.point.lng==o.point.lng||e.push(o)}return e},decodePath:function(t){for(var e=t.length,i=0,o=[],n=0,s=0,r=0,a=0,l=0;i&lt;e;){var h,p=0,c=0;do h=t.charCodeAt(i++)-63,c|=(31&amp;h)&lt;&lt;p,p+=5;while(h&gt;=32);var g=1&amp;c?~(c&gt;&gt;1):c&gt;&gt;1;n+=g,p=0,c=0;do h=t.charCodeAt(i++)-63,c|=(31&amp;h)&lt;&lt;p,p+=5;while(h&gt;=32);var u=1&amp;c?~(c&gt;&gt;1):c&gt;&gt;1;s+=u,p=0,c=0;do h=t.charCodeAt(i++)-63,c|=(31&amp;h)&lt;&lt;p,p+=5;while(h&gt;=32);var d=1&amp;c?~(c&gt;&gt;1):c&gt;&gt;1;r+=d,p=0,c=0;do h=t.charCodeAt(i++)-63,c|=(31&amp;h)&lt;&lt;p,p+=5;while(h&gt;=32);var v=1&amp;c?~(c&gt;&gt;1):c&gt;&gt;1;a+=v,p=0,c=0;do h=t.charCodeAt(i++)-63,c|=(31&amp;h)&lt;&lt;p,p+=5;while(h&gt;=32);var m=1&amp;c?~(c&gt;&gt;1):c&gt;&gt;1;l+=m;var f=[1e-5*n,1e-5*s,.1*r,.1*a,l];o.push(f)}return o}},rwgps.Router.ArcGIS=function(t){this.opts=t,this.routingUrl=t.url,this.language=t.language,this.token=t.token,this.attributes=t.attributes},rwgps.Router.ArcGIS.prototype=new rwgps.Router,rwgps.Router.ArcGIS.prototype.getDirections=function(t,e,i,o,n){for(var s,r=[],a=this,l="",h=this.language||"en_US",p=0;p&lt;t.length;p++)r.push({geometry:{x:t[p].lng,y:t[p].lat,spatialReference:{wkid:4326}}});for(var c=e.getEnabledRestrictions(),g=0;g&lt;c.length;g++){var u=this.attributes[c[g]];u&amp;&amp;(l.length&gt;0&amp;&amp;","!=l[l.length-1]&amp;&amp;(l+=","),l+=u)}s=e.walkingMode()?this.opts.modes.walking.cost:e.cyclingMode()?this.opts.modes.cycling.cost:this.opts.modes.driving.cost,$.ajax({url:this.routingUrl+"/solve",data:{stops:JSON.stringify({type:"features",features:r}),returnRoutes:!0,returnDirections:!0,directionsLengthUnits:"esriNAUMeters",returnBarriers:!1,returnStops:!1,preserveFirstStop:!1,preserveLastStop:!1,outputGeometryPrecision:3,outputGeometryPrecisionUnits:"esriMeters",outputLines:"esriNAOutputLineTrueShape",restrictionAttributeNames:l,impedanceAttributeName:s,outSR:4326,directionsLanguage:h,token:this.token?this.token:"",f:"json"},dataType:"jsonp",type:"get",success:function(t){if(t.routes){var s,r,l,h,p,c,g,u=[],d=[];for(p=0;p&lt;t.routes.features.length;p++)for(s=t.routes.features[p],c=0;c&lt;s.geometry.paths.length;c++)for(r=s.geometry.paths[c],g=0;g&lt;r.length;g++){var v=r[g],m=r[g-1];m&amp;&amp;m[0]==v[0]&amp;&amp;m[1]==v[1]||u.push(new rwgps.TrackPoint({point:{lat:v[1],lng:v[0]}}))}var f=3e-5,w=0;for(p=0;p&lt;t.directions.length;p++)for(l=t.directions[p],c=0;c&lt;l.features.length;c++){var P,_=999999;for(s=l.features[c],h=a.parseCompressedGeometry(s.compressedGeometry)[0],g=w;g&lt;u.length;g++){var k=rwgps.Router.euclideanDistance(u[g].point,h);if(k&lt;_&amp;&amp;(_=k,P=g,k&lt;f))break}if(_&lt;f&amp;&amp;P&gt;0&amp;&amp;P&lt;u.length-1){var y=a.cleanupNotes(s.attributes.text);d.push(new rwgps.CoursePoint({point:h,trackPoint:u[P],notes:y,type:a.extractTypeFromNotes(y),duration:s.attributes.time})),w=P}}o(u,d,e,i)}else n("No routes found")},error:function(t){n(t)}});var d=rwgps.config.labs.prevent_sticky_gmaps?"A":"B";trackEvent("Google Maps","Direction Request ("+d+")",this.opts.type),trackEvent("Google Maps","Direction Request",this.opts.type)},rwgps.Router.ArcGIS.prototype.parseCompressedGeometry=function(t){for(var e,i,o=0,n=0,s=[],r=t.replace(/(\+[0-9])*(\+)/,"$2").replace(/\|.*/,"").replace(/(\+)|(\-)/g," $&amp;").split(" "),a=parseInt(r[1],32),l=2,h=r.length;l&lt;h;l+=2)o=e=parseInt(r[l],32)+o,n=i=parseInt(r[l+1],32)+n,s.push({lat:i/a,lng:e/a});return s},rwgps.Router.Google=function(t){this.opts=t},rwgps.Router.Google.prototype=new rwgps.Router,rwgps.Router.Google.prototype.getDirections=function(t,e,i,o,n){function s(t,s){if(s==google.maps.DirectionsStatus.OK){for(var r=[],h=[],p=0;p&lt;t.routes.length;p++)for(var c=0;c&lt;t.routes[p].legs.length;c++)for(var g=0;g&lt;t.routes[p].legs[c].steps.length;g++){var u=t.routes[p].legs[c].steps[g];if(r.length&gt;0){var d=a.cleanupNotes(u.instructions);h.push(new rwgps.CoursePoint({point:{lat:u.path[0].lat(),lng:u.path[0].lng()},trackPoint:r[r.length-1],notes:d,type:a.extractTypeFromNotes(d),duration:u.duration.value}))}for(var v=0;v&lt;u.path.length;v++){var m=u.path[v-1],f=u.path[v];m&amp;&amp;m.lat()==f.lat()&amp;&amp;m.lng()==f.lng()||r.push(new rwgps.TrackPoint({point:{lat:f.lat(),lng:f.lng()}}))}}r.forEach(function(t){t.ghSurface=t.surface=0,t.roadClass=2}),window.Routes.activeMap.draggingMarker||window.Routes.activeMap.injectSurfaces(r,n),o(r,h,e,i)}else{var w=n(s);w&amp;&amp;setTimeout(function(){a.getDirections.apply(a,l)},3e3)}}var r=t.map(function(t){return new google.maps.LatLng(t.lat,t.lng)}),a=this,l=arguments,h=new google.maps.DirectionsService,p=null,c=r.length&gt;2?r.slice(1,r.length-1):[];p=e.cyclingMode()?google.maps.DirectionsTravelMode.BICYCLING:e.walkingMode()?google.maps.DirectionsTravelMode.WALKING:google.maps.DirectionsTravelMode.DRIVING;var g={origin:r[0],destination:r[r.length-1],waypoints:_.map(c,function(t){return{location:t,stopover:!1}}),provideRouteAlternatives:!1,unitSystem:google.maps.DirectionsUnitSystem.METRIC,travelMode:p,avoidHighways:e.avoidHighways()},u=rwgps.config.labs.prevent_sticky_gmaps?"A":"B";trackEvent("Google Maps","Direction Request ("+u+")",this.opts.type),trackEvent("Google Maps","Direction Request",this.opts.type),h.route(g,s)},rwgps.Router.RWGPSCombined=function(t){this.opts=t,this.language=t.language,this.url="/mrp_route"},rwgps.Router.RWGPSCombined.prototype=new rwgps.Router,rwgps.Router.RWGPSCombined.prototype.extractType=function(t){var e={"-98":"Uturn","-8":"Uturn","-7":"Slight Left","-3":"Sharp Left","-2":"Left","-1":"Slight Left",0:"Straight",1:"Slight Right",2:"Right",3:"Sharp Right",4:"Generic",5:"Generic",6:"Straight",7:"Slight Right",8:"Uturn"};return e[t]||"Generic"},rwgps.Router.RWGPSCombined.prototype.getDirections=function(t,e,i,o,n){var s,r,a=this,l=a.url;e.cyclingMode()?(s="rwgpsbike",r="rwgps"):e.cyclingExperimentMode()?(s="rwgpsbike",r="rwgps",l="https://directions-test.ridewithgps.com/route"):e.walkingMode()?(s="foot",r="fastest"):(s="car",r="fastest");var h="?vehicle="+s+"&amp;weighting="+r;h+="&amp;points=",t.map(function(t){h+=t.lat+","+t.lng+";"}),h+="&amp;locale="+window.navigator.language,h+="&amp;type=json",h+="&amp;point_attrs=surface,re",$.ajaxSettings.stopCSRF=!0,$.ajax({url:l+h,dataType:"json",type:"get",success:function(t){if(t.segments){if(0==t.segments.length)return void n("No route found");var s,r,l=0,h=[],p=[];for(s=0;s&lt;t.segments.length;s++){var c=t.segments[s],g=a.decodePath(c.points);for(r=0;r&lt;g.length;r++){var u=g[r];h.push(new rwgps.TrackPoint({point:{lat:u[0],lng:u[1]},ghSurface:u[2],roadClass:u[3],surface:rwgps.TrackPoint.inferSurface(u[2],u[3],u[0],u[1]),roadEnv:u[4]}))}for(r=0;r&lt;c.instructions.length;r++){var d=c.instructions[r],v=h[l+d.i];p.push(new rwgps.CoursePoint({point:v.point,trackPoint:v,notes:d.n,type:d.t}))}l=h.length}h.length&gt;0?o(h,p,e,i):n("No route found")}else n("No route found")},error:function(t,e){n(e)}});var p=rwgps.config.labs.prevent_sticky_gmaps?"A":"B";trackEvent("Google Maps","Direction Request ("+p+")",this.opts.type),trackEvent("Google Maps","Direction Request",this.opts.type)}},function(t,e){"use strict";rwgps=window.rwgps||{},rwgps.BikeLaneControl=function(t){this.map=t,this.controlDiv=document.createElement("DIV"),this.controlDiv.className="rwgps-BikeLaneControl",this.controlDiv.index=1;var e=t.gmap.getMapTypeId();"roadmap"!==e&amp;&amp;"satellite"!==e&amp;&amp;"hybrid"!==e&amp;&amp;"terrain"!==e&amp;&amp;(this.controlDiv.style.display="none");var i=this.controlDiv;i.style["padding-top"]="6px";var o=document.createElement("DIV");o.style.background="#fff",o.style.borderRadius="2px",o.style.boxShadow="1px 1px 5px 0 rgba(0,0,0,0.25)",o.style.cursor="pointer",o.title=T.t("bike_paths_desc"),o.className="rwgps-controlUI",i.appendChild(o);var n=document.createElement("DIV");n.style.fontFamily='"aktiv-grotesk", "Aktiv Grotesk", "Open Sans", "Gill Sans MT", "Gill Sans", Corbel, Arial, sans-serif',n.style.fontSize="13px",n.style.fontSize="13px",n.style.fontWeight="500",n.style.padding="7px 10px 0 10px",n.style.height="30px",n.style.boxSizing="border-box",n.style.color="#424242",n.style.userSelect="none",n.innerHTML=T.t("bike_paths"),o.appendChild(n);var s=!1,r=new google.maps.BicyclingLayer;google.maps.event.addDomListener(o,"click",function(){s?(r.setMap(null),o.style.backgroundColor="white"):(r.setMap(t.gmap),o.style.backgroundColor="#E7E7E7"),s=!s,t.plannerOptions.setOption("gmapsBikeOverlay",s)})},rwgps.BikeLaneControl.prototype.getContainingDiv=function(){return this.controlDiv}},function(t,e){"use strict";function i(t,e){if(!i.prototype.setValues)for(var o in google.maps.OverlayView.prototype)i.prototype[o]=google.maps.OverlayView.prototype[o];this.val=t,this.latLng=e}rwgps=window.rwgps||{},rwgps.actions=rwgpsG_js_maps_actions,rwgps.actionsManager=new rwgps.actions.ActionsManager,rwgps.Map=function(t){this.language=t.language||rwgps.config.language||"en",t.region?this.region=t.region:this.region="en-us",this.opts=t,this.mode=t.mode,this.surfaceTypesDebug=t.surfaceTypesDebug,this.prevClick=null,this.routes=[],this.setActiveRoute(new rwgps.Route(null,this)),this.pointsOfInterest=[],this.poisById={},this.gmap=null,this.nearestMousePoint1=null,this.nearestInterpolatedMousePoint=null,this.nearestPointMarker=null,this.routePoints=null,this.coursePointPopup=new rwgps.CoursePointPopup(this),this.distanceMarkers=[[],[],[],[]],this.nearestRouteSearchOpts={},this.clicks=[],this.showCoursePointIcons=!1,this.routers={},this.overlays={},this.activeOverlays=[],this.clickOptions=new rwgps.ClickOptions,this.clickOptions.followRoads(t.followRoads),this.plannerOptions=new rwgps.Bitmask.Planner,this.lineColor=16711680,_.bindAll(this,"addControlPointAtIndex","addCoursePointAtIndex"),this.topZIndex=1e3,this.nextAvailableOverlayIndex=0,this.routingOpts={allRestrictions:["avoidHighways"],services:[{id:"rwgps",enabled:!0,defaultColor:16711680,type:"rwgps",text:T.t("routes.follow_roads"),defaultMode:"cycling",checkboxes:{avoidHighways:!1},language:this.language,modes:{walking:{text:"walking",attributes:{}},cycling:{text:"cycling",attributes:{}},driving:{text:"driving",attributes:{}},experiment:{text:"experiment",attributes:{}}}},{id:"google",type:"google",enabled:!0,defaultColor:16711680,text:T.t("routes.follow_roads"),defaultMode:"cycling",checkboxes:{avoidHighways:!0},modes:{walking:{text:"walking",attributes:{avoidHighways:!0}},cycling:{text:"cycling",attributes:{avoidHighways:!0}},driving:{text:"driving",attributes:{avoidHighways:!0}}}},{id:"esriTopo",type:"arcgis",text:"Follow Roads",enabled:!0,defaultColor:16711680,url:"http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route",defaultMode:"cycling",attributes:{weightedCost:"",distanceCost:"Length",avoidOneWays:"OneWay",avoidFerries:"Avoid Ferries",avoidDirtRoads:"Avoid Unpaved Roads"},checkboxes:{avoidFerries:!0,avoidOneWays:!0,avoidDirtRoads:!0},modes:{walking:{text:"walking",attributes:{avoidHighways:!1}},cycling:{text:"cycling",attributes:{avoidHighways:!0}},driving:{text:"driving",attributes:{avoidHighways:!0}}}}]},this.overlayOpts={services:[{id:"roadmap",enabled:!0,routingService:"google",type:"google"},{id:"terrain",enabled:!0,routingService:"google",type:"google"},{id:"satellite",enabled:!0,routingService:"google",type:"google"},{id:"hybrid",enabled:!0,routingService:"google",type:"google"},{id:"rwgps_cycle",name:"RWGPS Cycle",maxZoom:18,minZoom:3,enabled:!0,type:"osm",url:"//vector.ridewithgps.com/styles/rwgpscycle/",routingService:"rwgps",attribution:"Â© OpenStreetMap contributors"},{id:"osm",name:"OSM",maxZoom:18,minZoom:3,enabled:!0,type:"osm",url:"//{s}.tile.openstreetmap.org/",routingService:"rwgps",attribution:"Â© OpenStreetMap contributors"},{id:"osmCycle",name:"OSM Cycle",key:"a1f31ce03c41486894ffd9ed393ec1ea",maxZoom:18,minZoom:3,enabled:!0,type:"osm",url:"//{s}.tile.thunderforest.com/cycle/",routingService:"rwgps",attribution:"Â© OpenStreetMap contributors"},{id:"osmOutdoor",name:"OSM Outdoors",key:"a1f31ce03c41486894ffd9ed393ec1ea",maxZoom:18,minZoom:3,enabled:!0,type:"osm",url:"//{s}.tile.thunderforest.com/outdoors/",routingService:"rwgps",attribution:"Â© OpenStreetMap contributors"},{id:"esriTopo",name:"Esri Topo",maxZoom:17,minZoom:3,enabled:!0,type:"arcgis",token:"AAPKb6d4ab91f6e249cda7f327bd40bc7a96xleixXTS5WctfNhsnl1TBpAX_vWdHu70IhznPJaqzUsjvRzBJvhmorfduBFxNhch",url:"//server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",routingService:"rwgps"},{id:"usgsTopo",name:"USGS Topo",maxZoom:15,minZoom:3,enabled:!0,type:"arcgis",url:"//basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer",routingService:"rwgps"},{id:"usgsTopoLegacy",name:"USGS Scans",maxZoom:15,minZoom:3,enabled:!0,type:"wms",token:"AAPKb6d4ab91f6e249cda7f327bd40bc7a96xleixXTS5WctfNhsnl1TBpAX_vWdHu70IhznPJaqzUsjvRzBJvhmorfduBFxNhch",url:"//services.arcgisonline.com/arcgis/rest/services/USA_Topo_Maps/MapServer/export",routingService:"rwgps"}],modes:{walking:{avoidCarsOnly:!0,avoidHighways:!0,avoidTunnels:!0},cycling:{avoidCarsOnly:!0,avoidHighways:!0,avoidTunnels:!0,avoidTrails:!0},driving:{}}};var e=this;_.each(this.routingOpts.services,function(i){t.modePreference&amp;&amp;i.modes[t.modePreference]&amp;&amp;(i.defaultMode=t.modePreference),1==i.enabled&amp;&amp;(e.routers[i.id]=new rwgps.Router(i))}),_.each(this.overlayOpts.services,function(t){1==t.enabled&amp;&amp;(e.overlays[t.id]=new rwgps.Overlay(t))}),this.initmap()},function(){var t=function(t,e){var i=void 0;return i=0===e?t.nextControlPoint:e===t.trackPoints.length+1?t.prevControlPoint:t.trackPoints[t.trackPoints.length-e],i?{point:i.point,distance:t.nextControlPoint.distance-i.distance}:null},e=function(t,e){var i=void 0;return i=0===e?t.prevControlPoint:e===t.trackPoints.length+1?t.nextControlPoint:t.trackPoints[e-1],i?{point:i.point,distance:i.distance-t.prevControlPoint.distance}:null},i=function(i,o){var n=function(n){return(o?t:e)(i,n)};return{index:0,distance:0,prevPoint:n(0),nextPoint:n(1),getPoint:n}},o=function(t,e){var i=t.index,o=t.distance,n=t.prevPoint,s=t.nextPoint,r=t.getPoint;if(!(e&lt;o)){for(var a=i,l=s,h=n;l.distance&lt;e||l.distance&lt;=o;)if(a++,h=l,l=r(a+1),!l)return;return{index:a,distance:e,prevPoint:h,nextPoint:l,getPoint:r}}},n=function(t,e){var i=t.lat*Math.PI/180,o=t.lng*Math.PI/180,n=e.lat*Math.PI/180,s=e.lng*Math.PI/180,r=s-o,a=Math.sin(r)*Math.cos(n),l=Math.cos(i)*Math.sin(n)-Math.sin(i)*Math.cos(n)*Math.cos(r),h=Math.atan2(a,l),p=(180*h/Math.PI+360)%360;return p},s=function(t){var e=t.prevPoint,i=t.nextPoint,o=t.distance,n=i.distance-e.distance,s=n&gt;0?(o-e.distance)/n:0;return{lat:(i.point.lat-e.point.lat)*s+e.point.lat,lng:(i.point.lng-e.point.lng)*s+e.point.lng}},r=10,a=75,l=function(t){for(var e=i(t,!0),l=i(t.nextSegment),h=null;;){if(!e.nextPoint||!l.nextPoint)break;var p=e.nextPoint.distance,c=l.nextPoint.distance,g=Math.min(p,c);if(e=o(e,g),l=o(l,g),!e||!l){h=null;break}var u=rwgps.TrackPoint.prototype.distanceFromLatLng.call({point:s(l)},s(e));if(!h){var d=n(t.nextControlPoint.point,s(e)),v=n(t.nextControlPoint.point,s(l)),m=Math.abs(d-v);if(m&gt;180&amp;&amp;(m=Math.abs(m-360)),m&gt;70)break}if(u&gt;r)break;if(e.distance&gt;a){h=null;break}h=e.distance}return h},h=function(t,e){for(var i=t.prevControlPoint,o=t.trackPoints.length&gt;0?t.trackPoints[0]:t.nextControlPoint,n=1;e&gt;o.distance&amp;&amp;n&lt;t.trackPoints.length;n++)i=o,o=t.trackPoints[n];e&gt;o.distance&amp;&amp;(i=o,o=t.nextControlPoint);var s=(e-i.distance)/(o.distance-i.distance);return{lat:(o.point.lat-i.point.lat)*s+i.point.lat,lng:(o.point.lng-i.point.lng)*s+i.point.lng}},p=10,c=function(t,e){var i=h(t,t.nextControlPoint.distance-e-p);return[t.prevControlPoint.point,i,t.nextSegment.nextControlPoint.point]},g=function(t,e,i,o,n,s){var r=Routes.activeMap,a=r.activeRoutingService;a.getDirections(e,i,o,function(i,o){if(null!=i&amp;&amp;0!=i.length){r.opts.generateCues||(o=null);for(var a=0,l=1/0,h=0;h&lt;i.length;h++){var p=rwgps.TrackPoint.prototype.distanceFromLatLng.call({point:e[1]},i[h].point);p&lt;l&amp;&amp;(l=p,a=h)}t.removeFromMap(),t.nextSegment.removeFromMap();var c=new rwgps.Segment(r.activeRoute,t.prevControlPoint,t.nextSegment.nextControlPoint,i,o,t.color);c.clickOptions.setOptions(t.clickOptions.getOptions()),c.splitAfter(a-1);for(var g=c.route.trackPoints(),u=[],d=0;d&lt;g.length;d++)void 0!=g[d].ele&amp;&amp;null!=g[d].ele||u.push(g[d]);u.length&gt;0&amp;&amp;!n?r.fetchElevations(u,function(){r.loadElevationProfile(),r.relabel(),r.activeRoute.calculateMetrics(),r.activeRoute.rebuildBounds(),r.activeRoute.flattenBridgesAndTunnels(),r.drawRouteDistanceMarkers(r.activeRoute),r.drawCoursePointIcons(r.activeRoute.coursePoints()),r.populateCuesheet(r.activeRoute.coursePoints()),r.snapshot(),$.jGrowl(T.t("routes.new.spur_corrected")),s&amp;&amp;s(c)}):(r.activeRoute.calculateMetrics(),s&amp;&amp;s(c))}},function(){s&amp;&amp;s()})},u=function(t,e,i){if(!t.nextSegment)return void(i&amp;&amp;i());if(!t.clickOptions.followRoads()||t.clickOptions.getOptions()!==t.nextSegment.clickOptions.getOptions())return void(i&amp;&amp;i());var o=l(t);if(o){var n=c(t,o);g(t,n,t.clickOptions,t.color,e,function(t){var o=t?l(t):null;if(o){var n=c(t,o);g(t,n,t.clickOptions,t.color,e,i)}else i&amp;&amp;i()})}else i&amp;&amp;i()};rwgps.checkSpur=u}(),rwgps.Map.prototype={routes:[],drawGrid:function(){var t,e,i=this.gmap.getBounds(),o=i.getNorthEast(),n=i.getSouthWest(),s=o.lat()-n.lat(),r=o.lng()-n.lng();for(t=0;t&lt;s;t++)e=Math.ceil(n.lat()+t),e&lt;=o.lat()&amp;&amp;new google.maps.Polyline({map:this.gmap,path:[new google.maps.LatLng(e,n.lng()),new google.maps.LatLng(e,o.lng())],strokeColor:"#0000FF",strokeOpacity:1,strokeWeight:1,clickable:!1});for(t=0;t&lt;r;t++)e=Math.ceil(n.lng()+t),e&lt;=o.lng()&amp;&amp;new google.maps.Polyline({map:this.gmap,path:[new google.maps.LatLng(n.lat(),e),new google.maps.LatLng(o.lat(),e)],strokeColor:"#0000FF",strokeOpacity:1,strokeWeight:1,clickable:!1})},inPlanningMode:function(){return"plan"==this.mode||"edit"==this.mode},setRoutingMode:function(t){var e=this.activeRoutingService.opts.modes[t];this.routingMode=t,"walking"==t?this.clickOptions.walkingMode(!0):"cycling"==t?this.clickOptions.cyclingMode(!0):"experiment"==t?this.clickOptions.cyclingExperimentMode(!0):this.clickOptions.drivingMode(!0),$("input.restrictions:checkbox").attr("checked",!1);for(var i=0;i&lt;this.routingOpts.allRestrictions.length;i++)this.clickOptions.setOption(this.routingOpts.allRestrictions[i],!1);for(var o in e.attributes){var n=e.attributes[o];$("#"+o).attr("checked",n),this.clickOptions.setOption(o,n)}var s=$(".walking"),r=$(".cycling"),a=$(".driving");s.removeClass("active"),r.removeClass("active"),a.removeClass("active"),$("."+t).addClass("active"),rwgps.Events.trigger("map:routing_mode_change",t)},setupInterfaceForRoutingService:function(){var t=this.activeRoutingService.opts.modes,e=$(".walking"),i=$(".cycling"),o=$(".driving");t.walking?e.val(t.walking.text).show():e.hide(),t.cycling?i.val(t.cycling.text).show():i.hide(),t.driving?o.val(t.driving.text).show():o.hide(),
$("#followRoadsButton").text(this.activeRoutingService.opts.text)},inactiveRoutes:function(){var t=_.clone(this.routes);return this.activeRoute&amp;&amp;t.splice(_.indexOf(t,this.activeRoute),1),t},setActiveRoute:function(t){if(t!==this.activeRoute){this.zoomOut(),_.indexOf(this.routes,t)===-1&amp;&amp;this.routes.push(t);var e=this.activeRoute;this.activeRoute=t,t.setActive(),delete this.routePoints;var i=t.trackPoints();if(this.prevClick=i.length&gt;0?i[i.length-1].point:null,e)if(e.trackPoints().length&gt;0)e.setInactive();else{var o=_.indexOf(this.routes,e);o!==-1&amp;&amp;(e.clearStartMarker(),this.routes.splice(o,1))}if(this.populateCuesheet(t.coursePoints()),this.drawCoursePointIcons(t.coursePoints()),this.loadElevationProfile(),Routes.sampleGraph){var n=t.showSurface&amp;&amp;(0===i.length||_.some(i,function(t){return t.surface})),s=Routes.sampleGraph.metricsEnabled();n?Routes.sampleGraph.metricsEnabled(s.push("surfaces")):s.indexOf("surfaces")!==-1&amp;&amp;Routes.sampleGraph.metricsEnabled(s.remove(s.indexOf("surfaces"),0)),Routes.sampleGraph.showSurface(n)}this.onMetricsChange(),this.drawRouteDistanceMarkers(this.activeRoute),this.loadPois(t.pois),t.metricsChange($.proxy(this.onMetricsChange,this)),rwgps.Events.trigger("map:routes_changed",this)}},showAllRoutes:function(t){function e(t){function e(t,e,i){var o="last",n="first";if(i&lt;0){var s=o;o=n,n=s}var r=t.get(o+"_lat"),p=t.get(o+"_lng");if(!r||!p)return!1;var c=e.get(n+"_lat"),g=e.get(n+"_lng");if(!c||!g)return!1;var u=rwgps.TrackPoint.haversine(r*h,p*h,c*h,g*h);return u&lt;a&amp;&amp;t.get("mappingRoute").metrics.distance&gt;l}function n(i,o){for(var n=0;n&lt;t.length;n++)if(e(i,t[n],o))return t[n]}t=_.sortBy(t,function(t){return-t.get("distance")});var s,r,a=500,l=2e3,h=Math.PI/180,p=[t.shift()];do if(s=n(p[0],-1)){var c=_.indexOf(t,s);t.splice(c,1),p.splice(0,0,s)}while(s);do r=n(p[p.length-1],1),r&amp;&amp;(c=_.indexOf(t,r),t.splice(c,1),p.push(r));while(r);p.length%i.length==1&amp;&amp;e(p[0],p[p.length-1],-1)&amp;&amp;i.push(o),t=t.concat(p),t.forEach(function(t){var e=t.get("mappingRoute");e.inactiveStyle={strokeOpacity:1,strokeWeight:4,strokeColor:i[0]},e.previewStyle={strokeOpacity:1,strokeWeight:4,strokeColor:"#000000",zIndex:1e3},e.setMap(this),e.active=!1,this.addRoute(e),i.push(i.shift())},this),this.recenterMap()}var i=["#FF0000","#0000FF","#229922","#FFFF00","#FF00FF","#802A2A"],o="#0077FF";this.clearMap(),this.activeRoute&amp;&amp;this.activeRoute.setInactive();var n=e.bind(this);async.mapLimit(t,3,function(t,e){t.full().done(function(t){e(null,t)})},function(t,e){n(e)})},onOverlayChanged:function(){var t=arguments.length&gt;0&amp;&amp;void 0!==arguments[0]&amp;&amp;arguments[0],e=!1;for(var i in this.overlays)this.plannerOptions.setOption(this.overlays[i].opts.id,!1);for(var o=this.activeOverlays.length-1;o&gt;=0;o--){var n=this.activeOverlays[o];if(!e&amp;&amp;n.opts.routingService){var s=this.routers[n.opts.routingService];if(s){if(s.opts&amp;&amp;s.opts.checkboxes){for(var r=s.opts.checkboxes,a=0;a&lt;this.routingOpts.allRestrictions.length;a++)this.clickOptions.setOption(this.routingOpts.allRestrictions[a],!1),$("#"+i).parent().toggle(!1);$("input.restrictions:checkbox").parent().toggle(!1);for(i in r)$("#"+i).parent().toggle(r[i])}this.activeRoutingService=s,this.setupInterfaceForRoutingService(),e=!0}}this.plannerOptions.setOption(n.opts.id,!0),this.activeRoutingService.opts.modes[this.routingMode]?this.setRoutingMode(this.routingMode):this.setRoutingMode(this.activeRoutingService.opts.defaultMode)}var l=this.gmap.getMapTypeId(),h=window.location.pathname,p=/^\/routes\/\d+\/edit/.test(h)&amp;&amp;"Edit",c=/^\/routes\/new/.test(h)&amp;&amp;"New",g=p||c,u=g?"Route Planner - "+g:"Route/Trip Viewer",d=t?"Map Style - Initial":"Map Style - Change";trackEvent(u,d,l),this.drawMapAttribution(this.overlays[l].opts.attribution),"roadmap"===l||"satellite"===l||"hybrid"===l||"terrain"===l?$(".rwgps-BikeLaneControl").show():$(".rwgps-BikeLaneControl").hide(),this.opts.onOverlayChanged&amp;&amp;this.opts.onOverlayChanged(n)},toggleOverlay:function(t){var e;return 1==t.active?(this.gmap.overlayMapTypes.setAt(t.index,null),this.nextAvailableOverlayIndex-=1,t.active=!1,t.index=null,e=!1,this.activeOverlays.splice(_.indexOf(this.activeOverlays,t),1)):(t.active=!0,t.index=this.nextAvailableOverlayIndex,this.nextAvailableOverlayIndex+=1,this.gmap.overlayMapTypes.setAt(t.index,t.getOverlayObj()),e=!0,this.activeOverlays.push(t)),this.onOverlayChanged(),rwgps.Events.trigger("map:overlay:toggled",t,e),e},initmap:function(){var t=this,e=this,i=[];_.each(this.overlays,function(t){if(1!=t.opts.isLayer){if(e.opts.hideGoogleTiles&amp;&amp;"google"==t.opts.type)return;i.push(t.opts.id)}});var o={addressControlOptions:{position:google.maps.ControlPosition.BOTTOM_CENTER},enableCloseButton:!0,visible:!1},n={zoom:15,gestureHandling:"greedy",scrollwheel:!this.opts.hasOwnProperty("scrollwheel")||1==this.opts.scrollwheel,draggableCursor:"crosshair",fullscreenControl:this.opts.fullscreenControl!==!1,fullscreenControlOptions:{position:google.maps.ControlPosition.TOP_LEFT},mapTypeControl:!this.opts.hasOwnProperty("showOverlayPicker")||!!this.opts.showOverlayPicker,mapTypeControlOptions:{mapTypeIds:i,style:google.maps.MapTypeControlStyle.DROPDOWN_MENU,position:google.maps.ControlPosition.TOP_RIGHT},controlSize:25,streetView:new google.maps.StreetViewPanorama(document.getElementById(this.opts.targetDiv),o),mapTypeId:this.opts.overlay||google.maps.MapTypeId.ROADMAP};if(this.opts.bounds){var s=new google.maps.LatLng(this.opts.bounds[0].lat,this.opts.bounds[0].lng),r=new google.maps.LatLng(this.opts.bounds[1].lat,this.opts.bounds[1].lng),a=new google.maps.LatLngBounds;a.extend(r),a.extend(s),n.bounds=a}else if(this.opts.center){var l=this.opts.center.lat,h=this.opts.center.lng;n.center=new google.maps.LatLng(l,h)}else n.center=new google.maps.LatLng(45.5773,-122.616);if(!this.inPlanningMode()&amp;&amp;this.opts.plannerOptions&amp;&amp;this.opts.plannerOptions&gt;0){this.plannerOptions.setOptions(this.opts.plannerOptions);var p=this.plannerOptions.getSetGroupOption("basemaps");p&amp;&amp;this.overlays[p]&amp;&amp;(n.mapTypeId=p)}n.styles=[{featureType:"poi.business",elementType:"labels",stylers:[{visibility:"on"}]}],this.gmap=new google.maps.Map(document.getElementById(this.opts.targetDiv),n),n.bounds&amp;&amp;this.gmap.fitBounds(a),this.inPlanningMode()&amp;&amp;this.activeOverlays.push(this.overlays[n.mapTypeId]),this.onOverlayChanged(!0),_.each(this.overlays,function(t){t.setProvider("google",e.gmap)});for(var c=0;c&lt;i.length;c++){var g=i[c],u=e.overlays[g];u&amp;&amp;"google"!=u.opts.type&amp;&amp;e.gmap.mapTypes.set(g,u.getOverlayObj())}if(rwgps.onRightClick&amp;&amp;google.maps.event.addListener(this.gmap,"rightclick",function(e){return rwgps.onRightClick(e,"map",t)}),google.maps.event.addListenerOnce(this.gmap,"tilesloaded",function(){e.opts.hideElevation&amp;&amp;e.hideElevation(),google.maps.event.trigger(e.gmap,"resize"),rwgps.Events.trigger("map:initialized")}),window.afterExpandCollapse&amp;&amp;afterExpandCollapse(function(){$(window).resize()}),google.maps.event.addListener(this.gmap,"zoom_changed",$.proxy(this.onMapZoom,this)),google.maps.event.addListener(this.gmap,"dragstart",$.proxy(this.onMapDragStart,this)),google.maps.event.addListener(this.gmap,"dragend",$.proxy(this.onMapDragEnd,this)),"user_edit"==this.mode);else if("preview"==this.mode);else if("search"==this.mode)this.drawCustomControls();else{this.enableClicks(),google.maps.event.addListener(this.gmap,"maptypeid_changed",$.proxy(this.mapTypeChanged,this)),google.maps.event.addListener(this.gmap,"mousemove",$.proxy(this.onMouseMove,this));var d=this;google.maps.event.addListener(this.gmap,"mouseout",function(){d.ignoreMouseMove=!0,_.delay(function(){d.ignoreMouseMove=!1},100)}),function t(){0==$(".sg-data-summary").length?_.delay(t,50):e.activeRoute.metricsChange()}(),this.drawCustomControls(),$("body.full #elevation_profile").length&gt;0&amp;&amp;$(window).resize(_.debounce(function(){google.maps.event.trigger(e.gmap,"resize");var t=$("#rp_nudge").offset()&amp;&amp;$("#rp_nudge").offset().top&gt;0?62:0,i=$(window).height()-$(".globalNav,#globalNav").get(0).getClientRects()[0].top-$(".globalNav,#globalNav").outerHeight()-t;$("#map").height(i),e.elevationCollapsed?$("#viewport").height(i-$("#elevation_profile .sg-bar").outerHeight()):($("#viewport").height(.8*i),_.defer(function(){$("#elevation_profile").height(.2*i),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.resize($("#elevation_profile").innerWidth(),$("#elevation_profile").innerHeight())}))},100)).resize(),"plan"!=this.mode||this.opts.preventLoadingLocallySavedRoute||this.redrawLocallySavedRoute()}},drawMapAttribution:function(t){if(this.hideMapAttribution(),t){var e=$("&lt;div&gt;&lt;span&gt;"+t+"&lt;/span&gt;&lt;/div&gt;");e.find("span").css({opacity:"0.65",padding:"0px 2px","font-family":"Roboto,Arial,sans-serif","background-color":"white","font-size":"0.9em","font-weight":"400",color:"#333333"}).end(),this.mapAttributionLocation=this.gmap.controls[google.maps.ControlPosition.BOTTOM_RIGHT],this.mapAttributionPosition=this.mapAttributionLocation.length,this.mapAttributionLocation.push(e.get(0))}},hideMapAttribution:function(){null!=this.mapAttributionLocation&amp;&amp;null!=this.mapAttributionPosition&amp;&amp;(this.mapAttributionLocation.removeAt(this.mapAttributionPosition),this.mapAttributionLocation=null,this.mapAttributionPosition=null)},drawCustomControls:function(){if(!this.opts.noCustomControls){var t=new rwgps.BikeLaneControl(this);this.gmap.controls[google.maps.ControlPosition.TOP_RIGHT].push(t.getContainingDiv())}},initializeBikeLayer:function(){this.bikeLayer=new google.maps.BicyclingLayer},showBikeLayer:function(){this.bikeLayer||this.initializeBikeLayer(),this.bikeLayer.setMap(this.gmap),this.plannerOptions.setOption("gmapsBikeOverlay",!0)},hideBikeLayer:function(){this.bikeLayer&amp;&amp;this.bikeLayer.setMap(null),this.plannerOptions.setOption("gmapsBikeOverlay",!1)},initializeHeatLayer:function(){var t={id:"heatMap",name:"Heatmap",maxZoom:19,minZoom:3,enabled:!0,type:"osm",url:"//heatmap.ridewithgps.com/normalized/"};this.heatLayer=new google.maps.ImageMapType({getTileUrl:function(e,i){return t.url+i+"/"+e.x+"/"+e.y+".png?start_color=%23bcebf0&amp;end_color=%23e94b65"},tileSize:new google.maps.Size(256,256),isPng:!0,alt:t.alt,name:t.name,maxZoom:t.maxZoom}),this.heatLayer.setOpacity(.7)},showHeatLayer:function(){var t=this;this.heatLayer||this.initializeHeatLayer(),this.gmap.overlayMapTypes.setAt(0,this.heatLayer),_.defer(function(){t.drawCoursePointIcons(t.activeRoute.coursePoints())})},hideHeatLayer:function(){var t=this;this.gmap.overlayMapTypes.setAt(0,null),_.defer(function(){t.drawCoursePointIcons(t.activeRoute.coursePoints())})},toggleElevation:function(){this.elevationCollapsed?this.showElevation():this.hideElevation()},showElevation:function(){var t=$(window).height()-$(".globalNav,#globalNav").get(0).getClientRects()[0].top-$(".globalNav,#globalNav").outerHeight();Routes.sampleGraph.options.displayLightControls?$("#elevation_profile").show():$("#elevation_profile canvas").show(),Routes.sampleGraph.segmentSelector&amp;&amp;Routes.sampleGraph.segmentSelector.show(),Routes.elevationHeight?$("#viewport").height(t-Routes.elevationHeight):$("#viewport").height(.8*t),google.maps.event.trigger(this.gmap,"resize"),this.loadElevationProfile(),this.elevationCollapsed=!1,$(window).resize()},hideElevation:function(){var t=$(".globalNav,#globalNav").get(0).getClientRects()[0].top,e=$(window).height()-t-$(".globalNav,#globalNav").outerHeight();Routes.sampleGraph.options.displayLightControls?$("#elevation_profile").hide():$("#elevation_profile canvas").hide(),Routes.sampleGraph.segmentSelector&amp;&amp;Routes.sampleGraph.segmentSelector.hide(),$("#routeContainer").height("100%"),$("#viewport").height(e-$("#elevation_profile .sg-bar").outerHeight()),google.maps.event.trigger(this.gmap,"resize"),this.loadElevationProfile(),this.elevationCollapsed=!0},onMetricsChange:function(){var t=this.highlightedPoints?this.highlightedPoints.metrics:this.activeRoute.metrics;$(".sg-data-summary").text(rwgps.LabelMaker.longLabel(t.distance||0,"short")+" +"+rwgps.LabelMaker.shortLabel(t.ele_gain||0,"short")+" / -"+rwgps.LabelMaker.shortLabel(t.ele_loss||0,"short")+(this.highlightedPoints&amp;&amp;t.grade&amp;&amp;t.grade.avg?" ("+t.grade.avg.toFixed(1)+"%)":"")),rwgps.Events.trigger("metrics:changed",t,!!this.highlightedPoints)},initInfoWindowHandlers:function(){var t=this;$("#coursePointInfoWindowContent .deleteButton").click(function(){return t.deleteCoursePoint(),!1}),$("#coursePointInfoWindowContent .saveButton").click(function(){return t.saveCoursePoint(),!1}),$("#coursePointInfoWindowContent .cancelButton").click(function(){return t.closeCoursePoint(),!1}),$("#poiInfoWindowContent .addToPoiLibrary").click(function(){if($(this).attr("data-poi_id")){var t=$("#saveOrUpdate");t.css("display",this.checked?"inline":"none")}}),$("#poiInfoWindowContent .deleteButton").click(function(){var e=this,i=function(){var i=$(e).attr("data-poi_id"),o=i?t.poisById[i]:t.openPoi;t.deletePoi(o)};return customConfirm(T.t("confirm_delete_poi"),i.bind(this)),!1}),$("#poiInfoWindowContent .saveButton").click(function(){return""==$("#poiInfoWindowContent .poiName").val()?(customAlert(T.t("poi_name_required")),!1):(t.savePoi(),!1)}),$("#poiInfoWindowContent .cancelButton").click(function(){return t.closeStickyInfoWindow(),!1}),$(".poi_add_to_route").click(function(){var e=$(this).attr("data-poi_id"),i=t.poisById[e];return i.addToRoute(),!1}),$(".poi_remove_from_route").click(function(){var e=$(this).attr("data-poi_id"),i=e?t.poisById[e]:t.openPoi;return i.removeFromRoute(),!1}),$(".poi_make_unique").click(function(){var e=$(this).attr("data-poi_id"),i=e?t.poisById[e]:t.openPoi;return i.id=null,i.library=!1,t.openStickyInfoWindow(i),!1}),$(".poi_route_to").click(function(){var e=$(this).attr("data-poi_id"),i=e?t.poisById[e]:t.openPoi;return t.onClickAddPoint({latLng:i.marker.gmarker.position}),i.addToRoute(),!1})},enableClicks:function(){return this.addPoiEnabled?void this.enableAddPoi():void(this.addCoursePointEnabled||this.addControlPointEnabled||this.routeSplitterEnabled||(this.disableClicks(),this.preventPoiMouseover=!1,this.inPlanningMode()&amp;&amp;google.maps.event.addListener(this.gmap,"click",$.proxy(this.onClickAddPoint,this))))},disableClicks:function(){this.preventPoiMouseover=!0,google.maps.event.clearListeners(this.gmap,"click")},enableAddPoi:function(){this.disableClicks(),this.addPoiEnabled=!0,google.maps.event.addListener(this.gmap,"click",$.proxy(this.onClickAddPoi,this))},disableAddPoi:function(){this.addPoiEnabled=!1,rwgps.Events.trigger("addpoi:disabled"),this.enableClicks()},onClickAddPoi:function(t){this.closeStickyInfoWindow();var e=new rwgps.PointOfInterest({point:{lat:t.latLng.lat(),lng:t.latLng.lng()}});e.marker=new rwgps.PoiIcon(e,this),e._new=!0,this.pointsOfInterest.push(e),this.activeRoute&amp;&amp;this.activeRoute.pois&amp;&amp;this.activeRoute.pois.push(e),rwgps.Events.trigger("pois:added",e),this.openStickyInfoWindow(e)},inclusiveBounds:function(){if(this.staticBounds)return this.staticBounds;var t=new google.maps.LatLngBounds;return _.each(this.routes,function(e){(e.active||e.drawInactive)&amp;&amp;t.union(e.gBounds)}),this.poiGBounds&amp;&amp;t.union(this.poiGBounds),t},recenterMap:function(){if(!this.recenterDisabled){var t=this.inclusiveBounds();t.isEmpty()||this.gmap.fitBounds(this.inclusiveBounds())}},withRecenterDisabled:function(t){this.recenterDisabled=!0,t(),this.recenterDisabled=!1},handleClick:function(t){if(this.opts.autoCenter&amp;&amp;this.gmap.panTo(new google.maps.LatLng(t.point.lat,t.point.lng)),this.routingRequestInProgress)return void this.clicks.push(t);if(this.prevClick)if(t.points)this.onRoutingSuccess(t.points,null,t.opts,t.color);else if(t.opts.followRoads()){var e=this.activeRoutingService,i=_.bind(function(){e.getDirections([this.prevClick,t.point],t.opts,t.color,$.proxy(this.onRoutingSuccess,this),$.proxy(this.onRoutingError,this))},this);this.routingRequestInProgress=!0,t.delay?setTimeout(i,t.delay):i()}else{var o=[new rwgps.TrackPoint({point:this.prevClick}),new rwgps.TrackPoint({point:t.point})];rwgps.config.labs.route_planner&amp;&amp;o.forEach(function(t){t.surface=99,t.ghSurface=99}),this.onRoutingSuccess(rwgps.Segment.fillTheCracks(o),null,t.opts,t.color)}else this.prevClick=t.point,this.activeRoute.startMarker=new rwgps.StartIcon(t.point,this),this.snapshot(),this.dispatchNextClick()},dispatchNextClick:function(){this.clicks.length&gt;0?this.handleClick(this.clicks.shift()):rwgps.Events.trigger("map:clicks_dispatched")},snapshot:function(t){if(!this.snapshotsDisabled&amp;&amp;this.inPlanningMode()){t||(t={});var e=this,i=function(){var i={routes:_.map(e.routes,function(t){var e=t.toSaveObj(!0);if(e.points_of_interest=t.pois.map(function(t){return t.toSaveObj()}),t.active&amp;&amp;t.startMarker){var i=t.startMarker.gmarker.getPosition();e.start_point={x:i.lng(),y:i.lat()}}return e.routeData=t.routeData,e.tripData=t.tripData,e})},o=new rwgps.actions.RouteSnapshot(e,i);t.updateLast?rwgps.actionsManager.chain(o):t.manualUndo?rwgps.actionsManager.manualUndoTo(o):rwgps.actionsManager.add(o),e.saveSnapshotLocally(o),e.activeRoute.setModified()};t.doSync?i():_.defer(i)}},saveSnapshotLocally:function(t){"edit"!=this.mode&amp;&amp;($.jStorage&amp;&amp;$.jStorage.storageAvailable()?$.jStorage.set("locallySavedRoute",t.serialized):trace("no local storage available?"))},redrawLocallySavedRoute:function(){try{if(void 0===$.jStorage)return;var t=$.jStorage.get("locallySavedRoute");if(t){var e=new rwgps.actions.RouteSnapshot(this,t);e.restore(),this.snapshot(),this.recenterMap()}}catch(t){trace(t.stack),trace("Error redrawing locally saved route, clearing it out"),this.clearMap()}},onClickAddPoint:function(t){return this.opts.tripId?void rwgps.Events.trigger("trip:modification_prevented"):void this.handleClick({point:{lat:t.latLng.lat(),lng:t.latLng.lng()},opts:this.clickOptions,color:this.lineColor,fetchEles:!0})},insertPointAfterClick:function(){var t=this.nearestPointMarker.gmarker.getPosition(),e={lat:t.lat(),lng:t.lng()},i=this.nearestMousePointBehind.distance+this.nearestMousePointBehind.distanceFromLatLng(e),o=this.nearestMousePointBehind.surface,n=this.nearestMousePointBehind.ghSurface,s=this.nearestMousePointBehind.roadClass,r=this.nearestMousePointBehind.excludeFromMetrics,a=new rwgps.TrackPoint({point:e,ele:this.nearestMousePointBehind.ele,surface:o,ghSurface:n,roadClass:s,excludeFromMetrics:r});a.distance=i;var l=this.nearestMousePointBehind.segment||this.nearestMousePointBehind.nextSegment,h=_.indexOf(l.trackPoints,this.nearestMousePointBehind);return l.insertTrackPointAfter(a,h),this.fetchElevations([a],$.proxy(function(){this.loadElevationProfile(),this.snapshot({updateLast:!0})},this),function(t){trace(t)}),{trackPoint:a,idx:h}},onClickAddCoursePoint:function(){var t=this.insertPointAfterClick().trackPoint;this.openCoursePointInfoWindow(new rwgps.CoursePoint({point:t.point,trackPoint:t,segment:t.segment,distance:t.distance}))},onClickAddControlPoint:function(){var t=this.insertPointAfterClick();t.trackPoint.segment.splitAfter(t.idx),this.loadElevationProfile()},onNearestPointMarkerClicked:function(t){if(this.activeRoute!==(this.nearestMousePointBehind.segment||this.nearestMousePointBehind.nextSegment).route);else if(this.inPlanningMode())if(this.selectionToolHelper){var e=this.insertPointAfterClick(),i=this.activeRoute.trackPoints().indexOf(e.trackPoint);this.selectionToolHelper.selectPoint({closestI:i})}else this.routeSplitterEnabled?this.onClickSplitRoute(t):this.addPoiEnabled?this.onClickAddPoi(t):this.addCoursePointEnabled?this.onClickAddCoursePoint(t):this.addControlPointEnabled?this.onClickAddControlPoint(t):this.onClickAddPoint(t);else rwgps.Events.trigger("map:route_click",this.lastNearestPoint)},onClickSplitRoute:function(){var t=this.insertPointAfterClick();this.splitRouteOnTrackPoint(t)},splitRouteOnTrackPoint:function(t){var e=this.activeRoute,i=t.trackPoint,o=this.activeRoute.trackPoints().indexOf(i),n=this.activeRoute.toSaveObj();n.pois=[],n.course_points=_.filter(n.course_points,function(t){return t.d&lt;=i.distance}),n.track_points=n.track_points.slice(0,o),delete n.id,delete n.name;var s=this.activeRoute.toSaveObj();if(s.track_points=s.track_points.slice(o),s.track_points.length&gt;0?s.course_points=_.filter(s.course_points,function(t){return t.d&gt;=s.track_points[0].d}):s.course_points=[],delete s.id,delete s.name,n.track_points[n.track_points.length-1].color=this.activeRoute.trackPoints()[n.track_points.length-1].segment.color,s.track_points.length&gt;0){var r=s.track_points[0].d;s.track_points.forEach(function(t){t.d=t.d-r}),s.course_points.forEach(function(t){t.d=t.d-r,t.i=t.i-o})}var a=this.loadRouteForEdit(n,!0,!1),l=this.loadRouteForEdit(s,!0,!1);this.setActiveRoute(a);var h=4828.032;e.pois.forEach(function(t){var e=a.distanceToLatLng(t.googleLatLng(),this),i=l.distanceToLatLng(t.googleLatLng(),this);e&lt;i?(a.pois.push(t),i&lt;h&amp;&amp;l.pois.push(t.copy())):(l.pois.push(t),e&lt;h&amp;&amp;a.pois.push(t.copy()))},this),this.activeRoute.pois.length&gt;0&amp;&amp;this.loadPois(this.activeRoute.pois,!1),this.removeRoute(e),this.drawRouteDistanceMarkers(),this.loadElevationProfile(),this.populateCuesheet(this.activeRoute.coursePoints()),this.snapshot(),rwgps.Events.trigger("map:routes_changed")},onRoutingSuccess:function(t,e,i,o){if(this.routingRequestInProgress=!1,this.routingRequestCancelled)return void(this.routingRequestCancelled=!1);this.opts.generateCues||(e=null);var n=this,s=function(){if(t.length&lt;=1)return void rwgps.Events.trigger("map:routing_complete");var s;if(n.activeRoute.segments.length&gt;0){var r=n.activeRoute.lastSegment,a=r.nextControlPoint;s=a;var l=!0;do{var h=a.distanceFromPoint(t[0]);h&lt;2?t.shift():l=!1}while(l&amp;&amp;t.length&gt;0)}else s=t.shift();var p=t.pop(),c=new rwgps.Segment(n.activeRoute,s,p,t,e,o);if(c){n.prevClick=c.nextControlPoint.point,null==n.activeRoute.startMarker?n.activeRoute.startMarker=new rwgps.StartIcon(c.prevControlPoint.point,n):1==n.activeRoute.segments.length&amp;&amp;n.activeRoute.startMarker.gmarker.setPosition(c.prevControlPoint.googleLatLng()),c.clickOptions.setOptions(i.getOptions()),n.activeRoute.calculateMetrics(),_.each(t,function(t){t.grade=null}),e&amp;&amp;e.length&gt;0&amp;&amp;(n.drawCoursePointIcons(e),n.populateCuesheet(e,!0)),n.autoCenter&amp;&amp;n.gmap.panTo(new google.maps.LatLng(n.prevClick.lat,n.prevClick.lng));var g=function(){n.loadElevationProfile(),n.activeRoute.flattenBridgesAndTunnels(),n.relabel(),n.activeRoute.resetGrade(),n.activeRoute.calculateMetrics(),n.activeRoute.redrawPolylines(),n.snapshot(),rwgps.Events.trigger("map:routing_complete"),n.drawSegmentDistanceMarkers(c)},u=_.filter(t.concat([c.prevControlPoint,c.nextControlPoint]),function(t){return void 0==t.ele||null==t.ele});u.length&gt;0?n.fetchElevations(u,g):g()}!n.modalOperationInProgress&amp;&amp;n.activeRoute.segments.length&gt;1&amp;&amp;rwgps.checkSpur(n.activeRoute.lastSegment.prevSegment)};s(),this.dispatchNextClick()},relabel:function(){$(".txtDistance").text(rwgps.LabelMaker.longLabel(this.activeRoute.distance,"full")),$(".txtAscent").text(rwgps.LabelMaker.shortLabel(this.activeRoute.elevationGain())),$(".txtDescent").text(rwgps.LabelMaker.shortLabel(this.activeRoute.elevationLoss(),"full"))},onRoutingError:function(t){if(this.routingRequestInProgress=!1,this.routingRequestCancelled)return void(this.routingRequestCancelled=!1);if(trace(t),"OVER_QUERY_LIMIT"==t){if(this.overQuota)return this.overQuota=!1,rwgps.Events.trigger("map:routing_error"),!1;var e=this;return this.overQuota=!0,setTimeout(function(){e.overQuota=!1},1e4),!0}rwgps.Events.trigger("map:routing_error"),this.clickOptions.googleRouting()&amp;&amp;this.clickOptions.cyclingMode()?customAlert(T.t("no_routes_found_google_cycling")):customAlert(T.t("no_routes_found"));var i=this.activeRoute.trackPoints();if(0==i.length){var o=this.activeRoute.startMarker.gmarker.position;return this.prevClick={lat:o.lat(),lng:o.lng()},!1}return this.prevClick=i[i.length-1].point,!1},onMouseMove:function(t){this.throttledOnMouseMove||(this.throttledOnMouseMove=_.throttle($.proxy(this.nonthrottledOnMouseMove,this),40),this.debouncedThrottledOnMouseMove=_.debounce(this.throttledOnMouseMove,100)),this.throttledOnMouseMove(t),this.debouncedThrottledOnMouseMove(t)},findNearestPoint:function(t){if(null!=this.activeRoute&amp;&amp;0!=this.activeRoute.segments.length){var e=this.activeRoute.trackPoints(),i=this.googleLatLngToPoint(t),o=i.x,n=i.y;if(this.nearestMousePoint1=null,this.nearestMousePoint2=null,this.nearestInterpolatedMousePoint=null,!this.routePoints){this.routePoints=[];for(var s=0;s&lt;e.length;s++)if(e[s].point){var r=this.googleLatLngToPoint(e[s].googleLatLng());this.routePoints.push(r.x),this.routePoints.push(r.y),this.routePoints.push(e[s])}else this.routePoints.push(null),this.routePoints.push(null),this.routePoints.push(null)}var a,l,h,p,c=99999,g=this.routePoints[0],u=this.routePoints[1],d=g,v=u,m=this.activeRoute.hasHighlightedSegment();for(a=0;a&lt;this.routePoints.length;a+=3){var f=d,w=v;if(d=this.routePoints[a],v=this.routePoints[a+1],null!=d&amp;&amp;null!=v&amp;&amp;!(d&lt;o-50&amp;&amp;f&lt;o-50||d&gt;o+50&amp;&amp;f&gt;o+50||v&lt;n-50&amp;&amp;w&lt;n-50||v&gt;n+50&amp;&amp;w&gt;n+50||m&amp;&amp;this.routePoints[a+2]&amp;&amp;(this.routePoints[a+2].segment&amp;&amp;this.routePoints[a+2].segment.drawInactive||!this.routePoints[a+2].segment&amp;&amp;this.routePoints[a+2].prevSegment&amp;&amp;!this.routePoints[a+2].prevSegment.drawInactive||!this.routePoints[a+2].segment&amp;&amp;this.routePoints[a+2].nextSegment&amp;&amp;!this.routePoints[a+2].nextSegment.drawInactive))){var P=d-f,_=v-w,k=P*P+_*_,y=((o-d)*P+(n-v)*_)/k,M=d+y*P,S=v+y*_,I=(o-M)*(o-M)+(n-S)*(n-S);if(I&lt;c){var C=(o-f)*(o-f)+(n-w)*(n-w),b=(o-d)*(o-d)+(n-v)*(n-v);C-I+(b-I)&gt;k&amp;&amp;(C&lt;b?(I=C,M=f,S=w):(I=b,M=d,S=v))}I&lt;c&amp;&amp;(c=I,g=M,u=S,l=C&lt;b?a-1:a+2,h=a-1,p=a+2,this.nearestMousePoint=this.routePoints[l],this.nearestMousePointBehind=this.routePoints[h],this.nearestMousePointAhead=this.routePoints[p])}}var x=new google.maps.Point(g,u),O=(l-2)/3,R=(h-2)/3,L=(p-2)/3,A=e[L],E=e[R];if(E&amp;&amp;E.point){var T=this.pointToGoogleLatLng(x);if(this.nearestInterpolatedMousePoint={lat:T.lat(),lng:T.lng()},null==A||null==A.point||null==this.nearestInterpolatedMousePoint)return;var D=E.distanceFromLatLng(this.nearestInterpolatedMousePoint)/A.distanceFromPoint(E);return{distance:c,point:x,closestI:O,lowI:R,highI:L,pct:D}}}},nonthrottledOnMouseMove:function(t){if(!this.ignoreMouseMove){var e=this.lastNearestPoint=this.findNearestPoint(t.latLng);if(e&amp;&amp;e.distance&lt;200){if(this.inPlanningMode()&amp;&amp;!this.draggingMarker){var i=this.nearestMousePointBehind.segment||this.nearestMousePointBehind.nextSegment||this.nearestMousePointBehind.prevSegment,o=this.googleLatLngToPoint(i.nextControlPoint.googleLatLng()),n=this.googleLatLngToPoint(i.prevControlPoint.googleLatLng());if(Math.pow(e.point.x-o.x,2)+Math.pow(e.point.y-o.y,2)&lt;150||Math.pow(e.point.x-n.x,2)+Math.pow(e.point.y-n.y,2)&lt;150)return void(this.nearestPointMarker&amp;&amp;this.nearestPointMarker.gmarker.getMap()&amp;&amp;this.unhighlightNearestPoint())}if(this.showNearestPointMarkerAt(this.nearestInterpolatedMousePoint),this.eleProfile()){var s=this.activeRoute.trackPoints();this.updatePlayhead(s[e.closestTpsI],s),rwgps.Events.trigger("map:highlight_point",e)}}else this.nearestPointMarker&amp;&amp;this.nearestPointMarker.gmarker.getMap()&amp;&amp;this.unhighlightNearestPoint()}},showNearestPointMarkerAt:function(t){null==this.nearestPointMarker&amp;&amp;(this.nearestPointMarker=new rwgps.NearestPointIcon(t,this),google.maps.event.addListener(this.nearestPointMarker.gmarker,"click",$.proxy(this.onNearestPointMarkerClicked,this))),null==this.nearestPointMarker.gmarker.getMap()&amp;&amp;this.nearestPointMarker.gmarker.setMap(this.gmap),0==this.nearestPointMarker.gmarker.getVisible()&amp;&amp;this.nearestPointMarker.gmarker.setVisible(!0),this.nearestPointMarker.gmarker.setPosition(new google.maps.LatLng(t.lat,t.lng)),this.nearestPointMarker.gmarker.setZIndex(0)},unhighlightNearestPoint:function(){!this._playing&amp;&amp;!this._paused&amp;&amp;this.nearestPointMarker&amp;&amp;this.nearestPointMarker.gmarker.getVisible()&amp;&amp;(this.nearestPointMarker.gmarker.setVisible(!1),rwgps.Events.trigger("map:unhighlight_nearest_point"),$.ui&amp;&amp;$.ui.slider&amp;&amp;$("#elapsed_time_slider").data("ui-slider")&amp;&amp;($("#elapsed_time_slider").slider("option","value",0),$("#elapsed_time").html("00:00:00")))},eleProfile:function(){var t=this.opts.eleProfileId||"elevation_profile";return document.getElementById(t)},mapTypeChanged:function(){var t=this.gmap.getMapTypeId();"osmCycle"==t||"osm"==t?this.clickOptions.osmRouting(!0):"esriTopo"==t?this.clickOptions.arcgisRouting(!0):this.clickOptions.googleRouting(!0),this.activeOverlays[0]=this.overlays[t],this.inPlanningMode()&amp;&amp;Application.setPreference("planner_overlay",t,!0),this.onOverlayChanged()},onMapZoom:function(){this.routePoints=null},onMapDragStart:function(){},onMapDragEnd:function(){this.routePoints=null},revert:function(){rwgps.actionsManager.revert()},undo:function(){trackEvent("Route Planner","Route Ops","Undo"),this.zoomOut(),rwgps.actionsManager.canUndo()?rwgps.actionsManager.undo():(this.undoLastClick(),this.snapshot({manualUndo:!0}))},redo:function(){trackEvent("Route Planner","Route Ops","Redo"),this.zoomOut(),rwgps.actionsManager.redo()},zoomOut:function(){Routes.sampleGraph&amp;&amp;(Routes.sampleGraph.zoomOut(),Routes.sampleGraph.segmentSelector&amp;&amp;Routes.sampleGraph.segmentSelector.unload())},clearSegment:function(){Routes.sampleGraph&amp;&amp;Routes.sampleGraph.segmentSelector&amp;&amp;Routes.sampleGraph.segmentSelector.unload()},undoLastClick:function(){if(0===this.activeRoute.segments.length)this.activeRoute.startMarker&amp;&amp;(this.clearAllOverlays(),this.prevClick=null,this.routes.slice(_.indexOf(this.routes,this.activeRoute),1),this.setActiveRoute(new rwgps.Route(null,this)),this.routes.push(this.activeRoute));else{var t=this.activeRoute.segments[this.activeRoute.segments.length-1];this.removeSegmentDistanceMarkers(t),this.activeRoute.removeSegment(t),this.prevClick=t.prevControlPoint.point}this.nearestPointMarker&amp;&amp;this.unhighlightNearestPoint(),rwgps.Events.trigger("cp:populate",this.activeRoute.coursePoints(),!1),this.routePoints=null,this.loadElevationProfile(),this.updateDistanceMarkersDisplayed()},clearAllOverlays:function(){this.closeStickyInfoWindow(),this.closePreviewInfoWindow();var t=0;for(t=0;t&lt;this.routes.length;t++)this.routes[t].clearAllOverlays();if(this.pointsOfInterest){for(t=0;t&lt;this.pointsOfInterest.length;t++)this.pointsOfInterest[t].marker.gmarker.setMap(null);this.poiGBounds=null}this.nearestPointMarker&amp;&amp;this.unhighlightNearestPoint()},clearMapWithConfirm:function(){trackEvent("Route Planner","Route Ops","Clear map");var t=this;customConfirm(T.t("clear_map_confirm"),function(){t.clearMap(),rwgps.actionsManager.clear(),t.snapshot()})},clearMapWithHistory:function(){this.clearMap(),rwgps.actionsManager.clear(),this.snapshot()},addRoute:function(t,e){this.routes.push(t),e?this.setActiveRoute(t):t.redraw(),rwgps.Events.trigger("map:routes_changed")},removeRoute:function(t,e){this.activeRoute===t&amp;&amp;this.zoomOut(),t.clearAllOverlays(),this.removeRouteDistanceMarkers(t),this.routes.splice(_.indexOf(this.routes,t),1),this.activeRoute===t?(this.zoomOut(),delete this.routePoints,this.activeRoute=null,e&amp;&amp;this.routes.length&gt;0?this.setActiveRoute(this.routes[0]):this.setActiveRoute(new rwgps.Route(null,this))):(rwgps.Events.trigger("map:routes_changed",this),this.snapshot())},redrawRoutes:function(){_.each(this.routes,function(t){t.redraw()})},clearMap:function(){this.zoomOut(),this.clearAllOverlays(),this.removeRouteDistanceMarkers(this.activeRoute),delete this.pointsOfInterest,this.pointsOfInterest=[],this.routes=[],this.activeRoute=null,this.setActiveRoute(new rwgps.Route(null,this)),this.prevClick=null,this.activeRoute.calculateMetrics(),this.closePreviewInfoWindow(),this.closeStickyInfoWindow(),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.data([]),"plan"==this.mode&amp;&amp;$.jStorage.deleteKey("locallySavedRoute")},reverseRoute:function(){trackEvent("Route Planner","Route Ops","Reverse"),this.replayRouteInReverse(!0)},outAndBack:function(){trackEvent("Route Planner","Route Ops","Out and back"),this.replayRouteInReverse(!1)},replayRouteInReverse:function(t){if(this.zoomOut(),this.opts.tripId)return void rwgps.Events.trigger("trip:modification_prevented");if(this.snapshot({updateLast:!0,doSync:!0}),this.activeRoute.firstSegment){for(var e=this.activeRoute.segments,i=e[e.length-1],o=t?[{
point:i.nextControlPoint.point,opts:i.clickOptions,color:i.color,fetchEles:!0}]:[],n=0,s=e.length-1;s&gt;=0;--s){var r=e[s];e.length-s==6&amp;&amp;(n=1e3);var a={point:r.prevControlPoint.point,opts:r.clickOptions,color:r.color,fetchEles:!0,delay:n};0===r.coursePoints.length&amp;&amp;(a.points=_.map(r.trackPoints,function(t){return t.shallowClone()}).reverse()),o.push(a)}if(t){var l=_.indexOf(this.routes,this.activeRoute),h=this.activeRoute.routeData,p=this.activeRoute.pois;this.removeRoute(this.activeRoute);var c=this.routes.pop();c.routeData=h,c.pois=p,this.routes.splice(l,0,c),this.loadPois(c.pois),rwgps.Events.trigger("map:routes_changed")}_.each(o,function(t){this.clicks.push(t)},this);var g,u,d,v,m=_.reduce(o,function(t,e){return t+(e.opts.followRoads()?1:0)},0),f=o.length-(t?1:0),w=0,P=m&gt;4;v=function(){rwgps.Events.unbind("map:routing_error",g),rwgps.Events.unbind("map:routing_complete",u),rwgps.Events.unbind("map:modal_operation_cancelled",d)},d=_.bind(function(){v(),this.clicks=[],this.routingRequestInProgress&amp;&amp;(this.routingRequestCancelled=!0),this.snapshotsDisabled=!1,this.revert()},this),u=_.bind(function(){w++,P&amp;&amp;rwgps.Events.trigger("map:modal_operation_progress",w,f),w==f&amp;&amp;(v(),P&amp;&amp;(rwgps.Events.trigger("map:modal_operation_complete"),this.modalOperationInProgress=!1),this.snapshotsDisabled=!1,this.snapshot())},this),g=_.bind(function(){v(),this.clicks=[],this.snapshotsDisabled=!1,rwgps.Events.trigger("map:reverted_due_to_error"),this.revert()},this),this.snapshotsDisabled=!0,rwgps.Events.bind("map:routing_complete",u),rwgps.Events.bind("map:routing_error",g),rwgps.Events.bind("map:modal_operation_cancelled",d),P&amp;&amp;(this.modalOperationInProgress=!0,rwgps.Events.trigger("map:modal_operation_started")),this.dispatchNextClick()}},removeAllNonActiveRoutes:function(){_.map(this.routes,function(t){t!=this.activeRoute&amp;&amp;t.removeFromMap()}),this.previewInfoWindow&amp;&amp;this.previewInfoWindow.close(),this.stickyInfoWindow&amp;&amp;this.stickyInfoWindow.close()},loadRoute:function(t,e){var i=void 0===e||1==e,o=t.segments[0],n=0;if(t.map=this,t.segments.length&gt;0){var s=o.prevControlPoint.point;if(!s)for(n=0;n&lt;o.trackPoints.length;n++)if(o.trackPoints[n].point){s=o.trackPoints[n].point;break}for(t.startMarker=new rwgps.StartIcon(s,this),o=t.segments[t.segments.length-1],i&amp;&amp;(t.endMarker=new rwgps.EndIcon(o.nextControlPoint.point,this)),n=0;n&lt;t.segments.length;n++)t.segments[n].addToMap(this)}this.routes.push(t)},loadRouteForEdit:function(t,e,i){var o,n;return t.track_points?(o=new rwgps.Route(t,this,{planning:!0}),this.loadRoute(o,!1)):_.isFunction(t.trackPoints)?(o=t,this.loadRoute(o,!1)):t.start_point?(o=new rwgps.Route(null,this),this.prevClick={lat:t.start_point.y,lng:t.start_point.x},this.setActiveRoute(o),this.activeRoute.startMarker=new rwgps.StartIcon(this.prevClick,this)):o=new rwgps.Route(null,this),n=o.trackPoints(),n.length&gt;0&amp;&amp;(this.prevClick=n[n.length-1].point),this.setActiveRoute(o),rwgps.Events.trigger("pois:populate",this.activePointsOfInterest()),o.drawControlPoints(this),e||this.recenterMap(),i&amp;&amp;this.snapshot(),o},loadRouteForView:function(t,e){this.clearAllOverlays(),this.loadRoute(t,!0),this.gmap.fitBounds(t.gBounds),this.setActiveRoute(t),e&amp;&amp;(this.afterLoadElevationProfileFn=e)},loadPois:function(t,e){void 0===e&amp;&amp;(e=!0),this.pointsOfInterest&amp;&amp;_.each(this.pointsOfInterest,function(t){t.marker.gmarker.setMap(null)});var i=_.map(t,function(t){return _.isFunction(t.toSaveObj)?t:rwgps.PointOfInterest.fromJSON([t],e)[0]});this.pointsOfInterest=i,this.poiGBounds=new google.maps.LatLngBounds;var o=this;_.each(this.pointsOfInterest,function(t){o.poisById[t.id]=t,t.marker=new rwgps.PoiIcon(t,o),o.poiGBounds.extend(t.googleLatLng())}),this.opts.poiEnabled||i.forEach(function(t){var e=t.marker.gmarker;return e.setMap(null)})},openPreviewInfoWindow:function(t,e){e=void 0==e||e,this.previewInfoWindow&amp;&amp;(this.previewInfoWindow.close(),this.previewInfoWindow=null),this.previewInfoWindow=new InfoBox({position:t.googleLatLng(),content:this.contentForPoiInfoWindow(t,!0),disableAutoPan:!e,maxWidth:0,pixelOffset:new google.maps.Size(-140,-40),alignBottom:!0,zIndex:null,closeBoxURL:"",boxStyle:{opacity:.9,minWidth:"200px",maxWidth:"260px",padding:"10px",border:"1px solid black",background:"white"},closeBoxMargin:"2px 2px 2px 2px",infoBoxClearance:new google.maps.Size(1,1),isHidden:!1,pane:"floatPane",enableEventPropagation:!1}),google.maps.event.addListener(this.previewInfoWindow,"closeclick",$.proxy(this.closePreviewInfoWindow,this)),google.maps.event.clearListeners(this.previewInfoWindow,"domready"),google.maps.event.addListener(this.previewInfoWindow,"domready",$.proxy(function(){this.initInfoWindowHandlers()},this)),this.disableClicks(),this.previewInfoWindow.open(this.gmap)},openStickyInfoWindow:function(t,e){this.openPoi&amp;&amp;this.openPoi.marker&amp;&amp;this.openPoi.marker.enableMouseOverOut(),t.marker&amp;&amp;t.marker.disableMouseOverOut(),this.openGenericStickyInfoWindow(t.point,this.contentForPoiInfoWindow(t),e),google.maps.event.addListener(this.stickyInfoWindow,"domready",$.proxy(function(){tb_init("a.thickbox"),this.initPoiInfoWindowHandlers(t),this.initPointPhotoWidget(t)},this)),this.openPoi=t},openGenericStickyInfoWindow:function(t,e,i){i=void 0==i||i,this.closePreviewInfoWindow(),this.stickyInfoWindow&amp;&amp;(this.stickyInfoWindow.close(),this.stickyInfoWindow=null),this.stickyInfoWindow=new InfoBox({position:new google.maps.LatLng(t.lat,t.lng),content:e,disableAutoPan:!i,maxWidth:0,pixelOffset:new google.maps.Size(-140,-40),alignBottom:!0,zIndex:null,boxStyle:{opacity:1,zIndex:1e3,minWidth:"240px",maxWidth:"400px",overflow:"auto",maxHeight:"500px",padding:"20px",background:"#FFFFFF",border:"1px solid #E8E8E8",boxShadow:"0 2px 4px 0 rgba(0,0,0,0.20)"},closeBoxMargin:"2px 2px 2px 2px",infoBoxClearance:new google.maps.Size(10,10),isHidden:!1,pane:"floatPane",enableEventPropagation:!1}),google.maps.event.addListener(this.stickyInfoWindow,"closeclick",$.proxy(this.closeStickyInfoWindow,this)),google.maps.event.clearListeners(this.stickyInfoWindow,"domready"),google.maps.event.addListener(this.stickyInfoWindow,"domready",$.proxy(function(){this.initInfoWindowHandlers()},this)),this.disableClicks(),this.stickyInfoWindow.open(this.gmap)},initPointPhotoWidget:function(t){if(t&amp;&amp;window.rwgpsG_views_photos){var e=_.map(t.photoIds,function(t){return{id:t}}),i=rwgpsG_views_photos;if(i){var o=new i({container:"#poiInfoWindowContent .photos_view, #coursePointInfoWindowContent .photos_view",photos:e,canEdit:!0,photosetDisabled:!0});o.bind("photo:added",function(e){t.photoIds.push(e.id)}),o.bind("photo:deleted",function(e){t.photoIds=_.without(t.photoIds,e.id)})}}},initPoiInfoWindowHandlers:function(t){this.inPlanningMode()&amp;&amp;t.isEditable()&amp;&amp;$("#poiInfoWindowContent select.poiType").msDropDown()},contentForPoiInfoWindow:function(t,e){return void 0==e&amp;&amp;(e=!1),this.inPlanningMode()&amp;&amp;t.isEditable()&amp;&amp;rwgps.config.privileges.advanced_planning?t.editHtml():e?t.previewHtml():t.showHtml()},deletePoi:function(t){t=t||this.openPoi,t&amp;&amp;(t.marker.gmarker.setMap(null),this.pointsOfInterest.splice(_.indexOf(this.pointsOfInterest,t),1),this.activeRoute.pois.splice(_.indexOf(this.activeRoute.pois,t),1),t.id&amp;&amp;(delete this.poisById[t.id],rwgps.Events.trigger("pois:deleted",[t])),this.closePreviewInfoWindow(),this.closeStickyInfoWindow(),this.snapshot(),rwgps.Events.trigger("pois:populate",this.activePointsOfInterest()))},closeStickyInfoWindow:function(){if(this.openPoi){if(this.openPoi.marker&amp;&amp;this.openPoi.marker.enableMouseOverOut(),this.openPoi._new){var t=this.openPoi;t.marker.gmarker.setMap(null);var e=_.indexOf(this.pointsOfInterest,t);this.pointsOfInterest.splice(e,1),t.id&amp;&amp;delete this.poisById[t.id],rwgps.Events.trigger("pois:populate",this.activePointsOfInterest())}this.openPoi=null}this.stickyInfoWindow&amp;&amp;this.stickyInfoWindow.close(),this.enableClicks()},closePreviewInfoWindow:function(){this.openPoi=null,this.previewInfoWindow&amp;&amp;this.previewInfoWindow.close(),this.enableClicks()},savePoi:function(t){t=t||this.openPoi,t&amp;&amp;(t._new&amp;&amp;delete t._new,this.poisById[t.id]=t,t.poiType=$("#poiInfoWindowContent select.poiType").val(),t.name=$("#poiInfoWindowContent .poiName").val(),t.description=$("#poiInfoWindowContent textarea.poiDescription").val(),t.attribution=$("#poiInfoWindowContent .poiAttribution").val(),t.url=$("#poiInfoWindowContent .poiUrl").val(),t.addToPoiLibrary=$("#poiInfoWindowContent .addToPoiLibrary").prop("checked"),t.saveOrUpdate=$("#poiInfoWindowContent input:radio[name='saveOrUpdate']:checked").val(),t.marker&amp;&amp;t.marker.gmarker.setMap(null),t.marker=new rwgps.PoiIcon(t,this),this.closeStickyInfoWindow(),rwgps.Events.trigger("pois:populate",this.activePointsOfInterest()),this.snapshot())},activePointsOfInterest:function(){return _.select(this.pointsOfInterest,function(t){return!t.ghosted})},pointsOfInterestObjs:function(){return _.map(this.pointsOfInterest,function(t){return t.toSaveObj()})},gotoLatLng:function(t,e,i){return this.gotoPoint({lat:t,lng:e},i)},gotoPoint:function(t,e){var i=this;if(!isNaN(t.lat)&amp;&amp;!isNaN(t.lng)){var o=new google.maps.LatLng(t.lat,t.lng);if(this.gmap.setCenter(o),e){var n={position:o,clickable:!0};this._gotoMarker&amp;&amp;this._gotoMarker.setMap(null);var s=new google.maps.Marker(n);this._gotoMarker=s;var r=this,a=function(){var e='&lt;div style="height:60px;margin-top:15px;text-align:center;padding-top:10px"&gt;'+('&lt;div style=\'display:flex;justify-content:space-around\'&gt;&lt;a href="javascript:;" class="route_to_point btn btn-primary"&gt;'+(r.prevClick?"Route to here":"Start route here")+"&lt;/a&gt;")+'&lt;a href="javascript:;" class="remove_marker btn btn-secondary" style="border:1px solid #f60;margin-left:10px"&gt;Remove marker&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;';r.openGenericStickyInfoWindow(t,e,!0),google.maps.event.addListener(r.stickyInfoWindow,"domready",function(){$(".route_to_point").click(function(){return rwgps.Events.trigger("map:route_to_point",t),i._gotoMarker&amp;&amp;i._gotoMarker.setMap(null),!1}),$(".remove_marker").click(function(){return Routes.activeMap.closeStickyInfoWindow(),i._gotoMarker&amp;&amp;i._gotoMarker.setMap(null),!1})})};return google.maps.event.addListener(s,"click",a),s.setMap(this.gmap),setTimeout(a,0),s}}},gotoLocation:function(t,e){var i,o=this,n=new function(){var t=this;this.done=function(e){return t.doneCb=e,this},this.fail=function(e){return t.failCb=e,this},this.resolve=function(){t.doneCb.apply(t,arguments)}},s=t.match(/^[ ]*(-?[0-9]+\.[0-9]+)[ ]*,?[ ]*(-?[0-9]+\.[0-9]+)[ ]*$/);if(rwgps.places[t])return i=this.gotoLatLng(rwgps.places[t].y,rwgps.places[t].x,e),{done:function(t){t.call(o,i)}};if(s)return i=this.gotoLatLng(s[1],s[2],e),_.defer(function(){n.resolve(i)}),n;var r=new google.maps.Geocoder,a={address:t,location:this.gmap.getCenter(),bounds:this.gmap.getBounds(),language:this.language,region:this.region};return r.geocode(a,function(t,i){if(i==google.maps.GeocoderStatus.OK)if(t.length&gt;0&amp;&amp;t[0].geometry){var s=t[0].geometry.location;n.resolve(o.gotoPoint({lat:s.lat(),lng:s.lng()},e))}else n.failCb();else n.failCb()}),n},geocode:function(t,e,i){var o=this,n=new google.maps.Geocoder,s={address:t,location:this.gmap.getCenter(),bounds:this.gmap.getBounds(),language:this.language,region:this.region};n.geocode(s,function(t,n){o.geocodingResponse(t,n,e,i)})},reverseGeocode:function(t,e,i){var o=this,n=new google.maps.Geocoder,s={latLng:t,language:this.language,region:this.region};n.geocode(s,function(t,n){o.geocodingResponse(t,n,e,i)})},geocodingResponse:function(t,e,i,o){if(e==google.maps.GeocoderStatus.OK){var n,s,r={};t.length&gt;0&amp;&amp;t[0].address_components?(t[0].geometry&amp;&amp;t[0].geometry.location&amp;&amp;(r.lat=t[0].geometry.location.lat(),r.lng=t[0].geometry.location.lng()),_.each(t[0].address_components,function(t){_.each(t.types,function(e){"country"==e&amp;&amp;(r.country_code=t.short_name),"administrative_area_level_1"==e&amp;&amp;(r.administrative_area=t.long_name),"locality"==e&amp;&amp;(r.locality=t.long_name),"postal_code"==e&amp;&amp;(r.postal_code=t.long_name),"administrative_area_level_2"==e&amp;&amp;(n=t.long_name),"administrative_area_level_3"==e&amp;&amp;(s=t.long_name)})}),r.administrative_area||(n?r.administrative_area=n:r.administrative_area=s),i(r)):i({})}else"ZERO_RESULTS"===e?i({}):o(e)},drawCoursePointIcons:function(t){var e=this,i=this.showCoursePointIcons;(i||this.inPlanningMode())&amp;&amp;_.map(t,function(t){if(i)if(t.marker)t.marker.gmarker.setMap(e.gmap);else{var o=new rwgps.CoursePointIcon(t,e);t.marker=o}})},removeCoursePointIcons:function(t){_.map(t,function(t){t.marker&amp;&amp;t.marker.gmarker&amp;&amp;t.marker.gmarker.setMap(null)})},populateCuesheet:function(t,e){void 0===e&amp;&amp;(e=!1),rwgps.Events.trigger("cp:populate",t,e)},resize:function(){if(this.activeRoute||this.staticBounds){google.maps.event.trigger(this.gmap,"resize");var t=this.inclusiveBounds();t.isEmpty()||this.gmap.fitBounds(t)}},setColor:function(t,e){this.lineColor=parseInt(t),e||rwgps.Events.trigger("map:colorChanged",rwgps.Segment.cssColor(this.lineColor))},showCoursePointMarker:function(t){this.coursePointPopup.setCoursePoint(t),this.coursePointPopup.show()},hideCoursePointMarker:function(){this.coursePointPopup.hide()},enableAddCoursePoint:function(){this.addCoursePointEnabled=!0,this.disableClicks(),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.bind("pointselected",this.addCoursePointAtIndex)},disableAddCoursePoint:function(){this.addCoursePointEnabled=!1,this.enableClicks(),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.unbind("pointselected",this.addCoursePointAtIndex)},addControlPointAtIndex:function(t){var e=this.activeRoute.trackPoints()[t.closestI];if(!e.isControlPoint){var i=_.indexOf(e.segment.trackPoints,e);e.segment.splitAfter(i)}},addCoursePointAtIndex:function(t){var e=this.activeRoute.trackPoints()[t.closestI];this.openCoursePointInfoWindow(new rwgps.CoursePoint({point:e.point,trackPoint:e,segment:e.segment,distance:e.distance}))},enableAddControlPoint:function(){this.addControlPointEnabled=!0,this.disableClicks(),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.bind("pointselected",this.addControlPointAtIndex),rwgps.Events.bind("map:control_point_clicked",this.onControlPointClickRemove)},onControlPointClickRemove:function(t){if(!(t.trackPoint.nextSegment&amp;&amp;t.trackPoint.prevSegment&amp;&amp;(t.trackPoint.prevSegment.drawInactive===!0&amp;&amp;t.trackPoint.nextSegment.drawInactive===!1||t.trackPoint.prevSegment.drawInactive===!1&amp;&amp;t.trackPoint.nextSegment.drawInactive===!0))){var e=t.trackPoint.prevSegment;e.slurpNext(),t.map.drawCoursePointIcons(e.coursePoints),t.map.drawRouteDistanceMarkers(t.map.activeRoute),t.map.snapshot({updateLast:!0})}},disableAddControlPoint:function(){this.addControlPointEnabled=!1,this.enableClicks(),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.unbind("pointselected",this.addControlPointAtIndex),rwgps.Events.unbind("map:control_point_clicked",this.onControlPointClickRemove)},enableRouteSplitter:function(){this.routeSplitterEnabled=!0,this.disableClicks(),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.bind("pointselected",this.splitRouteAtIndex,this)},disableRouteSplitter:function(){this.routeSplitterEnabled=!1,this.enableClicks(),Routes.sampleGraph&amp;&amp;Routes.sampleGraph.unbind("pointselected",this.splitRouteAtIndex)},splitRouteAtIndex:function(t){this.addControlPointAtIndex(t);var e=this.activeRoute.trackPoints()[t.closestI];return this.splitRouteOnTrackPoint({trackPoint:e,idx:t.closestI})},openCoursePointInfoWindow:function(t,e){void 0===e&amp;&amp;(e=!0);var i,o;if(e)o=!0;else{if(this.stickyInfoWindow&amp;&amp;$("#coursePointInfoWindowContent").get(0))return;o=!1}this.stickyInfoWindow&amp;&amp;this.stickyInfoWindow.close(),this.previewInfoWindow&amp;&amp;this.previewInfoWindow.close(),i=new google.maps.InfoWindow({position:t.googleLatLng(),maxWidth:220,disableAutoPan:!o,content:this.contentForCoursePointInfoWindow(t)}),google.maps.event.addListener(i,"closeclick",$.proxy(this.closeCoursePoint,this)),e&amp;&amp;(google.maps.event.addListener(i,"domready",$.proxy(function(){this.initPointPhotoWidget(t),this.initInfoWindowHandlers()},this)),this.disableClicks(),this.openCoursePoint=t),i.open(this.gmap),e?(this.stickyInfoWindow=i,this.previewInfoWindow=null):(this.stickyInfoWindow=null,this.previewInfoWindow=i)},contentForCoursePointInfoWindow:function(t){return this.inPlanningMode()&amp;&amp;rwgps.config.privileges.advanced_planning?t.editHtml():t.showHtml()},deleteCoursePoint:function(t){t=t||this.openCoursePoint,t&amp;&amp;(t.segment.removeCoursePoint(t),this.closeCoursePoint(),this.snapshot())},closeCoursePoint:function(){this.openCoursePoint=null,this.stickyInfoWindow&amp;&amp;(this.stickyInfoWindow.close(),this.enableClicks())},saveCoursePoint:function(t){if(t=t||this.openCoursePoint){var e=t.row;t.type=$("#coursePointInfoWindowContent select.coursePointType").val(),t.notes=$("#coursePointInfoWindowContent textarea.coursePointDescription").val(),t.description=$("#coursePointInfoWindowContent textarea.coursePointLongDescription").val(),t.edited=!0,Routes&amp;&amp;Routes.Common&amp;&amp;(t.row=Routes.Common.createCoursePointRow(t)),t.marker||(t.marker=new rwgps.CoursePointIcon(t,this)),e?e.after(t.row).remove():(t.segment.insertCoursePoint(t),rwgps.Events.trigger("cp:populate",t.segment.route.coursePoints(),!1)),this.closeCoursePoint(),this.snapshot()}},initializeLocallySavedRoute:function(){"plan"==this.mode&amp;&amp;$.jStorage.deleteKey("locallySavedRoute")},callWhenReady:function(t){var e=this;if(this._mapIsReady)t();else if(this.gmap&amp;&amp;null!=this.gmap.getMapTypeId())_.defer(function(){e._mapIsReady=!0,t()});else{var i=this;setTimeout(function(){i.callWhenReady(t)},100)}},setOption:function(t,e){var i=this;switch(t.match("avoid")&amp;&amp;this.clickOptions.setOption(t,e),t){case"show_coursepoint_icons":this.showCoursePointIcons=e,e?this.drawCoursePointIcons(this.activeRoute.coursePoints()):this.removeCoursePointIcons(this.activeRoute.coursePoints());break;case"show_control_point_icons":this.showControlPointIcons=e,e?this.activeRoute.drawControlPoints(this):this.activeRoute.clearControlPoints();break;case"auto_center":this.opts.autoCenter=e;break;case"show_distance_markers":this.distanceMarkersEnabled(e);break;case"generate_cues":this.generateCues(e);break;case"show_pois":if(this.opts.poiEnabled=e,e)for(var o=0;o&lt;this.pointsOfInterest.length;o++)this.pointsOfInterest[o].marker.gmarker.setMap(this.gmap);else for(var n=0;n&lt;this.pointsOfInterest.length;n++)this.pointsOfInterest[n].marker.gmarker.setMap(null);break;case"enable_scrollwheel_zoom":this.gmap.set("scrollwheel",!!e),this.opts.scrollwheel=e;break;case"show_surface":this.opts.showSurface=e,e?this.activeRoute.segments.forEach(function(t){return t.sPolylines.forEach(function(t){return t.setMap(i.gmap)})}):this.activeRoute.segments.forEach(function(t){return t.sPolylines.forEach(function(t){return t.setMap(null)})})}},loadElevationProfile:function(){this.debouncedLoadElevationProfile||(this.debouncedLoadElevationProfile=_.debounce(this.realLoadElevationProfile,100)),this.debouncedLoadElevationProfile()},realLoadElevationProfile:function(){if(0!=$("#elevation_profile").length){var t=this.activeRoute.trackPoints();if(Routes.sampleGraph){if(this.inPlanningMode()&amp;&amp;!this.badEleLoadSemaphore){var e=_.filter(t,function(t){return!t.fetchingEle&amp;&amp;t.lat&amp;&amp;t.lng&amp;&amp;(void 0===t.ele||null===t.ele)});if(e.length&gt;0){this.badEleLoadSemaphore=!0;var i=this;setTimeout(function(){delete i.badEleLoadSemaphore},5e3),this.fetchElevations(e,$.proxy(function(){this.loadElevationProfile(),this.snapshot({updateLast:!0})},this),function(t){trace(t)})}}Routes.sampleGraph.data(t),Routes.sampleGraph.render(),this.afterLoadElevationProfileFn&amp;&amp;this.afterLoadElevationProfileFn()}else{var o=this;setTimeout(function(){o.loadElevationProfile()},100)}}},setPlaybackSpeed:function(t){try{Routes.sampleGraph.setPlaybackSpeed(t)}catch(t){}},setPlaybackPercentage:function(t){try{Routes.sampleGraph.setPlaybackPercentage(t)}catch(t){}},startPlayback:function(){try{Routes.sampleGraph.play(),this._playing=!0,this._paused=!1,google.maps.event.clearListeners(this.gmap,"mousemove")}catch(t){}},pause:function(){try{Routes.sampleGraph.pause(),this._playing=!1,this._paused=!0}catch(t){}},stopPlayback:function(){try{Routes.sampleGraph.stopPlayback(),this._playing=!1,this._paused=!1,this.unhighlightNearestPoint(),this.keepPlayheadStopped=!0;var t=this;setTimeout(function(){t.keepPlayheadStopped=!1},250),google.maps.event.clearListeners(this.gmap,"mousemove"),google.maps.event.addListener(this.gmap,"mousemove",$.proxy(this.onMouseMove,this))}catch(t){}},updatePlayhead:function(t,e){if(t&amp;&amp;t.time&amp;&amp;!this.keepPlayheadStopped){e||(e=this.activeRoute.trackPoints());var i=t.time,o=e[0].time,n=e[e.length-1].time;n||(n=e[e.length-2].time);var s=i-o,r=Math.round(100*s/(n-o));$.ui&amp;&amp;$.ui.slider&amp;&amp;$("#elapsed_time_slider").data("ui-slider")&amp;&amp;($("#elapsed_time_slider").slider("option","value",r),$("#elapsed_time").html(rwgps.LabelMaker.durationLabel(s)))}},googleLatLngToPoint:function(t){var e=this.gmap.getZoom(),i=this.gmap.getProjection().fromLatLngToPoint(t),o=Math.pow(2,e),n=new google.maps.Point(i.x*o,i.y*o);return n},pointToGoogleLatLng:function(t){var e=this.gmap.getZoom(),i=Math.pow(2,e),o=new google.maps.Point(t.x/i,t.y/i),n=this.gmap.getProjection().fromPointToLatLng(o);return n},googleLatLngToContainerPoint:function(t){var e=this.gmap.getProjection(),i=this.gmap.getBounds(),o=e.fromLatLngToPoint(i.getNorthEast()),n=e.fromLatLngToPoint(i.getSouthWest()),s=Math.pow(2,this.gmap.getZoom()),r=e.fromLatLngToPoint(t);return new google.maps.Point((r.x-n.x)*s,(r.y-o.y)*s)},gBoundsToObj:function(t){var e=t.getNorthEast(),i=t.getSouthWest();return{ne:{lat:e.lat(),lng:e.lng()},sw:{lat:i.lat(),lng:i.lng()}}},getBounds:function(){var t=this.gmap.getBounds(),e=t.getNorthEast(),i=t.getSouthWest();return{ne:{lat:e.lat(),lng:e.lng()},sw:{lat:i.lat(),lng:i.lng()}}},eliminateLoneSurfaces:function(t){var e=rwgps.surfaces.surfaceGroups,i=161,o=[],n=void 0,s=void 0,r=function(){return o.length&lt;4?0:t[n-1].distance-t[n-(o.length-2)].distance};for(n=0;n&lt;t.length;n++){for(s=t[n],o.push(e[s.surface]);r()&gt;i;)o.shift();if(o.length&gt;2){var a=o.length;if(o[0]!==o[a-2]&amp;&amp;o[0]===o[a-1])for(var l=1;l&lt;a-1;l++){var h=t[n-l];h.roadClass=s.roadClass,h.ghSurface=s.ghSurface,h.surface=s.surface,o[a-l-1]=e[s.surface]}}}},injectSurfaces:function(t,e){var i=this;t.forEach(function(t){t.fetchingSurface=!0});for(var o=[],n=0,s=70;n&lt;=t.length;)o.push(t.slice(n,n+s)),n+=s;var r=function(t){return function(e){var i=JSON.stringify({track_points:t.map(function(t){return t.point?{y:t.point.lat,x:t.point.lng}:{y:0,x:0}})});$.ajaxSettings.stopCSRF=!0,$.ajax({url:"https://directions.ridewithgps.com/surfaceinjector",dataType:"json",contentType:"application/json",type:"POST",data:i,success:function(i){var o,n,s;i.track_points.forEach(function(e,i){o=rwgps.surfaces.roadClassToInt[e.R],n=rwgps.surfaces.surfaceToInt[e.S],s=rwgps.TrackPoint.inferSurface(n,o,e.y,e.x),void 0===s&amp;&amp;(n=99,s=99),t[i].roadClass=o,t[i].ghSurface=n,t[i].surface=s,t[i].roadEnv=["bridge","tunnel"].includes(e.RE)?1:0}),e(null,t)},error:function(t){return e(t,null)}})}};async.parallelLimit(o.map(r),6,function(o){if(o)return void e("No routes found");t.forEach(function(t){delete t.fetchingSurface});var n=t[0].segment&amp;&amp;t[0].segment.prevControlPoint.prevSegment;n?i.eliminateLoneSurfaces(n.trackPoints.concat(t)):i.eliminateLoneSurfaces(t);var s=window.Routes.activeMap;!s.activeRoute.showSurface&amp;&amp;rwgps.config.labs.surface_types&amp;&amp;rwgps.config.labs.route_planner&amp;&amp;(s.activeRoute.showSurface=!0,Routes.sampleGraph.showSurface(!0)),s.activeRoute.recalculatePolylines(),window.rwgps.Events.trigger("surfacesChanged"),_.find(t,function(t){return t.fetchingEle})||(s.activeRoute.flattenBridgesAndTunnels(),s.loadElevationProfile(),s.snapshot({updateLast:!0}))})},fetchElevations:function(t,e){for(var i=0,o=t.length;i&lt;o;i++)t[i].fetchingEle=!0;for(var n=[],s=0,r=70;s&lt;=t.length;)n.push(t.slice(s,s+r)),s+=r;for(var a=0,l=0;l&lt;n.length;l++)a+=1,function(t){for(var i="",o="",s=n[t],r=0;r&lt;s.length;r++)i+=Math.round(1e6*s[r].point.lat)/1e6+",",o+=Math.round(1e6*s[r].point.lng)/1e6+",";i=i.slice(0,i.length-1),o=o.slice(0,o.length-1),$.ajax({url:"https://gis.ridewithgps.com/get_eles",data:{lats:i,lngs:o},dataType:"jsonp",type:"get",success:function(t){for(r=0;r&lt;s.length;r++)s[r].ele=t[r],delete s[r].fetchingEle,delete s[r].flattened;a-=1,0==a&amp;&amp;e()},error:function(t,e,i){for(r=0;r&lt;s.length;r++)delete s[r].fetchingEle}})}(l)}},rwgps.CoursePointPopup=function(t){this.map=t,this.div=$("&lt;div/&gt;"),this.div.css({position:"absolute",background:"#FFF","z-index":10,padding:3,border:"1px solid black"})},rwgps.CoursePointPopup.prototype={setCoursePoint:function(t){if(!t)return null;var e=this.map.googleLatLngToContainerPoint(t.googleLatLng()),i=$("#"+this.map.opts.targetDiv).offset().left,o=e.x+20+i;if(this.div.html(""),t.photoIds.length&gt;0){this.div.css({width:150,height:65});var n=$("&lt;div style='float:left;border:1px solid #CCC;padding:2px;width:60px;height:60px;margin-right:3px;'/&gt;");n.append("&lt;img class='left' src='/photos/micro/"+t.photoIds[0]+".jpg' /&gt;"),this.div.append(n)}else this.div.css({width:120,height:30});this.div.append("&lt;span class='left'&gt;&lt;b&gt;"+t.type+"&lt;/b&gt;&lt;/span&gt;"),this.div.css({left:o,top:e.y+20})},show:function(){$("body").append(this.div)},hide:function(){this.div.remove()}},rwgps.MouseSpeedometer=function(){this.speed=this.x=this.y=this.t=0},rwgps.MouseSpeedometer.ZERO_TIMEOUT=100,rwgps.MouseSpeedometer.UPDATE_THROTTLE=50,rwgps.MouseSpeedometer.prototype.update=function(t,e){var i=this,o=(new Date).getTime(),n=!1;if(this.t&gt;0){var s=t-this.x,r=e-this.y,a=o-this.t;if(a&gt;rwgps.MouseSpeedometer.UPDATE_THROTTLE){var l=Math.sqrt(s*s+r*r)/a;this.speed=.8*this.speed+.2*l,n=!0,this.zeroTimeout&amp;&amp;clearTimeout(this.zeroTimeout),this.zeroTimeout=setTimeout(function(){i.speed=0},rwgps.MouseSpeedometer.ZERO_TIMEOUT)}}else n=!0;n&amp;&amp;(this.x=t,this.y=e,this.t=o)},rwgps.Icon=function(){},rwgps.Icon.prototype={map:null,icon:null,shadow:null,gmarker:null,init:function(t,e){e||(e={}),t||(t={});var i=this.icon;this.size&amp;&amp;(i={scaledSize:this.size,url:this.icon}),e=$.extend({position:new google.maps.LatLng(t.lat,t.lng),clickable:!0,icon:i,shadow:this.shadow},e),this.gmarker=new google.maps.Marker(e),this.map&amp;&amp;this.gmarker.setMap(this.map.gmap);var o=this;google.maps.event.addListener(this.gmarker,"mouseover",_.debounce(function(){o.map.topZIndex+=1,o.gmarker.setZIndex(o.map.topZIndex)}))},enableDragEdit:function(){var t,e,i,o,n,s,r,a,l,h,p,c,g,u,d,v,m,f,w,P,k=0,y=$.proxy(function(s){this.map.draggingMarker=!1,this.dragPolyline1&amp;&amp;(this.dragPolyline1.setMap(null),this.dragPolyline1.setPath([]),this.dragPolyline1=null),this.dragPolyline2&amp;&amp;(this.dragPolyline2.setMap(null),this.dragPolyline2.setPath([]),this.dragPolyline2=null),t&amp;&amp;t.removeFromMap(),e&amp;&amp;e.removeFromMap();var r,a,p,c,g,m,P,_=new rwgps.TrackPoint({point:{lat:s.latLng.lat(),lng:s.latLng.lng()}});if(u&amp;&amp;(g=[_,n],m=w,P=e),(v||d)&amp;&amp;(g=[o,_],m=f,P=t),m){if(!l)return trace("Aborting drag/drop, expected results and there are none"),t&amp;&amp;t.addToMap(this.map),e&amp;&amp;e.addToMap(this.map),this.map.loadElevationProfile(),this.map.relabel(),this.map.activeRoute.calculateMetrics(),this.map.activeRoute.rebuildBounds(),this.map.drawRouteDistanceMarkers(this.map.activeRoute),this.map.drawCoursePointIcons(this.map.activeRoute.coursePoints()),this.map.populateCuesheet(this.map.activeRoute.coursePoints()),this.map.snapshot(),void google.maps.event.addListener(this.map.gmap,"mousemove",$.proxy(this.map.onMouseMove,this.map));r=l,a=h}else r=rwgps.Segment.fillTheCracks(g),a=[];var k,y;if(!u&amp;&amp;t.prevSegment){var M=t.prevSegment,S=M.nextControlPoint;r[0].pointEquals(S.point)&amp;&amp;r.shift(),k=S}else k=r.shift();e&amp;&amp;e.nextSegment?(r.length&gt;0&amp;&amp;r[r.length-1].pointEquals(e.nextControlPoint.point)&amp;&amp;r.pop(),y=!v||w&amp;&amp;f?e.nextControlPoint:r.pop()):y=r.pop(),p=new rwgps.Segment(this.map.activeRoute,k,y,r,a,P.color),p.clickOptions.setOptions(P.clickOptions.getOptions()),i&amp;&amp;(i.trackPoint=p.prevControlPoint,i.gmarker.setPosition(p.prevControlPoint.googleLatLng()));var I=p.nextControlPoint;if(v){var C;if(w)if(f){this.trackPoint=new rwgps.TrackPoint({point:{lat:s.latLng.lat(),lng:s.latLng.lng()}});for(var b=0,x=99999,O=0;O&lt;p.trackPoints.length;O++){var R=p.trackPoints[O],L=R.distanceFromPoint(this.trackPoint);L&lt;x&amp;&amp;(x=L,b=O)}x&lt;99999&amp;&amp;(c=p.splitAfter(b-1))}else r=l,r[0].pointEquals(I.point)&amp;&amp;r.shift(),C=e.nextSegment?e.nextControlPoint:r.pop(),a=h,c=new rwgps.Segment(this.map.activeRoute,I,C,r,a,e.color),c.clickOptions.setOptions(e.clickOptions.getOptions());else r=rwgps.Segment.fillTheCracks([_,n]),r[0].pointEquals(I.point)&amp;&amp;r.shift(),e.nextSegment?(C=e.nextControlPoint,r.length&gt;0&amp;&amp;r[r.length-1].pointEquals(C.point)&amp;&amp;r.pop()):C=r.pop(),a=[],c=new rwgps.Segment(this.map.activeRoute,I,C,r,a,e.color),c.clickOptions.setOptions(e.clickOptions.getOptions())}c=c||p,c.nextSegment||(this.map.prevClick=c.nextControlPoint.point);for(var A=$.proxy(function(){this.loadElevationProfile(),this.relabel(),this.activeRoute.calculateMetrics(),this.activeRoute.rebuildBounds(),this.activeRoute.redrawPolylines(),this.activeRoute.flattenBridgesAndTunnels(),this.drawRouteDistanceMarkers(this.activeRoute),this.drawCoursePointIcons(this.activeRoute.coursePoints()),this.populateCuesheet(this.activeRoute.coursePoints()),this.snapshot(),v&amp;&amp;rwgps.checkSpur(p)},this.map),E=p.route.trackPoints(),T=[],D=0;D&lt;E.length;D++)void 0!=E[D].ele&amp;&amp;null!=E[D].ele||T.push(E[D]);T.length&gt;0?this.map.fetchElevations(T,A,function(t){trace(t)}):A();var W=Routes.activeMap.activeRoutingService;"google"===W.opts.id&amp;&amp;this.map.injectSurfaces(T,function(){}),google.maps.event.addListener(this.map.gmap,"mousemove",$.proxy(this.map.onMouseMove,this.map))},this);if(google.maps.event.addListener(this.gmarker,"dragstart",$.proxy(function(){function M(){if($(window).unbind("mouseup",M),S instanceof rwgps.StartIcon&amp;&amp;0===S.map.activeRoute.segments.length){var t=S.gmarker.getPosition();S.map.prevClick={lat:t.lat(),lng:t.lng()}}S.map.draggingMarker&amp;&amp;(google.maps.event.clearInstanceListeners(S),k?P=function(){y(p)}:y(p))}if(this.map.opts.tripId)return void rwgps.Events.trigger("trip:modification_prevented");if(!this.map.draggingMarker){rwgps.unhighlightPoints(!0),this.map.clearSegment(),this.map.removeRouteDistanceMarkers(this.map.activeRoute),c=!(this instanceof rwgps.NearestPointIcon),g=i=u=d=v=m=f=w=e=o=n=s=r=l=h=p=P=void 0,a=new rwgps.MouseSpeedometer,k=0,p={};var S=this;if($(window).mouseup(M),c){if(m=!1,g=this,!this.trackPoint){if(0==this.map.activeRoute.segments.length)return;this.trackPoint=this.map.activeRoute.firstSegment.prevControlPoint}t=this.trackPoint.segment||this.trackPoint.prevSegment||this.trackPoint.nextSegment,e=t.nextSegment,this instanceof rwgps.StartIcon&amp;&amp;(i=this,e=t,t=null)}else{m=!0,t=this.map.nearestMousePointBehind.segment||this.map.nearestMousePointBehind.nextSegment;var I=_.indexOf(t.trackPoints,this.map.nearestMousePointBehind),C=this.map.nearestInterpolatedMousePoint,b=this.map.nearestMousePointBehind.distance+this.map.nearestMousePointBehind.distanceFromLatLng(C),x=new rwgps.TrackPoint({point:C});x.distance=b,t.insertTrackPointAfter(x,I),e=t.splitAfter(I&lt;0?-1:I+1),this.trackPoint=x,g=t.controlPointIcon,g.gmarker.setVisible(!1),c=!0}if(t&amp;&amp;!t.prevSegment&amp;&amp;t.route.startMarker&amp;&amp;(i=t.route.startMarker),u=!t,d=!e,(u||d||t.clickOptions.getOptions()==e.clickOptions.getOptions())&amp;&amp;(m=!0),v=!u&amp;&amp;!d,m){var O=this.map.clickOptions.getOptions();t&amp;&amp;t.clickOptions.setOptions(O),e&amp;&amp;e.clickOptions.setOptions(O)}if(t&amp;&amp;(f=!!t.clickOptions.followRoads()),e&amp;&amp;(w=!!e.clickOptions.followRoads()),n=e?e.nextControlPoint:t.nextControlPoint,o=t?t.prevControlPoint:e.prevControlPoint,this.map.draggingMarker=!0,google.maps.event.clearListeners(this.map.gmap,"mousemove"),t&amp;&amp;(t.clearCoursePointMarkers(),t.gPolylines.forEach(function(t){return t.setMap(null)}),t.backgroundPolyline&amp;&amp;t.backgroundPolyline.setMap(null)),e&amp;&amp;(e.clearCoursePointMarkers(),e.gPolylines.forEach(function(t){return t.setMap(null)}),e.backgroundPolyline&amp;&amp;e.backgroundPolyline.setMap(null)),f||w){s=this.map.activeRoutingService;var R=$.proxy(function(t,e,i,o){var n=this,r="dragPolyline"+(o||1);k+=1,s.getDirections(t,e,i,function(e,i){if(null!=e&amp;&amp;0!=e.length){n.map.opts.generateCues||(i=null);
var o=_.map(e,function(t){return t.point});e[0].pointEquals(t[0])||o.unshift(t[0]),e[e.length-1].pointEquals(t[t.length-1])||o.push(t[t.length-1]);var s=o.map(function(t){return new google.maps.LatLng(t.lat,t.lng)});n[r]?n[r].setPath(s):n[r]=new google.maps.Polyline({path:s,map:n.map.gmap}),l=e,h=i,k-=1,0==k&amp;&amp;P&amp;&amp;P()}},function(t){trace(["error while requesting directions on drag to edit",t]),k-=1,0==k&amp;&amp;P&amp;&amp;P()}),window.dragCount?window.dragCount+=1:window.dragCount=1;var a=rwgps.config.labs.prevent_sticky_gmaps?"A":"B";trackEvent("Google Maps","Direction Request (Drag - "+a+")",s.opts.type),trackEvent("Google Maps","Direction Request (Drag)",s.opts.type)},this),L=2e3,A=900,E=.09,T=void 0,D=void 0,W=void 0,B=L,N=!0,G=!1,F=function(){N=!0};r=function(){var t=0;if(!G&amp;&amp;a.speed&lt;E&amp;&amp;(G=!0,N=!0,t=A),G&amp;&amp;a.speed&gt;=E&amp;&amp;(G=!1,t=L),T&amp;&amp;(T=!1,k--,clearTimeout(D)),N)R.apply(null,arguments),t||(t=B);else{k++,T=!0;var e=arguments;D=setTimeout(function(){T=!1,k--,R.apply(null,e)},rwgps.MouseSpeedometer.ZERO_TIMEOUT+100)}t&gt;0&amp;&amp;(N=!1,W&amp;&amp;clearTimeout(W),W=setTimeout(F,t),B=t)}}}},this)),!this.map.opts.tripId){var M=$.proxy(function(t,e,i){var o=t.map(function(t){return new google.maps.LatLng(t.lat,t.lng)}),n="dragPolyline"+(e||1);if(i){var s,r;1==e?(s=this.dragPolyline2)&amp;&amp;(r=s.getPath(),r.insertAt(0,o[o.length-1]),s.setPath(r)):(s=this.dragPolyline1)&amp;&amp;(r=s.getPath(),r.push(o[0]),s.setPath(r))}this[n]?this[n].setPath(o):this[n]=new google.maps.Polyline({path:o,map:this.map.gmap})},this);google.maps.event.addListener(this.gmarker,"drag",$.proxy(function(i){var s={lat:i.latLng.lat(),lng:i.latLng.lng()};if(a.update(i.pixel.x,i.pixel.y),p=i,v&amp;&amp;f!=w){var l=[o.point,s],h=[s,n.point];f?r(l,t.clickOptions,t.color):M(l,1,!0),w?r(h,e.clickOptions,e.color,2):M(h,2,!0)}else{var c;c=u?[s,n.point]:d?[o.point,s]:o&amp;&amp;n?[o.point,s,n.point]:[];var g=u&amp;&amp;w||d&amp;&amp;f||f&amp;&amp;w;if(g){var m=this.map.clickOptions.getProviderOptions()|this.map.clickOptions.getRestrictionOptions();u?(e.clickOptions.setPartialOptions(m),r(c,e.clickOptions,e.color)):(t.clickOptions.setPartialOptions(m),r(c,t.clickOptions,t.color))}else M(c)}},this));var S=this;google.maps.event.addListener(this.gmarker,"dragend",function(t){S.map.draggingMarker&amp;&amp;(google.maps.event.clearInstanceListeners(S),k?P=function(){y(t)}:y(t))})}},_dragEndDirectionsHandler:function(){},_dragEndPolylineHandler:function(){}},rwgps.CoursePointIcon=function(t,e){this.coursePoint=t,this.icon="/images/cue_icon.png",t.deleted&amp;&amp;(this.icon="/images/cue_deleted_icon.png"),t.selected?this.size=new google.maps.Size(36,40):this.size=new google.maps.Size(24,27),this.shadow=new google.maps.MarkerImage("/images/cp_icon_shadow.png",new google.maps.Size(32,22),new google.maps.Point(0,0),new google.maps.Point(3,22)),this.init(t.point),e&amp;&amp;this.setMap(e)},rwgps.CoursePointIcon.prototype=new rwgps.Icon,rwgps.CoursePointIcon.prototype.setMap=function(t){var e=this,i=this;this.map=t,this.gmarker.setMap(t.gmap),google.maps.event.addListener(this.gmarker,"click",function(){t.inCueReview||t.openCoursePointInfoWindow(i.coursePoint)}),google.maps.event.addListener(this.gmarker,"mouseover",function(){t.coursePointPopup.setCoursePoint(i.coursePoint),t.coursePointPopup.show()}),google.maps.event.addListener(this.gmarker,"mouseout",function(){t.coursePointPopup.hide()}),rwgps.onRightClick&amp;&amp;google.maps.event.addListener(this.gmarker,"rightclick",function(t){return rwgps.onRightClick(t,"coursePoint",e)})},rwgps.PoiIcon=function(t,e){var i,o=this;this.poi=t;var n=rwgps.PointOfInterest.poiTypesById[t.poiType];n?(i=n.icon,t.ghosted&amp;&amp;(i="alt_"+i),i=rwgps.poiIconsPath()+i):i="poi_icons/generic.png",this.size=new google.maps.Size(34,40),this.icon="/images/"+i,this.init(t.point,{draggable:e.inPlanningMode()}),e.inPlanningMode()&amp;&amp;(google.maps.event.addListener(this.gmarker,"dragstart",function(){e.closePreviewInfoWindow(),e.closeStickyInfoWindow(),o.disableMouseOverOut()}),google.maps.event.addListener(this.gmarker,"dragend",function(){o.poi.point={lat:o.gmarker.position.lat(),lng:o.gmarker.position.lng()},o.enableMouseOverOut()}),rwgps.onRightClick&amp;&amp;google.maps.event.addListener(this.gmarker,"rightclick",function(t){return rwgps.onRightClick(t,"pointOfInterest",o)})),e&amp;&amp;this.setMap(e)},rwgps.PoiIcon.prototype=new rwgps.Icon,rwgps.PoiIcon.prototype.clickHandler=function(){this.mouseUpInAction=!1,this.map.openStickyInfoWindow(this.poi),rwgps.Events.trigger("pois:click",this.poi)},rwgps.PoiIcon.prototype.disableMouseOverOut=function(){google.maps.event.clearListeners(this.gmarker,"mouseup"),google.maps.event.clearListeners(this.gmarker,"mouseover"),google.maps.event.clearListeners(this.gmarker,"mouseout")},rwgps.PoiIcon.prototype.enableMouseOverOut=function(){google.maps.event.addListener(this.gmarker,"mouseup",$.proxy(this.mouseUpHandler,this)),google.maps.event.addListener(this.gmarker,"mouseover",$.proxy(this.mouseOverHandler,this)),google.maps.event.addListener(this.gmarker,"mouseout",$.proxy(this.mouseOutHandler,this))},rwgps.PoiIcon.prototype.mouseOverHandler=function(){this.map.preventPoiMouseover||(this.mouseUpInAction=!1,this.map.openPreviewInfoWindow(this.poi,!1),rwgps.Events.trigger("pois:mouseover",this.poi),this.map.preventPoiMouseover=!1)},rwgps.PoiIcon.prototype.mouseOutHandler=function(){this.map.preventPoiMouseover||this.mouseUpInAction||(this.map.closePreviewInfoWindow(),rwgps.Events.trigger("pois:mouseout",self.poi))},rwgps.PoiIcon.prototype.mouseUpHandler=function(){this.mouseUpInAction=!0},rwgps.PoiIcon.prototype.setMap=function(t){var e=this;this.map=t,this.gmarker.setMap(t.gmap),google.maps.event.addListener(this.gmarker,"click",function(){e.clickHandler.apply(e,arguments)}),this.enableMouseOverOut()},rwgps.StartIcon=function(t,e){var i=this;this.map=e,this.icon={url:"/images/start.svg",size:new google.maps.Size(34,47),anchor:new google.maps.Point(21,40)};var o={clickable:!0,draggable:!1};e.inPlanningMode()&amp;&amp;(o.draggable=!0),this.init(t,o),e.inPlanningMode()&amp;&amp;(this.enableDragEdit(),google.maps.event.addListener(this.gmarker,"click",function(t){e.onClickAddPoint(t)}),rwgps.onRightClick&amp;&amp;google.maps.event.addListener(this.gmarker,"rightclick",function(t){return rwgps.onRightClick(t,"startIcon",i)})),this.gmarker.setZIndex(0)},rwgps.StartIcon.prototype=new rwgps.Icon,rwgps.EndIcon=function(t,e){this.map=e,this.icon={url:"/images/stop.svg",size:new google.maps.Size(34,47),anchor:new google.maps.Point(21,40)},this.init(t)},rwgps.EndIcon.prototype=new rwgps.Icon,rwgps.PointOfInterestIcon=function(t,e){this.map=e,this.icon="/images/poi.png",this.init(t)},rwgps.PointOfInterestIcon.prototype=new rwgps.Icon,rwgps.NearestPointIcon=function(t,e){var i=this;this.map=e,this.icon=new google.maps.MarkerImage("/images/nearest_point_icon.png",new google.maps.Size(14,14),new google.maps.Point(0,0),new google.maps.Point(7,7));var o=window.Routes&amp;&amp;Routes.activeMap&amp;&amp;Routes.activeMap.inPlanningMode(),n=!!(window.Routes&amp;&amp;Routes.activeMap&amp;&amp;Routes.activeMap.opts.enableNearestPointMarkerClicks);this.init(t,{clickable:o||n,draggable:o&amp;&amp;!this.map.inCueReview,raiseOnDrag:!1,zIndex:1}),rwgps.onRightClick&amp;&amp;google.maps.event.addListener(this.gmarker,"rightclick",function(t){return rwgps.onRightClick(t,"nearestPoint",i)}),o&amp;&amp;this.enableDragEdit()},rwgps.NearestPointIcon.prototype=new rwgps.Icon,rwgps.RacerIcon=function(t,e,i){this.map=e,this.icon=new google.maps.MarkerImage("/images/icons/racers/"+i+".png",new google.maps.Size(16,16),new google.maps.Point(0,0),new google.maps.Point(8,8)),this.init(t,{clickable:!1,draggable:!1,raiseOnDrag:!1,zIndex:1})},rwgps.RacerIcon.prototype=new rwgps.Icon,rwgps.ControlPointIcon=function(t,e){var i=this;this.map=e,this.trackPoint=t,this.icon=new google.maps.MarkerImage("/images/control_point_icon.png?1",new google.maps.Size(14,14),new google.maps.Point(0,0),new google.maps.Point(7,7)),this.init(t.point,{zIndex:google.maps.Marker.MAX_ZINDEX+1,raiseOnDrag:!1,clickable:!0,draggable:!0}),this.enableDragEdit(),google.maps.event.addListener(this.gmarker,"mouseover",$.proxy(function(){this.unhighlightNearestPoint()},this.map));var o=this;google.maps.event.addListener(this.gmarker,"click",$.proxy(function(){rwgps.Events.trigger("map:control_point_clicked",o)},this.map)),rwgps.onRightClick&amp;&amp;google.maps.event.addListener(this.gmarker,"rightclick",function(t){return rwgps.onRightClick(t,"controlPoint",i)})},rwgps.ControlPointIcon.prototype=new rwgps.Icon,rwgps.ConnectionPointIcon=function(t,e){var i=this;this.map=e,this.trackPoint=t,this.overIcon=new google.maps.MarkerImage("/images/connection_point_icon.png?1",new google.maps.Size(18,18),new google.maps.Point(0,0),new google.maps.Point(9,9)),this.outIcon=new google.maps.MarkerImage("/images/connection_point_icon_transparent.png?1",new google.maps.Size(18,18),new google.maps.Point(0,0),new google.maps.Point(9,9)),this.icon=this.outIcon,this.init(t.point,{zIndex:google.maps.Marker.MAX_ZINDEX+1,raiseOnDrag:!1,clickable:!0,draggable:!1});var o=this;google.maps.event.addListener(this.gmarker,"click",$.proxy(function(){var i=_.once(function(){rwgps.Events.unbind("maps:clicks_dispatched",i);var o=t.nextSegment.route,n=e.activeRoute;o.mysqlId&amp;&amp;!n.mysqlId&amp;&amp;(n.mysqlId=o.mysqlId,n.name=o.name,n.routeData={name:o.name,id:o.routeData.id,isTrip:o.routeData.isTrip}),e.snapshotsDisabled=!0,e.removeRoute(o),e.snapshotsDisabled=!1,n.lastSegment.nextControlPoint.setNextSegment(o.firstSegment),n.segmentsChanged(),n.rebuildBounds(),n.redraw(),n.pois=n.pois.concat(o.pois),e.loadPois(n.pois);var s=n.coursePoints();e.drawCoursePointIcons(s),e.populateCuesheet(s);var r=n.trackPoints();e.prevClick=r[r.length-1].point,n.calculateMetrics(),e.drawRouteDistanceMarkers(),rwgps.Events.trigger("map:routes_changed")});rwgps.Events.bind("map:clicks_dispatched",i),e.handleClick({point:t.point,opts:e.clickOptions,color:e.lineColor,fetchEles:!0})},this.map)),google.maps.event.addListener(this.gmarker,"mouseover",$.proxy(function(){o.gmarker.setIcon(o.overIcon)},this.map)),google.maps.event.addListener(this.gmarker,"mouseout",$.proxy(function(){o.gmarker.setIcon(o.outIcon)},this.map)),rwgps.onRightClick&amp;&amp;google.maps.event.addListener(this.gmarker,"rightclick",function(t){return rwgps.onRightClick(t,"connectionPoint",i)})},rwgps.ConnectionPointIcon.prototype=new rwgps.Icon,rwgps.highlightPoints=function(t,e,i){if(Routes.activeMap){var o=Routes.activeMap,n=o.activeRoute.trackPoints().slice(t,e),s=[];if(_.each(n,function(t){t.point&amp;&amp;s.push(t.googleLatLng())}),o.highlightedPoints&amp;&amp;rwgps.unhighlightPoints(!0),o.highlightedPoints={gPolyline:new google.maps.Polyline({path:s,map:o.gmap,strokeColor:"#0000FF",strokeWeight:rwgps.Route.DEFAULT_LINE_WIDTH,clickable:!1,zIndex:1e4}),startI:t,endI:e,metrics:new rwgps.MetricsCalculator(_.map(n,function(t){return _.clone(t)})).calculate()},"only_metrics"==i)o.onMetricsChange();else if(!i){var r=new google.maps.LatLngBounds;_.each(s,function(t){r.extend(t)}),o.gmap.fitBounds(r),o.onMetricsChange()}}},rwgps.highlightDataSlice=function(t,e,i){if(Routes.activeMap){var o=Routes.activeMap,n=[];if(_.each(t.points(),function(t){t.point&amp;&amp;n.push(t.googleLatLng())}),o.highlightedPoints&amp;&amp;rwgps.unhighlightPoints(!0),o.highlightedPoints={gPolyline:new google.maps.Polyline($.extend({path:n,map:o.gmap,strokeColor:"#0000FF",strokeWeight:rwgps.Route.DEFAULT_LINE_WIDTH,clickable:!1},i)),metrics:t.metrics()},"only_metrics"==e)o.onMetricsChange();else if(!e){var s=new google.maps.LatLngBounds;_.each(n,function(t){s.extend(t)}),o.gmap.fitBounds(s),o.onMetricsChange()}}},rwgps.zoomToPoint=function(t,e){var i=Routes.activeMap,o=i.activeRoute.trackPoints()[t];rwgps.zoomToLatLng(o.point,e)},rwgps.zoomToLatLng=function(t,e){var i=Routes.activeMap;e||(e=14),i.gmap.setCenter(new google.maps.LatLng(t.lat,t.lng)),i.gmap.setZoom(e)},rwgps.zoomToPoints=function(t,e){var i=Routes.activeMap,o=i.activeRoute.trackPoints().slice(t,e);o=_.filter(o,function(t){return t.point});var n=new google.maps.LatLngBounds;_.each(o,function(t){n.extend(t.googleLatLng())}),i.gmap.fitBounds(n)},rwgps.unhighlightPoints=function(t){var e=Routes.activeMap;e&amp;&amp;e.highlightedPoints&amp;&amp;(e.highlightedPoints.gPolyline.setMap(null),delete e.highlightedPoints,t||(e.recenterMap(),e.onMetricsChange()))},rwgps.recenterMap=function(){Routes.activeMap.recenterMap()},rwgps.highlightPoint=function(t,e){var i=Routes.activeMap,o=i.activeRoute.trackPoints(),n=o[t];if(n){var s=n.point;if(s&amp;&amp;!i.keepPlayheadStopped){var r=o[t-1];if(t&gt;0&amp;&amp;e&amp;&amp;r.point){var a=r.point.lat,l=r.point.lng,h=s.lat,p=s.lng,c=(h-a)*e+a,g=(p-l)*e+l;s={lat:c,lng:g}}i._playing&amp;&amp;$("#playback_autoCenter").is(":checked")&amp;&amp;i.gmap.setCenter(new google.maps.LatLng(c,g)),i.showNearestPointMarkerAt(s),i.updatePlayhead(n,o)}}},rwgps.showMarker=function(t,e,i){var o=Routes.activeMap,n=new google.maps.LatLng(e,t);rwgps.markerSet||(rwgps.markerSet={});var s=rwgps.markerSet;if(!s[i]){var r=_.size(s)%10+1;s[i]=new rwgps.RacerIcon(n,o,r)}null==s[i].gmarker.getMap()&amp;&amp;s[i].gmarker.setMap(o.gmap),0==s[i].gmarker.getVisible()&amp;&amp;s[i].gmarker.setVisible(!0),s[i].gmarker.setPosition(n),s[i].gmarker.setZIndex(0)},rwgps.removeMarker=function(t){rwgps.markerSet&amp;&amp;rwgps.markerSet[t]&amp;&amp;(rwgps.markerSet[t].gmarker.setMap(null),delete rwgps.markerSet[t])},rwgps.Map.prototype.updateDistanceMarkersDisplayed=function(){var t=this;if(this.gmap&amp;&amp;this.opts.distanceMarkersEnabled){var e,i=this.gmap.getZoom();e=rwgps.LabelMaker.metric?i&gt;=14?0:i&gt;=13?1:i&gt;=12?2:i&gt;=10?3:4:i&gt;=13?0:i&gt;=12?1:i&gt;=11?2:i&gt;=9?3:4,e!==this._distanceMarkerLevel&amp;&amp;(this.distanceMarkers[this._distanceMarkerLevel]&amp;&amp;this.distanceMarkers[this._distanceMarkerLevel].forEach(function(t){var e=t.marker;return e.setMap(null)}),this._distanceMarkerLevel=e);var o=this.gmap.getBounds();e&lt;4&amp;&amp;o&amp;&amp;this.distanceMarkers[e].forEach(function(e){var i=e.marker;o.contains(i.latLng)?i.getMap()||i.setMap(t.gmap):i.setMap(null)})}},rwgps.Map.prototype.removeSegmentDistanceMarkers=function(t){_.each(t.distanceMarkers,function(t){try{t.setMap(null)}catch(t){}_.each(this.distanceMarkers,function(e){_.each(e,function(i,o){try{t===i.marker&amp;&amp;e.splice(o,1)}catch(t){}})})},this),t.distanceMarkers=[]},rwgps.Map.prototype.removeRouteDistanceMarkers=function(t){this._updateDistanceMarkersListener&amp;&amp;(this._updateDistanceMarkersListener.remove(),this._updateDistanceMarkersListener=null),this.distanceMarkers=[[],[],[],[]],_.each(t.segments,function(t){t.distanceMarkers.forEach(function(t){return t.setMap(null)}),t.distanceMarkers=[]}),this._distanceMarkerLevel=null},rwgps.Map.prototype.drawRouteDistanceMarkers=function(t){t||(t=this.activeRoute),this.removeRouteDistanceMarkers(t),_.each(t.segments,function(t){this.drawSegmentDistanceMarkers(t,!0)},this),this.updateDistanceMarkersDisplayed(),this.gmap&amp;&amp;(this._updateDistanceMarkersListener=this.gmap.addListener("bounds_changed",_.throttle(this.updateDistanceMarkersDisplayed.bind(this),200)))},i.prototype.onAdd=function(){var t="/images/distance_marker_icon"+(this.val&gt;=1e3?"_wide":"")+".png?1";this.el=$('&lt;div class="distanceMarkerLabel"&gt;&lt;img src="'+t+'" /&gt;&lt;span class="'+(this.val&lt;10?"lt10":this.val&lt;100?"lt100":this.val&lt;1e3?"lt1000":"gte1000")+'"&gt;'+this.val+"&lt;/span&gt;&lt;/div&gt;").get(0),this.el.style.position="absolute",this.getPanes().markerLayer.appendChild(this.el)},i.prototype.draw=function(){var t=this.getProjection().fromLatLngToDivPixel(this.latLng);t&amp;&amp;(this.el.style.left=t.x+"px",this.el.style.top=t.y+"px")},i.prototype.onRemove=function(){this.el&amp;&amp;this.el.parentNode.removeChild(this.el)},rwgps.Map.prototype.drawSegmentDistanceMarkers=function(t,e){if(this.opts.distanceMarkersEnabled){for(var o=t.prevControlPoint,n=rwgps.LabelMaker.metric?1e3:1609.344,s=0,r=t.trackPoints.length;s&lt;r;s++){var a=t.trackPoints[s];if(a.point){var l=Math.floor(a.distanceWithoutExcludedPoints/n),h=Math.floor(o.distanceWithoutExcludedPoints/n);if(l!=h&amp;&amp;a.point&amp;&amp;o.point){var p=a.point.lat-o.point.lat,c=a.point.lng-o.point.lng,g=a.distanceWithoutExcludedPoints-o.distanceWithoutExcludedPoints,u=(l*n-o.distanceWithoutExcludedPoints)/g,d=o.point.lat+p*u,v=o.point.lng+c*u,m=new i(l,new google.maps.LatLng(d,v)),f={lat:d,lng:v,marker:m};l%25==0&amp;&amp;this.distanceMarkers[3].push(f),l%5==0&amp;&amp;this.distanceMarkers[2].push(f),l%2==0&amp;&amp;this.distanceMarkers[1].push(f),this.distanceMarkers[0].push(f),t.distanceMarkers.push(f.marker)}o=a}}e||this.updateDistanceMarkersDisplayed()}},rwgps.Map.prototype.distanceMarkersEnabled=function(t){this.opts.distanceMarkersEnabled=t,this.drawRouteDistanceMarkers(this.activeRoute)},rwgps.Map.prototype.generateCues=function(t){this.opts.generateCues=t},rwgps.Map.prototype.drawImageMarkers=function(t){this.imageMarkers={},_.each(t,function(t){if(t.lat&amp;&amp;t.lng){var e=new google.maps.Marker({map:this.gmap,icon:"/images/image_marker.png?1",position:new google.maps.LatLng(t.lat,t.lng),clickable:!0});google.maps.event.addListener(e,"click",function(){if(e.selected)$(".mini_slideshow .item.active a.popup_photo_modal").click();else{var i=$(".mini_slideshow .item").index($(".mini_slideshow img.ss_img[data-photo-id="+t.id+"]").closest(".item"));$(".mini_slideshow").carousel(i)}}),this.imageMarkers[t.id]=e}},this)}},function(t,e){"use strict";rwgps=window.rwgps||{},rwgps.Overlay=function(t){if(t)switch(this.opts=t,t.type){case"osm":return new rwgps.Overlay.OSM(t);case"arcgis":return new rwgps.Overlay.ArcGIS(t);case"wms":return new rwgps.Overlay.WMS(t)}},rwgps.Overlay.prototype={init:function(t){this.opts=t,this.url=t.url,this.provider=t.provider||"google",this.map=t.map,this.width=t.width||256,this.height=t.height||256},setProvider:function(t,e){this.provider=t,this.map=e}},rwgps.Overlay.WMS=function(t){this.init(t),this.requestOpts=t.requestOpts||{f:"image",transparent:"true",format:"png8",bboxSR:"4326"}},rwgps.Overlay.WMS.prototype=new rwgps.Overlay,rwgps.Overlay.WMS.prototype.getParamString=function(){var t=[];return _.each(this.requestOpts,function(e,i){t.push(i+"="+e)}),t.join("&amp;")},rwgps.Overlay.WMS.prototype.getOverlayObj=function(){if("google"==this.provider){var t=this;return new google.maps.ImageMapType({getTileUrl:function(e,i){var o=t.map.getProjection(),n=Math.pow(2,i),s=new google.maps.Point(e.x*t.width/n,e.y*t.height/n),r=new google.maps.Point((e.x+1)*t.width/n,(e.y+1)*t.height/n),a=o.fromPointToLatLng(s),l=o.fromPointToLatLng(r);return t.url+"?"+t.getParamString()+"&amp;size="+t.width+","+t.height+"&amp;bbox="+a.lng()+","+l.lat()+","+l.lng()+","+a.lat()},isPng:!0,name:t.opts.name,tileSize:new google.maps.Size(t.width,t.height),minZoom:t.opts.minZoom,maxZoom:t.opts.maxZoom})}return L.TileLayer.WMS(this.url,{layers:this.opts.layers,format:"image/png",version:this.opts.version||"1.3",transparent:!0,width:this.width,height:this.height})},rwgps.Overlay.OSM=function(t){this.init(t)},rwgps.Overlay.OSM.prototype=new rwgps.Overlay,rwgps.Overlay.OSM.prototype.getOverlayObj=function(){if("google"==this.provider){var t=this;return new google.maps.ImageMapType({getTileUrl:function(e,i){var o=t.url+i+"/"+e.x+"/"+e.y+".png",n=String.fromCharCode(Math.floor(3*Math.random())+97);return t.opts.key&amp;&amp;t.opts.key.length&gt;0&amp;&amp;(o+="?apikey="+t.opts.key),o.replace("{s}",n)},tileSize:new google.maps.Size(256,256),isPng:!0,alt:t.opts.alt,name:t.opts.name,maxZoom:t.opts.maxZoom})}return L.TileLayer(this.url,{maxZoom:this.opts.maxZoom})},rwgps.Overlay.ArcGIS=function(t){this.init(t)},rwgps.Overlay.ArcGIS.prototype=new rwgps.Overlay,rwgps.Overlay.ArcGIS.prototype.getOverlayObj=function(){if("google"==this.provider){var t=this;return new google.maps.ImageMapType({getTileUrl:function(e,i){var o=Math.floor(4*Math.random()+1),n=t.url.replace(/%{num}/,o);return n+"/tile/"+i+"/"+e.y+"/"+e.x+"?token="+(t.opts.token||"")},tileSize:new google.maps.Size(256,256),isPng:!0,alt:this.opts.alt,name:this.opts.name,maxZoom:this.opts.maxZoom})}}},function(t,e){"use strict";rwgps=window.rwgps||{},rwgps.TrackPoint=function(t){this.init(t)},rwgps.TrackPoint.inferSurface=function(t,e,i,o){if(95!==t)return t;var n=rwgps.surfaces.stInfer.find(function(t){var e=new google.maps.LatLngBounds({lat:t[0],lng:t[1]},{lat:t[2],lng:t[3]});return e.contains({lat:i,lng:o})});return n?void 0!==e?n[4][e]:t:void console.warn("unable to resolve surface type inferrence rule for {lat: "+i+", lng: "+o+"}")},rwgps.TrackPoint.fromJSON=function(t,e){e||(e={});for(var i=[],o=[],n=t[0],s=0;s&lt;t.length;s++)if(null!==t[s]){t[s].e&lt;-1e3&amp;&amp;(t[s-1]&amp;&amp;null!=t[s-1].e&amp;&amp;t[s-1].e&gt;=-1e3?t[s].e=t[s-1].e:t[s+1]&amp;&amp;null!=t[s+1].e&amp;&amp;t[s+1].e&gt;=-1e3?t[s].e=t[s+1].e:t[s].e=null);var r=t[s],a={point:null,ele:r.e};null!=r.y&amp;&amp;null!=r.x&amp;&amp;(a.point={lat:r.y,lng:r.x}),e.planning||null==r.d||""===r.d||n.d&amp;&amp;!(n.d&lt;=r.d)||(a.distance=r.d);var l=new rwgps.TrackPoint(a);l.hr=r.h,l.cad=r.c,l.watts=r.p,l.time=r.t,l.temp=r.T,l.modified=r.m,rwgps.surfaces&amp;&amp;rwgps.surfaces.stInfer&amp;&amp;(l.roadClass=r.R,l.ghSurface=r.S,l.surface=rwgps.TrackPoint.inferSurface(r.S,r.R,r.y,r.x)),void 0!==r.RE&amp;&amp;(l.roadEnv=r.RE,void 0!==r.flat&amp;&amp;(l.flattened=r.flat)),r.k&amp;&amp;(l.excludeFromMetrics=!0,l.exclude=!0),isNaN(r.s)||void 0===r.s||(l.speed=3.6*r.s),o.push(l),r.options||r.color?i.push(o.length-1):n&amp;&amp;!n.k&amp;&amp;r.k?i.push(o.length-1):!n||!n.k||r.k||n.options||r.color||i.push(o.length-2),n=r}return i.length&gt;0&amp;&amp;i[i.length-1]!=t.length-1&amp;&amp;i.push(t.length-1),{clickIndexes:i,trackPoints:o}},rwgps.TrackPoint.prototype={point:null,distance:null,ele:null,hr:null,cad:null,watts:null,time:null,grade:null,speed:null,temp:null,excludeFromMetrics:null,segment:null,isControlPoint:!1,prevSegment:null,nextSegment:null,surface:null,roadClass:null,ghSurface:null,roadEnv:null,modified:null,flattened:null,init:function(t){t&amp;&amp;(this.point=t.point,this.time=t.time,this.distance=t.distance,void 0!==t.distance&amp;&amp;(this.providedDistance=t.distance),this.ele=t.ele,this.segment=t.segment,this.surface=t.surface,this.roadClass=t.roadClass,this.ghSurface=t.ghSurface,this.roadEnv=t.roadEnv,this.excludeFromMetrics=t.excludeFromMetrics)},googleLatLng:function(){return window.google&amp;&amp;window.google.maps||console.error("Google Maps not loaded, attempt to instantiate google.maps.LatLng"),void 0===this._googleLatLng&amp;&amp;(this._googleLatLng=this.point?new google.maps.LatLng(this.point.lat,this.point.lng):null),this._googleLatLng},pointEquals:function(t){return this.point.lat==t.lat&amp;&amp;this.point.lng==t.lng},ensureNotControlPoint:function(){this.isControlPoint=!1,this.prevSegment=null,this.nextSegment=null},setNextSegment:function(t){this.segment=null,this.isControlPoint=!0,this.nextSegment=t,t&amp;&amp;(t.prevControlPoint=this,t.prevSegment=this.prevSegment),this.prevSegment&amp;&amp;(this.prevSegment.nextSegment=t)},setPrevSegment:function(t){this.segment=null,this.isControlPoint=!0,this.prevSegment=t,t&amp;&amp;(t.nextControlPoint=this,t.nextSegment=this.nextSegment),this.nextSegment&amp;&amp;(this.nextSegment.prevSegment=t)},toMiniObj:function(){var t={};return this.point&amp;&amp;(t.x=this.point.lng,t.y=this.point.lat),_.isNumber(t.x)&amp;&amp;(t.x=Math.round(1e6*t.x)/1e6),_.isNumber(t.y)&amp;&amp;(t.y=Math.round(1e6*t.y)/1e6),_.isNumber(this.ele)&amp;&amp;(t.e=this.ele),_.isNumber(this.cad)&amp;&amp;(t.c=this.cad),_.isNumber(this.hr)&amp;&amp;(t.h=this.hr),_.isNumber(this.watts)&amp;&amp;(t.p=this.watts),_.isNumber(this.time)&amp;&amp;(t.t=this.time),_.isNumber(this.speed)&amp;&amp;(t.s=this.speed_orig/3.6),_.isNumber(this.temp)&amp;&amp;(t.T=this.temp),_.isNumber(this.distance)&amp;&amp;(t.d=Math.round(1e3*this.distance)/1e3),this.excludeFromMetrics&amp;&amp;(t.k=!0),t.S=this.ghSurface,t.R=this.roadClass,t.m=this.modified,void 0!==this.roadEnv&amp;&amp;(t.RE=this.roadEnv,this.flattened&amp;&amp;(t.flat=this.flattened)),t},shallowClone:function(){return new rwgps.TrackPoint({point:this.point?{lat:this.point.lat,lng:this.point.lng}:null,ele:this.ele,surface:this.surface,ghSurface:this.ghSurface,roadClass:this.roadClass})},distanceFromPoint:function(t){return this.distanceFromLatLng(t.point)},distanceFromLatLng:function(t){var e=t.lat*Math.PI/180,i=t.lng*Math.PI/180,o=this.point.lat*Math.PI/180,n=this.point.lng*Math.PI/180;return rwgps.TrackPoint.haversine(e,i,o,n)},headingFromPoint:function(t){var e=this.point.lat*Math.PI/180,i=this.point.lng*Math.PI/180,o=t.point.lat*Math.PI/180,n=t.point.lng*Math.PI/180,s=Math.atan2(Math.sin(n-i)*Math.cos(o),Math.cos(e)*Math.sin(o)-Math.sin(e)*Math.cos(o)*Math.cos(n-i)),r=s*(180/Math.PI);return(r+360)%360}},rwgps.TrackPoint.haversine=function(t,e,i,o){var n=t-i,s=e-o,r=6378100,a=Math.sin(n/2),l=Math.sin(s/2),h=a*a+Math.cos(t)*Math.cos(i)*l*l,p=2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h));return r*p},rwgps.TrackPoint.calculateSplits=function(t){var e=Routes.sampleGraph._data.points();if(!(e.length&lt;2)){for(var i,o,n,s,r=t.method,a=e[0][r],l=0,h=[],p=0,c=0,g=0,u=e.length;g&lt;u;g++)e[g][r]-a&gt;=t.value?(i=e[g],o=e[g-1],c=1-(i[r]-a-t.value)/(i[r]-o[r]),1==c?(n=g,c=0):n=g-1,s=rwgps.TrackPoint.buildSplitObject(l,n,p,c),h.push(s),l=n,p=c,a+=t.value):g==u-1&amp;&amp;(s=rwgps.TrackPoint.buildSplitObject(l,g,p),h.push(s));return h}},rwgps.TrackPoint.buildSplitObject=function(t,e,i,o){var n=Routes.sampleGraph?Routes.sampleGraph._data:Routes.data,s=n.slice(t,e-t+1,i,o),r=s.metrics();return r.first_i=t,r.last_i=e,r.slice=s,r.moving_time=r.movingTime,r.elevation_gain=r.ele_gain,r.elevation_loss=r.ele_loss,r.pace=Math.round(r.moving_time/rwgps.LabelMaker.longLabel(r.distance,!1,5)),r},rwgps.CoursePoint=function(t){this.notes=t.notes||"",this.type=t.type||"",this.trackPointIndex=t.trackPointIndex||-1,this.trackPoint=t.trackPoint||null,this.marker=t.marker||null,this.description=t.description||"",this.photoIds=t.photoIds||[],this.edited=t.edited,this.confirmed=t.confirmed||!1,this.init(t)},rwgps.CoursePoint.prototype=new rwgps.TrackPoint,rwgps.CoursePoint.prototype.toMiniObj=function(){var t={x:this.point.lng,y:this.point.lat};return this.edited&amp;&amp;(t._e=1),this.type&amp;&amp;(t.t=this.type),this.notes&amp;&amp;(t.n=this.notes),_.isNumber(this.distance)&amp;&amp;(t.d=this.distance),_.isNumber(this.trackPointIndex)&amp;&amp;(t.i=this.trackPointIndex),this.description&amp;&amp;(t.description=this.description),this.photoIds&amp;&amp;this.photoIds.length&gt;0&amp;&amp;(t.photo_ids=this.photoIds),this.confirmed===!0&amp;&amp;(t.c=this.confirmed),t},rwgps.CoursePoint.prototype.buildCoursePointTypeSelect=function(){var t=T.t("cuesheet_types"),e=this,i="&lt;select class='coursePointType form-control' style='width:75%;display:inline;'&gt;";return _.each(t,function(t,o){i+="&lt;option value='"+o+"'"+(o==e.type?" selected":"")+"&gt;"+t+"&lt;/option&gt;"}),i+="&lt;/select&gt;"},rwgps.CoursePoint.prototype.editHtml=function(){return"&lt;div id='coursePointInfoWindowContent'&gt;"+("&lt;label class='inline'&gt;"+T.t("type")+"&lt;/label&gt;")+this.buildCoursePointTypeSelect()+("&lt;label&gt;"+T.t("notes")+"&lt;/label&gt;")+"&lt;textarea class='coursePointDescription'&gt;"+_.escape(this.notes||"")+"&lt;/textarea&gt;"+("&lt;label&gt;"+T.t("description")+"&lt;/label&gt;")+"&lt;textarea class='coursePointLongDescription'&gt;"+_.escape(this.description||"")+"&lt;/textarea&gt;&lt;div class='photos_view'&gt;&lt;/div&gt;"+("&lt;button type='submit' class='saveButton btn btn-primary'&gt;"+T.t("save")+"&lt;/button&gt;")+"&lt;div class='bottom-buttons'&gt;"+("&lt;button type='submit' class='deleteButton btn btn-link'&gt;"+T.t("delete")+"&lt;/button&gt;")+("&lt;button type='submit' class='cancelButton btn btn-link'&gt;"+T.t("cancel")+"&lt;/button&gt;")+"&lt;/div&gt;&lt;/div&gt;"},rwgps.CoursePoint.prototype.previewHtml=function(){var t="&lt;div id='poiInfoWindowContent' class='show'&gt;&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("type")+": &lt;/span&gt; "+this.type+"&lt;/p&gt;&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("notes")+": &lt;/span&gt; "+_.escape(this.notes)+"&lt;/p&gt;";return this.photoIds.length&gt;0&amp;&amp;(t+="&lt;p&gt;"+T.t("show_photos",{count:this.photoIds?this.photoIds.length:0})+"&lt;/span&gt;&lt;/p&gt;"),t+="&lt;/div&gt;"},rwgps.CoursePoint.prototype.showHtml=function(){var t="&lt;div id='poiInfoWindowContent' class='show'&gt;&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("type")+": &lt;/span&gt; "+this.type+"&lt;/p&gt;&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("notes")+": &lt;/span&gt; "+_.escape(this.notes)+"&lt;/p&gt;";return this.description&amp;&amp;this.description.length&gt;0&amp;&amp;(t+="&lt;p&gt;&lt;span style='font-weight:bold;margin-right:5px;'&gt;"+T.t("description")+":&lt;/span&gt;"+(this.description?_.escape(this.description).replace(/\n|\r/gi,"&lt;br&gt;"):"")),this.photoIds.length&gt;0&amp;&amp;(t+="&lt;/p&gt;&lt;br/&gt;&lt;br/&gt;"+_.map(this.photoIds,function(t){return"&lt;div style='float:left;border:1px solid #CCC;padding:2px;width:64;height:64px;'&gt;&lt;a class='thickbox' href='/photos/medium/"+t+".jpg'&gt;&lt;img src='/photos/milli/"+t+".jpg'&gt;&lt;/a&gt;&lt;/div&gt;"}).join("")),t+="&lt;/div&gt;"},rwgps.PointOfInterest=function(t){this.id=t.id||null,this.name=t.name||"",this.url=t.url||null,this.poiType=t.poiType,this.description=t.description||"",this.photoIds=t.photoIds||[],this.marker=null,this.readOnly=!!t.hasOwnProperty("readOnly")&amp;&amp;t.readOnly,this.route=null,this.visibility=t.visibility,this.userId=t.userId,this.library=t.library,this.addToPoiLibrary=t.library,this.saveOrUpdate=t.library?"update":void 0,this.init(t)},rwgps.PointOfInterest.fromJSON=function(t,e){if(void 0!==t){void 0===e&amp;&amp;(e=!0);var i="string"==typeof t?$.evalJSON(t):t,o=[];if(i)for(var n=0;n&lt;i.length;n++){var s=i[n],r=new rwgps.PointOfInterest({id:s.id,point:{lat:s.lat||s.y,lng:s.lng||s.x},name:s.name||s.name,poiType:s.poi_type||s.poi_type,description:s.description||s.description,url:s.url,readOnly:e,library:"Club"===s.parent_type,photoIds:s.photo_ids||s.photo_ids||[],visibility:s.visibility,userId:s.user_id,addToPoiLibrary:"Club"===s.parent_type});o.push(r)}return o}},rwgps.PointOfInterest.prototype=new rwgps.TrackPoint,rwgps.PointOfInterest.prototype.copy=function(){var t=this.toSaveObj();return delete t.id,rwgps.PointOfInterest.fromJSON([t],!1)[0]},rwgps.PointOfInterest.prototype.isEditable=function(){if(null==this.id)return!0;var t=rwgps.ns("config");return!(!t.currentUser||t.currentUser.id!=this.userId)},rwgps.PointOfInterest.prototype.addToRoute=function(){var t=this.marker.map;this.ghosted=!1,_.detect(t.pointsOfInterest,function(t){return t.id==this.id},this)||t.pointsOfInterest.push(this),this.marker.gmarker.setMap(null),this.marker=new rwgps.PoiIcon(this,t),t.closeStickyInfoWindow(),rwgps.Events.trigger("pois:added",this)},rwgps.PointOfInterest.prototype.removeFromRoute=function(){var t=this.marker.map;this.ghosted=!0,t.pointsOfInterest=_.without(t.pointsOfInterest,this),this.marker.gmarker.setMap(null),this.marker=new rwgps.PoiIcon(this,t),t.closeStickyInfoWindow(),rwgps.Events.trigger("pois:removed",[this])},rwgps.PointOfInterest.prototype.toSaveObj=function(){var t={lat:this.point.lat,lng:this.point.lng,poi_type:this.poiType||17};return t.id=this.id,t.name=this.name,t.description=this.description,this.photoIds&amp;&amp;this.photoIds.length&gt;0&amp;&amp;(t.photo_ids=this.photoIds),t.url=this.url,t.user_id=this.userId,t.addToPoiLibrary=this.addToPoiLibrary,this.addToPoiLibrary&amp;&amp;(t.saveOrUpdate=this.saveOrUpdate),t},rwgps.PointOfInterest.prototype.buildTypeSelect=function(){for(var t=rwgps.PointOfInterest.poiTypes,e="&lt;select class='poiType' style='width: 100%'&gt;",i=this.poiType?this.poiType:17,o=0;o&lt;t.length;o++)t[o].disabled&amp;&amp;t[o]._id!=i||(e+="&lt;option title='/images/"+rwgps.poiIconsPath()+t[o].icon+"?2' value='"+t[o]._id+"'"+(t[o]._id==i?" selected":"")+"&gt;"+t[o].name+"&lt;/option&gt;");return e+="&lt;/select&gt;"};var i=function(){return rwgps.activeNs.hasPoiLibrary};rwgps.PointOfInterest.prototype.editHtml=function(){var t="&lt;div id='poiInfoWindowContent'&gt;";if(this.library||i()){var e;e=void 0===this.addToPoiLibrary?this.library||!this.id:this.addToPoiLibrary!==!1,t+="\n      &lt;input type='checkbox' "+(e&amp;&amp;"checked")+" class='addToPoiLibrary' data-poi_id='"+(this.id||"")+"' /&gt;\n      &lt;label class='inline'&gt;"+T.t("add_to_library")+"&lt;/label&gt;\n      ",this.library&amp;&amp;this.addToPoiLibrary!==!1&amp;&amp;(t+="&lt;span id='saveOrUpdate'&gt;\n        &lt;div style='padding-left:15px'&gt;\n          &lt;input name='saveOrUpdate' type='radio' value='update' "+("save"!==this.saveOrUpdate&amp;&amp;"checked")+" {/&gt;\n          &lt;label class='inline'&gt;"+T.t("update_in_library")+"&lt;/label&gt;\n        &lt;/div&gt;\n        &lt;div style='padding-left:15px'&gt;\n          &lt;input name='saveOrUpdate' type='radio' value='save' "+("save"===this.saveOrUpdate&amp;&amp;"checked")+"/&gt;\n          &lt;label class='inline'&gt;"+T.t("save_as_new_poi")+"&lt;/label&gt;\n        &lt;/div&gt;\n      &lt;/span&gt;")}return t+="&lt;div style='margin-bottom:5px;height:60px'&gt;\n            "+this.buildTypeSelect()+"\n          &lt;/div&gt;\n          &lt;label&gt;"+T.t("name")+"&lt;/label&gt;\n          &lt;input type='text' class='poiName' value='"+_.escape(this.name||"")+"' /&gt;\n          &lt;label&gt;"+T.t("url")+"&lt;/label&gt;\n          &lt;input type='text' class='poiUrl' value='"+_.escape(this.url||"")+"' /&gt;\n          &lt;label&gt;"+T.t("description")+"&lt;/label&gt;\n          &lt;textarea class='poiDescription'&gt;"+_.escape(this.description||"")+"&lt;/textarea&gt;\n          &lt;div class='photos_view'&gt;&lt;/div&gt;\n          &lt;button type='submit' class='saveButton btn btn-primary' data-poi_id='"+(this.id||"")+"'&gt;"+T.t("save")+"&lt;/button&gt;\n          &lt;div class='bottom-buttons'&gt;\n            &lt;button type='submit' class='deleteButton btn btn-link' style='padding-bottom:0px' data-poi_id='"+(this.id||"")+"'&gt;"+T.t("delete")+"&lt;/button&gt;\n            &lt;button type='submit' class='cancelButton btn btn-link' style='padding-bottom:0px' data-poi_id='"+(this.id||"")+"'&gt;"+T.t("cancel")+"&lt;/button&gt;\n            &lt;button type='submit' class='poi_route_to btn btn-link' style='padding-bottom:0px' data-poi_id='"+(this.id||"")+"'&gt;"+T.t("route_to_poi")+"&lt;/button&gt;\n          &lt;/div&gt;\n        &lt;/div&gt;";
},rwgps.PointOfInterest.prototype.previewHtml=function(){var t=rwgps.PointOfInterest.poiTypesById[this.poiType],e="&lt;div id='poiInfoWindowContent' class='show'&gt;"+(t&amp;&amp;"Generic"!=t.name?"&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("type")+": &lt;/span&gt; "+t.name+"&lt;/p&gt;":"")+"&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("name")+": &lt;/span&gt; "+_.escape(this.name)+"&lt;/p&gt;";return this.url&amp;&amp;(e+="&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("url")+": &lt;/span&gt; "+rwgps.Utils.truncate(this.url,25)+"&lt;/p&gt;"),e+=this.photoIds.length&gt;0?"&lt;p&gt;"+T.t("show_photos",{count:this.photoIds?this.photoIds.length:0})+"&lt;/span&gt;&lt;/p&gt;":"&lt;p style='font-style: italic'&gt;"+T.t("click_for_details")+"&lt;/p&gt;",e+="&lt;/div&gt;"},rwgps.PointOfInterest.prototype.showHtml=function(){var t,e=rwgps.PointOfInterest.poiTypesById[this.poiType],i="&lt;div id='poiInfoWindowContent' class='show'&gt;"+(e&amp;&amp;"Generic"!=e.name?"&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("type")+": &lt;/span&gt; "+e.name+"&lt;/p&gt;":"")+"&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("name")+": &lt;/span&gt; "+_.escape(this.name)+"&lt;/p&gt;"+(this.url?"&lt;p&gt;&lt;span style='font-weight:bold;'&gt;"+T.t("url")+": &lt;/span&gt; &lt;a href='"+this.url+"' target='_blank'&gt;"+rwgps.Utils.truncate(_.escape(this.url),25)+"&lt;/a&gt;&lt;/p&gt;":"");if(this.description&amp;&amp;this.description.length&gt;0&amp;&amp;(i+="&lt;p&gt;&lt;span style='font-weight:bold;margin-right:5px;'&gt;"+T.t("description")+":&lt;/span&gt;"+_.escape(this.description).replace(/\r|\n/gi,"&lt;br&gt;")),t=this.marker.map,this.photoIds.length&gt;0&amp;&amp;(i+="&lt;/p&gt;&lt;br/&gt;&lt;br/&gt;"+_.map(this.photoIds,function(t){return"&lt;div style='float:left;border:1px solid #CCC;padding:2px;width:64;height:64px;'&gt;&lt;a class='thickbox' href='/photos/medium/"+t+".jpg'&gt;&lt;img src='/photos/milli/"+t+".jpg'&gt;&lt;/a&gt;&lt;/div&gt;"}).join("")),t=this.marker.map,t&amp;&amp;t.inPlanningMode()){t.poisById[this.id]=this;var o=rwgps.ns("config");o.features_withheld_on_restricted&amp;&amp;o.features_withheld_on_restricted.copy_poi&amp;&amp;2==this.visibility||(i+='&lt;div class="clear"&gt;&lt;/div&gt;&lt;div class="spacer"&gt;&lt;/div&gt;&lt;p&gt;Editable in POI Library (&lt;a href="javascript:;" class="poi_make_unique" data-poi_id="'+(this.id||"")+'"&gt;Make unique&lt;/a&gt;)&lt;/p&gt;',i+='&lt;div class="clear"&gt;&lt;/div&gt;&lt;div class="spacer"&gt;&lt;/div&gt;&lt;p&gt;&lt;a href="javascript:;" class="poi_remove_from_route" data-poi_id="'+(this.id||"")+'"&gt;Remove from route&lt;/a&gt;&lt;/p&gt;',i+='&lt;p&gt;&lt;a href="javascript:;" class="poi_route_to" data-poi_id="'+(this.id||"")+'"&gt;'+T.t("route_to_poi")+"&lt;/a&gt;&lt;/p&gt;")}return i+="&lt;/div&gt;"}},function(t,e){"use strict";var i=function(){function t(t,e){var i=[],o=!0,n=!1,s=void 0;try{for(var r,a=t[Symbol.iterator]();!(o=(r=a.next()).done)&amp;&amp;(i.push(r.value),!e||i.length!==e);o=!0);}catch(t){n=!0,s=t}finally{try{!o&amp;&amp;a.return&amp;&amp;a.return()}finally{if(n)throw s}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();rwgps=window.rwgps||{},rwgps.Route=function(t,e,i){this.segments=[],this.distance=0,this.startMarker=null,this.endMarker=null,this.gBounds=new google.maps.LatLngBounds,this.locality=null,this.postalCode=null,this.administrativeArea=null,this.countryCode=null,this.map=e,this.metricsChangeCallbacks=[],this.mysqlId=null,this.mongoidId=null,this.photoIds=[],this.userId=null,this.drawInactive=!0,this.pois=[];var o=function(t){return!!rwgps.config.labs.surface_types&amp;&amp;(!t||(t.showSurface||!_.some(t.track_points,function(t){return void 0===t.S})))};this.showSurface=o(t),t&amp;&amp;this.initFromDataJSON(t,i)},rwgps.Route.DEFAULT_LINE_WIDTH=4,rwgps.Route.ORIGINAL_DEFAULT_LINE_COLOR=16711680,rwgps.Route.DEFAULT_LINE_COLOR=16711680,rwgps.Route.prototype={setModified:function(){this._dirty=!0,rwgps.Events.trigger("route:modified",this)},isModified:function(){return this._dirty},setMap:function(t){this.map=t,_.each(this.segments,function(e){e.map=t})},deleteCoursePoints:function(){_.each(this.segments,function(t){_.each(t.coursePoints,function(t){t.row&amp;&amp;t.row.remove(),t.marker&amp;&amp;t.marker.gmarker&amp;&amp;t.marker.gmarker.setMap(null)}),t.coursePoints=[]})},segments:function(t){if(t){for(var e=this.firstSegment;t--;)e=e.nextSegment;return e}},segmentsChanged:function(t){this.segments=[];var e=this.firstSegment,i=0,o={};if(e){i=1;do{if(o[e._segId])break;o[e._segId]=!0,e.route=this,this.segments.push(e),i++,e=e.nextSegment}while(e);this.lastSegment=this.segments[this.segments.length-1]}if(delete this._trackPoints,this.map&amp;&amp;this.map.activeRoute===this&amp;&amp;delete this.map.routePoints,this.connectionPointIcon&amp;&amp;this.firstSegment&amp;&amp;(this.connectionPointIcon.trackPoint=this.firstSegment.prevControlPoint),t){t.prevControlPoint&amp;&amp;t.prevControlPoint.point&amp;&amp;this.gBounds.extend(t.prevControlPoint.googleLatLng()),t.nextControlPoint&amp;&amp;t.nextControlPoint.point&amp;&amp;this.gBounds.extend(t.nextControlPoint.googleLatLng());for(var n=0;n&lt;t.trackPoints.length;n++){var s=t.trackPoints[n];s.point&amp;&amp;this.gBounds.extend(s.googleLatLng())}if(t.coursePoints)for(n=0;n&lt;t.coursePoints.length;n++){var r=t.coursePoints[n];r.distance=r.trackPoint.distance,r.route=this}}},createSegmentBoundariesForSlice:function(t){var e=this.trackPoints(),i=e[t.i],o=e[t.i+t.count-1];if(!i.isControlPoint){var n=_.indexOf(i.segment.trackPoints,i);i.segment.splitAfter(n-1)}if(!o.isControlPoint){var s=_.indexOf(o.segment.trackPoints,o);o.segment.splitAfter(s-1)}},removeSlice:function(t){var e,i,o=this.trackPoints(),n=o[t.i],s=o[t.i+t.count-1];if(this.createSegmentBoundariesForSlice(t),0===t.i){for(i=[s.prevSegment];i[0].prevSegment;)i.unshift(i[0].prevSegment);_.each(i,function(t){this.removeSegment(t)},this),this.firstSegment=s.nextSegment,this.segmentsChanged(),this.calculateMetrics(),this.startMarker.gmarker.setPosition(s.googleLatLng())}else{for(s.nextSegment?(e=new rwgps.Route(null,this.map),this.map.routes.push(e),e.firstSegment=s.nextSegment,s.prevSegment.nextSegment=null,s.setPrevSegment(null),e.segmentsChanged(),e.rebuildBounds(),e.calculateMetrics(),e.setInactive(!0)):this.endMarker&amp;&amp;this.endMarker.gmarker.setPosition(n.googleLatLng()),i=[n.nextSegment];i[0].nextSegment;)i.unshift(i[0].nextSegment);_.each(i,function(t){this.removeSegment(t)},this),this.redrawPolylines(),this.map.prevClick=n.point}return this.map.drawRouteDistanceMarkers(),this.map.loadElevationProfile(),this.map.populateCuesheet(this.coursePoints()),this.map.snapshot(),rwgps.Events.trigger("map:routes_changed"),e},cropTo:function(t){var e=this.trackPoints(),i=e[t.i],o=e[t.i+t.count-1];this.createSegmentBoundariesForSlice(t);var n=[];if(i.prevSegment)for(n.unshift(i.prevSegment);n[0].prevSegment;)n.unshift(n[0].prevSegment);if(o.nextSegment)for(n.unshift(o.nextSegment);n[0].nextSegment;)n.unshift(n[0].nextSegment);_.each(n,function(t){this.removeSegment(t)},this),this.firstSegment=i.nextSegment,this.segmentsChanged(),this.calculateMetrics(),this.rebuildBounds();var s=i.nextSegment.coursePoints[0];s&amp;&amp;s.trackPoint===i&amp;&amp;i.nextSegment.coursePoints.splice(0,1);var r=o.prevSegment.coursePoints,a=r[r.length-1];a&amp;&amp;a.trackPoint===o&amp;&amp;r.splice(r.length-1),this.startMarker.gmarker.setPosition(i.googleLatLng()),this.endMarker&amp;&amp;this.endMarker.gmarker.setPosition(o.googleLatLng()),this.map.prevClick=t.lastPoint().point,this.map.drawRouteDistanceMarkers(),this.map.loadElevationProfile(),this.map.populateCuesheet(this.coursePoints()),this.map.snapshot()},removeTrack:function(){_.each(this.segments,function(t){this.removeSegment(t)},this),this.active&amp;&amp;(this.map.prevClick=null,this.clearStartMarker(),this.map.removeRouteDistanceMarkers(this))},customColorsUsed:function(){return this.customColors||!1},hasPower:function t(){for(var e,t=!1,i=this.trackPoints(),o=0;o&lt;10;o++)e=Math.floor(Math.random()*i.length),t=null!=i[e].watts;return t},storeRawPower:function(){if(!(this.storedPower&amp;&amp;this.storedPower.length&gt;0)){var t=this.trackPoints();this.storedPower=new Array(t.length);for(var e=0;e&lt;t.length;e++)this.storedPower[e]=t[e].watts}},restoreRawPower:function(){if(null!=this.storedPower&amp;&amp;0!=this.storedPower.length)for(var t=this.trackPoints(),e=0;e&lt;t.length;e++)t[e].watts=this.storedPower[e]},replacePowerWithAvg:function(t){var e=this.trackPoints();if(0!=e.length&amp;&amp;0!=this.hasPower()){this.storePower();var i=0,o=0,n=[],s=Math.floor((t||3)/2),r=s*-1,a=s;for(i=0;i&lt;e.length;i++){var l=[];for(o=r;o&lt;=a;o++)i+o&gt;=0&amp;&amp;i+o&lt;e.length&amp;&amp;l.push(e[i+o].watts);var h=0,p=0;for(o=0;o&lt;l.length;o++)null!=l[o]&amp;&amp;(h+=l[o],p+=1);n.push(h/p)}for(i=0;i&lt;e.length;i++)e[i].watts=n[i]}},resetGrade:function(){var t=this._trackPoints;if(t)for(var e=0;e&lt;t.length;e++)t[e].grade=t[e].grade_orig=null},flattenBridgesAndTunnels:function(){var t=void 0,e=void 0,i=!1,o=this.trackPoints(),n=o.length,s=20;_.forEach(o,function(r,a){if(!r.flattened)if(r.roadEnv&amp;&amp;!i)for(i=!0,t=a;o[a].distance-o[t].distance&lt;s&amp;&amp;t&gt;0;)t-=1;else if(i&amp;&amp;0===r.roadEnv){for(i=!1,e=a;o[e].distance-o[a].distance&lt;s&amp;&amp;e&lt;n;)e+=1;var l=o[t],h=o[e],p="distance",c=l[p],g=(h.ele-l.ele)/(h[p]-l[p]);_.forEach(o.slice(t,e),function(t){t.ele=(t[p]-c)*g+l.ele,t.flattened=!0})}})},trackPoints:function(){if(!this._trackPoints){for(var t=[],e=this.firstSegment;e;){t.push(e.prevControlPoint);for(var i=0;i&lt;e.trackPoints.length;i++)t.push(e.trackPoints[i]);e.nextSegment||t.push(e.nextControlPoint),e=e.nextSegment}this._trackPoints=t}return this._trackPoints},coursePoints:function(){for(var t=[],e=0;e&lt;this.segments.length;e++)t=t.concat(this.segments[e].coursePoints);return t},elevationGain:function(){for(var t=0,e=0;e&lt;this.segments.length;e++)t+=this.segments[e].elevationGain;return t},elevationLoss:function(){for(var t=0,e=0;e&lt;this.segments.length;e++)t+=this.segments[e].elevationLoss;return t},isOnMap:function(){return!!(this.startMarker&amp;&amp;this.startMarker.gmarker.map||this.endMarker&amp;&amp;this.endMarker.gmarker.map||this.segments.length&gt;0&amp;&amp;this.segments[0].gPolylines[0].map)},removeFromMap:function(){this.startMarker&amp;&amp;this.startMarker.gmarker&amp;&amp;this.startMarker.gmarker.setMap(null),this.endMarker&amp;&amp;this.endMarker.gmarker&amp;&amp;this.endMarker.gmarker.setMap(null);for(var t=0;t&lt;this.segments.length;t++)this.segments[t].gPolylines.forEach(function(t){return t.setMap(null)}),this.segments[t].sPolylines.forEach(function(t){return t.setMap(null)}),this.segments[t].backgroundPolyline&amp;&amp;this.segments[t].backgroundPolyline.setMap(null);for(t=0;t&lt;this.map.routes.length;t++)if(this.map.routes[t]==this){this.map.routes.remove(t,t+1);break}},setActive:function(){this.active||(this.active=!0,this.redraw())},setInactive:function(t){(this.active||t)&amp;&amp;(this.active=!1,this.map&amp;&amp;this.map.removeRouteDistanceMarkers(this),this.redraw())},clearConnectionPoint:function(){this.connectionPointIcon&amp;&amp;this.connectionPointIcon.gmarker.setMap(null)},drawConnectionPoint:function(){if(!this.connectionPointDisabled){var t=this.trackPoints()[0];if(this.connectionPointIcon)this.connectionPointIcon.gmarker.setMap(this.map.gmap),this.connectionPointIcon.gmarker.setPosition(t.googleLatLng()),this.connectionPointIcon.trackPoint=t;else{var e=new rwgps.ConnectionPointIcon(t,this.map);this.connectionPointIcon=e}}},initFromDataJSON:function(t,e){var i="string"==typeof t?$.evalJSON(t):t,o=0,n=0,s=i.course_points||[],r=i.track_points||[];this.drawInactive=void 0===i.drawInactive||i.drawInactive,this.connectionPointDisabled=i.connectionPointDisabled;var a,l=[],h=[],p=[],c=[];i.id&amp;&amp;(this.mysqlId=i.id),i.mongoid_id&amp;&amp;(this.mongoidId=i.mongoid_id),i.photo_ids&amp;&amp;i.photo_ids.length&gt;0&amp;&amp;(this.photoIds=i.photo_ids),i.user_id&amp;&amp;(this.userId=i.user_id),this.showSurface=rwgps.config.labs.surface_types&amp;&amp;(!_.some(r,function(t){return void 0===t.S})||0===r.length),this.name=t.name,this.routeData={name:t.name,id:t.id,description:t.description,isTrip:e&amp;&amp;e.isTrip},this.pois=_.map(i.points_of_interest||[],function(t){return _.isFunction(t.toSaveObj)?t:rwgps.PointOfInterest.fromJSON([t],!(e||{}).planning)[0]});var g=rwgps.TrackPoint.fromJSON(r,e);h=g.trackPoints,e&amp;&amp;e.isTrip&amp;&amp;!_.every(h,function(t){return t.surface})&amp;&amp;this.map.injectSurfaces(h,function(){}),c=g.clickIndexes;var u=1,d=h[0];for(o=0;o&lt;c.length;o++){var v=c[o];if(0!==v){var m=h.slice(u,v);r[v].color!=rwgps.Route.ORIGINAL_DEFAULT_LINE_COLOR&amp;&amp;(this.customColors=!0),a=new rwgps.Segment(this,d,h[v],m,null,r[v].color),a.clickOptions.setOptions(r[v].options),p.push(a),d=h[v],u=v+1}}0==c.length&amp;&amp;h.length&gt;0&amp;&amp;p.push(new rwgps.Segment(this,h[0],h[h.length-1],h.slice(1,-1)));var f;for(o=0;o&lt;s.length;o++)f=s[o],l.push(new rwgps.CoursePoint({edited:f._e,point:{lat:f.y,lng:f.x},notes:f.n,type:f.t,description:f.description,trackPointIndex:f.i,distance:f.d,photoIds:f.photo_ids,confirmed:f.c}));var w=0;for(o=0;o&lt;l.length;o++){if(f=l[o],h[f.trackPointIndex])f.trackPoint=h[f.trackPointIndex];else{var P=1e-4;for(n=w;n&lt;h.length;n++){var k=h[n];if(k.point&amp;&amp;Math.abs(f.point.lat-k.point.lat)&lt;=P&amp;&amp;Math.abs(f.point.lng-k.point.lng)&lt;=P){w=n+1,f.trackPointIndex=n,f.trackPoint=k;break}}}f.trackPoint&amp;&amp;(f.trackPoint.segment?(f.segment=f.trackPoint.segment,f.trackPoint.segment.coursePoints.push(f)):f.trackPoint.prevSegment?(f.segment=f.trackPoint.prevSegment,f.trackPoint.prevSegment.coursePoints.push(f)):(f.segment=p[0],p[0].coursePoints.push(f)))}this.rebuildBounds(),this.calculateMetrics()},trackPointsForSave:function(){for(var t,e=[],i=0;i&lt;this.segments.length;i++){t=this.segments[i],0===i&amp;&amp;e.push(t.prevControlPoint.toMiniObj());for(var o=0;o&lt;t.trackPoints.length;o++){var n=t.trackPoints[o];e.push(n.toMiniObj())}e.push(t.nextControlPoint.toMiniObj()),e[e.length-1].options=t.clickOptions.getOptions(),e[e.length-1].color=t.color}return e},coursePointsForSave:function(){for(var t=this.trackPoints(),e=this.coursePoints(),i=[],o=0;o&lt;e.length;o++){var n=e[o];n.trackPointIndex=_.indexOf(t,n.trackPoint),i.push(n.toMiniObj())}return i},toSaveObj:function(){return{id:this.mysqlId,name:this.name,active:this.active,track_points:this.trackPointsForSave(),course_points:this.coursePointsForSave(),drawInactive:this.drawInactive,connectionPointDisabled:this.connectionPointDisabled,isTrip:this.routeData&amp;&amp;this.routeData.isTrip,showSurface:this.showSurface}},metrics:{},calculateMetrics:function(){this.metricsCalculator=new rwgps.MetricsCalculator(this.trackPoints()),this.metrics=this.metricsCalculator.calculate(),_.each(this.coursePoints(),function(t){t.distance=t.trackPoint.distance}),this.metricsChange()},metricsChangeCallbacks:[],metricsChange:function(t){if(t)this.metricsChangeCallbacks.push(t);else{var e=this;_.each(this.metricsChangeCallbacks,function(t){t(e)})}},removeSegment:function(t){t.removeFromMap(),t.prevControlPoint.setNextSegment(null),t.nextControlPoint.setPrevSegment(null),this.firstSegment===t&amp;&amp;(this.firstSegment=null),this.segmentsChanged(),this.calculateMetrics(),this.rebuildBounds()},rebuildBounds:function(){this.gBounds=new google.maps.LatLngBounds;for(var t=this.trackPoints(),e=0;e&lt;t.length;e++){var i=t[e];i.point&amp;&amp;this.gBounds.extend(i.googleLatLng())}},drawPreview:function(){if(this.previewPolyline)return void this.previewPolyline.setMap(this.map.gmap);for(var t=this.trackPoints(),e=[],i=0;i&lt;t.length;i++){var o=t[i];o.point&amp;&amp;e.push(o.googleLatLng())}if(e.length&gt;0){var n=this.previewStyle||{strokeColor:"#0000ff",strokeOpacity:.4,strokeWeight:10};this.previewPolyline=new google.maps.Polyline(_.extend(n,{map:this.map.gmap,path:e,clickable:!1}))}},clearPreview:function(){this.previewPolyline&amp;&amp;this.previewPolyline.setMap(null)},redraw:function(){this.clearAllOverlays(),(this.active||this.drawInactive)&amp;&amp;(this.active?(this.startMarker?this.startMarker.gmarker.setMap(this.map.gmap):this.firstSegment&amp;&amp;(this.startMarker=new rwgps.StartIcon(this.firstSegment.prevControlPoint.point,this.map)),"view"===this.map.mode&amp;&amp;(this.endMarker?this.endMarker.gmarker.setMap(this.map.gmap):this.lastSegment&amp;&amp;(this.endMarker=new rwgps.EndIcon(this.lastSegment.nextControlPoint.point,this.map)))):this.map.inPlanningMode()&amp;&amp;this.drawConnectionPoint(),this.redrawPolylines())},clearAllOverlays:function(){this.clearPreview(),this.clearCoursePointMarkers(),this.clearStartMarker(),this.clearEndMarker(),this.clearPolylines(),this.clearControlPoints(),this.clearConnectionPoint()},clearCoursePointMarkers:function(){for(var t=0;t&lt;this.segments.length;t++)for(var e=0;e&lt;this.segments[t].coursePoints.length;e++)this.segments[t].coursePoints[e].marker&amp;&amp;this.segments[t].coursePoints[e].marker.gmarker.setMap(null)},clearStartMarker:function(){this.startMarker&amp;&amp;this.startMarker.gmarker.setMap(null)},clearEndMarker:function(){this.endMarker&amp;&amp;this.endMarker.gmarker.setMap(null)},drawPolylines:function(t){_.each(this.segments,function(e){e.gPolylines.length&gt;0?(e.backgroundPolyline&amp;&amp;e.backgroundPolyline.setMap(t.gmap),e.gPolylines.forEach(function(e){return e.setMap(t.gmap)}),t.opts.showSurface&amp;&amp;e.sPolylines.forEach(function(e){return e.setMap(t.gmap)})):e.render()})},clearPolylines:function(){for(var t=0;t&lt;this.segments.length;t++)this.segments[t].backgroundPolyline&amp;&amp;this.segments[t].backgroundPolyline.setMap(null),this.segments[t].gPolylines.length&gt;0&amp;&amp;(this.segments[t].gPolylines.forEach(function(t){return t.setMap(null)}),this.segments[t].sPolylines.forEach(function(t){return t.setMap(null)}))},redrawPolylines:function(){for(var t=0;t&lt;this.segments.length;t++)this.segments[t].backgroundPolyline&amp;&amp;(this.segments[t].backgroundPolyline.setMap(null),this.segments[t].backgroundPolyline=null),this.segments[t].gPolylines.length&gt;0&amp;&amp;(this.segments[t].gPolylines.forEach(function(t){return t.setMap(null)}),this.segments[t].gPolylines=[],this.segments[t].sPolylines.forEach(function(t){return t.setMap(null)}),this.segments[t].sPolylines=[]);this.drawPolylines(this.map)},recalculatePolylines:function(){this.segments.forEach(function(t){return t.recalculateSurfaces()})},drawControlPoints:function(t){_.each(this.segments,function(e){e.drawControlPoint(t)})},clearControlPoints:function(){_.each(this.segments,function(t){t.controlPointIcon&amp;&amp;t.controlPointIcon.gmarker.setMap(null)})},distanceToLatLng:function(t,e){for(var i=this.trackPoints(),o=e.googleLatLngToPoint(t),n=o.x,s=o.y,r=[],a=0;a&lt;i.length;a++)if(i[a].point){var l=e.googleLatLngToPoint(i[a].googleLatLng());r.push(l.x),r.push(l.y),r.push(i[a])}else r.push(null),r.push(null),r.push(null);var h,p,c=Number.MAX_VALUE,g=r[0],u=r[1],d=g,v=u;for(h=0;h&lt;r.length;h+=3){var m=d,f=v;if(d=r[h],v=r[h+1],null!=d&amp;&amp;null!=v){var w=d-m,P=v-f,_=w*w+P*P,k=((n-d)*w+(s-v)*P)/_,y=d+k*w,M=v+k*P,S=(n-y)*(n-y)+(s-M)*(s-M);if(S&lt;c){var I=(n-m)*(n-m)+(s-f)*(s-f),C=(n-d)*(n-d)+(s-v)*(s-v);I-S+(C-S)&gt;_&amp;&amp;(I&lt;C?(S=I,y=m,M=f):(S=C,y=d,M=v))}S&lt;c&amp;&amp;(c=S,g=y,u=M,p=h-1)}}var b=(p-2)/3,x=i[b];if(x&amp;&amp;x.point)return x.distanceFromLatLng({lat:t.lat(),lng:t.lng()})},hasHighlightedSegment:function(){return!_.every(this.segments,function(t){return t.drawInactive!==!0})}};var o=0;rwgps.Segment=function(t,e,i,n,s,r){this._segId=o++,n||(n=[]);var a=0;for(e.setNextSegment(this),i.setPrevSegment(this),this.map=t.map,this.distance=0,this.elevationGain=0,this.elevationLoss=0,this.color=_.isNumber(r)&amp;&amp;!isNaN(r)?r:rwgps.Route.DEFAULT_LINE_COLOR,this.clickOptions=new rwgps.ClickOptions,this.gPolylines=[],this.sPolylines=[],this.backgroundPolyline=null,this.trackPoints=n,this.coursePoints=s||[],this.controlPointIcon=null,this.distanceMarkers=[],this.distance=i.distance-e.distance,a=0;a&lt;n.length;a++)n[a].segment=this;if(this.calculateSurfaceIndices(),s)for(a=0;a&lt;s.length;a++)s[a].segment=this;this.route=t,this.prevSegment||(this.route.firstSegment=this),this.detectAndSetExcludeFromMetrics(),this.route.segmentsChanged(this),this.route.active&amp;&amp;this.render()},rwgps.Segment.cssColor=function(t){for(var e=t&lt;0?"0":t.toString(16);e.length&lt;6;)e="0"+e;return"#"+e.toUpperCase()},rwgps.Segment.prototype={calculateSurfaceIndices:function(){if(rwgps.surfaces){this.surfaceIndices=[];var t=this.trackPoints;if(this.prevControlPoint||0!==t.length||this.nextControlPoint){var e=[];this.prevControlPoint.point&amp;&amp;e.push(this.prevControlPoint),t.forEach(function(t){t.point&amp;&amp;e.push(t)}),this.nextControlPoint.point&amp;&amp;e.push(this.nextControlPoint);for(var i=void 0,o=void 0,n=rwgps.surfaces.surfaceGroups[e[0].surface],s=0;s&lt;e.length;s++)i=e[s],rwgps.surfaces&amp;&amp;s&gt;1&amp;&amp;(o=rwgps.surfaces.surfaceGroups[i.surface],n!==o&amp;&amp;(n=o,this.surfaceIndices.push(s)))}}},detectAndSetExcludeFromMetrics:function(){this.prevControlPoint.excludeFromMetrics!==this.nextControlPoint.excludeFromMetrics?this.setExcludeFromMetrics(!1):this.prevControlPoint.excludeFromMetrics&amp;&amp;this.nextControlPoint.excludeFromMetrics&amp;&amp;this.setExcludeFromMetrics(0===this.trackPoints.length||this.trackPoints[0].excludeFromMetrics)},setExcludeFromMetrics:function(t,e){this.excludeFromMetrics=t;var i=[];this.prevSegment&amp;&amp;this.prevSegment.excludeFromMetrics||i.push(this.prevControlPoint),this.nextSegment&amp;&amp;this.nextSegment.excludeFromMetrics||i.push(this.nextControlPoint),[i,this.trackPoints].forEach(function(i){i.forEach(function(i){e&amp;&amp;(i.excludeFromMetrics=t,t?(void 0===i._exclude&amp;&amp;(i._exclude=!!i.exclude),i.exclude=!0):void 0!==i._exclude&amp;&amp;(i.exclude=i._exclude))})})},recalculateSurfaces:function(){this.gPolylines.forEach(function(t){return t.setMap(null)}),this.gPolylines=[],this.sPolylines.forEach(function(t){return t.setMap(null)}),this.sPolylines=[],this.calculateSurfaceIndices(),this.render()},showSurface:function(){return!(!this.route.showSurface||!(this.prevControlPoint.surface||this.nextControlPoint.surface||_.some(this.trackPoints,function(t){return t.surface})))&amp;&amp;this.route.map.opts.showSurface},render:function(){var t=this;if(this.route.active||this.route.map&amp;&amp;this.route.drawInactive){this.gPolylines.length&gt;0&amp;&amp;this.gPolylines.forEach(function(t){return t.setMap(null)}),this.sPolylines.length&gt;0&amp;&amp;this.sPolylines.forEach(function(t){return t.setMap(null)}),this.backgroundPolyline&amp;&amp;this.backgroundPolyline.setMap(null);var e=this.route,o=this.surfaceIndices&amp;&amp;this.surfaceIndices.map(function(t){return t}),n=[],s=[];this.prevControlPoint.point&amp;&amp;(s.push(this.prevControlPoint.googleLatLng()),n.push(this.prevControlPoint));for(var r=0;r&lt;this.trackPoints.length;r++){var a=this.trackPoints[r];a.point&amp;&amp;(s.push(a.googleLatLng()),n.push(a))}this.nextControlPoint.point&amp;&amp;(s.push(this.nextControlPoint.googleLatLng()),n.push(this.nextControlPoint)),this.prevControlPoint.point&amp;&amp;n.unshift(this.prevControlPoint);var l=[];if(s.length&gt;0&amp;&amp;s[0]){if(this.showSurface()&amp;&amp;e.active&amp;&amp;o.length&gt;0){var h=0;o.forEach(function(t){l.push([s.slice(h,t+1),n[t-1].surface]),h=t}),l.push([s.slice(h),n[n.length-1].surface])}else{var p=n.length&gt;0?n[n.length-1].surface:this.nextControlPoint.surface;l.push([s,p])}var c,g;e.active&amp;&amp;!this.excludeFromMetrics?l.forEach(function(e){var o=i(e,2),n=o[0],r=o[1],a=rwgps.surfaces&amp;&amp;rwgps.surfaces.surfaceGroups[""+r];c={strokeColor:t.cssColor(),strokeOpacity:Routes.heatmapEnabled?1:.6,strokeWeight:rwgps.Route.DEFAULT_LINE_WIDTH,zIndex:1},t.map.inPlanningMode()&amp;&amp;Routes.heatmapEnabled&amp;&amp;(g={strokeColor:rwgps.Segment.cssColor(16777215),strokeOpacity:1,strokeWeight:7,zIndex:0,path:s,clickable:!1},t.backgroundPolyline=new google.maps.Polyline(g)),t.gPolylines.push(new google.maps.Polyline(_.extend(c,{path:n,clickable:!1}))),t.showSurface()&amp;&amp;"paved"!==a&amp;&amp;t.surfacePolyline(n,a)}):this.gPolylines.push(new google.maps.Polyline(_.extend(e.inactiveStyle||{strokeColor:"#000000",strokeOpacity:.2,strokeWeight:5},{path:s,clickable:!1}))),this.addToMap()}}},cssColor:function(){return rwgps.Segment.cssColor(this.color)},surfacePolyline:function(t,e){if("unpaved"===e){var i={path:"M 0.5,-1.5 0.5,1.5 -0.5,1.5 -0.5,-1.5",strokeOpacity:.9,strokeColor:"#FFFFFF",scale:1};this.sPolylines.push(new google.maps.Polyline({strokeOpacity:0,zIndex:2,path:t,clickable:!1,icons:[{icon:i,offset:"0",repeat:"6px"}]}))}else this.sPolylines.push(new google.maps.Polyline({strokeOpacity:.9,strokeWeight:rwgps.Route.DEFAULT_LINE_WIDTH/2,strokeColor:"#FFFFFF",zIndex:2,path:t,clickable:!1}))},drawControlPoint:function(t){if(t?this.map=t:t=this.map,!this.drawInactive)if(this.controlPointIcon){this.controlPointIcon.gmarker.setMap(t.gmap);var e=this.nextControlPoint;this.controlPointIcon.gmarker.setPosition(e.googleLatLng()),this.controlPointIcon.trackPoint=e}else this.redrawControlPoint(t)},redrawControlPoint:function(t){this.controlPointIcon&amp;&amp;this.controlPointIcon.gmarker.setMap(null);var e=this.nextControlPoint,i=new rwgps.ControlPointIcon(e,t);this.controlPointIcon=i},removeFromMap:function(){this.map&amp;&amp;(this.map.removeSegmentDistanceMarkers(this),this.map=null),this.gPolylines.length&gt;0&amp;&amp;this.gPolylines.forEach(function(t){return t.setMap(null)}),this.sPolylines.length&gt;0&amp;&amp;this.sPolylines.forEach(function(t){return t.setMap(null)}),this.backgroundPolyline&amp;&amp;this.backgroundPolyline.setMap(null),this.controlPointIcon&amp;&amp;this.controlPointIcon.gmarker.setMap(null);for(var t=0;t&lt;this.coursePoints.length;t++){var e=this.coursePoints[t];e.marker&amp;&amp;e.marker.gmarker&amp;&amp;this.coursePoints[t].marker.gmarker.setMap(null)}},addToMap:function(t){var e=this;t&amp;&amp;(this.map=t),this.map&amp;&amp;(this.backgroundPolyline&amp;&amp;this.backgroundPolyline.setMap(this.map.gmap),this.gPolylines.length&gt;0&amp;&amp;(this.gPolylines.forEach(function(t){t.setMap(e.map.gmap)}),this.map.opts.showSurface&amp;&amp;this.sPolylines.forEach(function(t){return t.setMap(e.map.gmap)})),this.map.showControlPointIcons&amp;&amp;this.route.active&amp;&amp;this.drawControlPoint(this.map))},insertCoursePoint:function(t){for(var e=this.coursePoints.length-1;e&gt;=0;e--){var i=this.coursePoints[e];if(i.distance&lt;=t.distance)return this.coursePoints.splice(e+1,0,t),void(t.segment=this)}this.coursePoints.unshift(t),t.segment=this},removeCoursePoint:function(t){t.row&amp;&amp;t.row.remove(),t.marker&amp;&amp;t.marker.gmarker&amp;&amp;t.marker.gmarker.setMap(null);var e=_.indexOf(t.segment.coursePoints,t);this.coursePoints.splice(e,1)},clearCoursePointMarkers:function(){for(var t=0;t&lt;this.coursePoints.length;t++)this.coursePoints[t].marker&amp;&amp;this.coursePoints[t].marker.gmarker.setMap(null)},insertTrackPointAfter:function(t,e){this.trackPoints.splice(e+1,0,t),this.calculateSurfaceIndices();var i=e&lt;0?this.prevControlPoint:this.trackPoints[e];t.distance=i.distance+t.distanceFromPoint(i),t.segment=this,this.route.segmentsChanged()},connectAfter:function(t){this.prevControlPoint.ensureNotControlPoint(),t.nextControlPoint.setControlPoint(t,this)},splitAfter:function(t){var e=t+1;if(e&gt;this.trackPoints.length-1){if(!(e&gt;0&amp;&amp;e===this.trackPoints.length))return;e--}for(var i=this.trackPoints.length-e,o=[],n=0;n&lt;this.coursePoints.length;n++){var s=this.coursePoints[n],r=_.indexOf(this.trackPoints,s.trackPoint);if(r&gt;e){o=this.coursePoints.splice(n);break}}var a=this.trackPoints.splice(e,i);this.calculateSurfaceIndices();var l=this.nextControlPoint,h=a.shift();h.setPrevSegment(this);var p=new rwgps.Segment(this.route,h,l,a,o,this.color);return p.clickOptions.setOptions(this.clickOptions.getOptions()),this.render(),p.render(),this.route&amp;&amp;(this.route.clearControlPoints(),this.map&amp;&amp;"view"!=this.map.mode&amp;&amp;this.route.drawControlPoints(this.map)),p},slurpNext:function(){var t=this.nextSegment;if(t){this.coursePoints=this.coursePoints.concat(t.coursePoints);var e=this.nextControlPoint;e.ensureNotControlPoint(),e.segment=this,this.trackPoints.push(e),this.trackPoints=this.trackPoints.concat(t.trackPoints);for(var i=0,o=t.coursePoints.length;i&lt;o;i++)t.coursePoints[i].segment=this;for(i=0,o=t.trackPoints.length;i&lt;o;i++)t.trackPoints[i].segment=this;t.nextControlPoint.setPrevSegment(this),t.removeFromMap(),this.render(),this.route.segmentsChanged()}}},rwgps.Segment.fillTheCracks=function(t){for(var e=[],i=1;i&lt;t.length;i++){var o=t[i-1],n=t[i],s=n.distanceFromPoint(o),r=Math.floor(s/1e3*10),a=n.point.lat-o.point.lat,l=n.point.lng-o.point.lng,h=a/r,p=l/r,c=o.point.lat,g=o.point.lng;e.push(o);for(var u=0;u&lt;r;u++){var d=new rwgps.TrackPoint({point:{lat:c,lng:g}});rwgps.config.labs.surface_types&amp;&amp;rwgps.config.labs.route_planner&amp;&amp;(d.surface=99,d.ghSurface=99),e.push(d),c+=h,g+=p}}return e.push(t[t.length-1]),e}},function(t,e){"use strict";var i;!function(){function t(t){for(var e,i,o="",n=-1;++n&lt;t.length;)e=t.charCodeAt(n),i=n+1&lt;t.length?t.charCodeAt(n+1):0,55296&lt;=e&amp;&amp;e&lt;=56319&amp;&amp;56320&lt;=i&amp;&amp;i&lt;=57343&amp;&amp;(e=65536+((1023&amp;e)&lt;&lt;10)+(1023&amp;i),n++),e&lt;=127?o+=String.fromCharCode(e):e&lt;=2047?o+=String.fromCharCode(192|e&gt;&gt;&gt;6&amp;31,128|63&amp;e):e&lt;=65535?o+=String.fromCharCode(224|e&gt;&gt;&gt;12&amp;15,128|e&gt;&gt;&gt;6&amp;63,128|63&amp;e):e&lt;=2097151&amp;&amp;(o+=String.fromCharCode(240|e&gt;&gt;&gt;18&amp;7,128|e&gt;&gt;&gt;12&amp;63,128|e&gt;&gt;&gt;6&amp;63,128|63&amp;e));return o}var e=function(){function e(t,e){var i=t[0],a=t[1],l=t[2],h=t[3];i=o(i,a,l,h,e[0],7,-680876936),h=o(h,i,a,l,e[1],12,-389564586),l=o(l,h,i,a,e[2],17,606105819),a=o(a,l,h,i,e[3],22,-1044525330),i=o(i,a,l,h,e[4],7,-176418897),h=o(h,i,a,l,e[5],12,1200080426),l=o(l,h,i,a,e[6],17,-1473231341),a=o(a,l,h,i,e[7],22,-45705983),i=o(i,a,l,h,e[8],7,1770035416),h=o(h,i,a,l,e[9],12,-1958414417),l=o(l,h,i,a,e[10],17,-42063),a=o(a,l,h,i,e[11],22,-1990404162),i=o(i,a,l,h,e[12],7,1804603682),h=o(h,i,a,l,e[13],12,-40341101),l=o(l,h,i,a,e[14],17,-1502002290),a=o(a,l,h,i,e[15],22,1236535329),i=n(i,a,l,h,e[1],5,-165796510),h=n(h,i,a,l,e[6],9,-1069501632),l=n(l,h,i,a,e[11],14,643717713),a=n(a,l,h,i,e[0],20,-373897302),i=n(i,a,l,h,e[5],5,-701558691),h=n(h,i,a,l,e[10],9,38016083),l=n(l,h,i,a,e[15],14,-660478335),a=n(a,l,h,i,e[4],20,-405537848),i=n(i,a,l,h,e[9],5,568446438),h=n(h,i,a,l,e[14],9,-1019803690),l=n(l,h,i,a,e[3],14,-187363961),a=n(a,l,h,i,e[8],20,1163531501),i=n(i,a,l,h,e[13],5,-1444681467),h=n(h,i,a,l,e[2],9,-51403784),l=n(l,h,i,a,e[7],14,1735328473),a=n(a,l,h,i,e[12],20,-1926607734),i=s(i,a,l,h,e[5],4,-378558),h=s(h,i,a,l,e[8],11,-2022574463),l=s(l,h,i,a,e[11],16,1839030562),a=s(a,l,h,i,e[14],23,-35309556),i=s(i,a,l,h,e[1],4,-1530992060),h=s(h,i,a,l,e[4],11,1272893353),l=s(l,h,i,a,e[7],16,-155497632),a=s(a,l,h,i,e[10],23,-1094730640),i=s(i,a,l,h,e[13],4,681279174),h=s(h,i,a,l,e[0],11,-358537222),l=s(l,h,i,a,e[3],16,-722521979),a=s(a,l,h,i,e[6],23,76029189),i=s(i,a,l,h,e[9],4,-640364487),h=s(h,i,a,l,e[12],11,-421815835),l=s(l,h,i,a,e[15],16,530742520),a=s(a,l,h,i,e[2],23,-995338651),i=r(i,a,l,h,e[0],6,-198630844),h=r(h,i,a,l,e[7],10,1126891415),l=r(l,h,i,a,e[14],15,-1416354905),a=r(a,l,h,i,e[5],21,-57434055),i=r(i,a,l,h,e[12],6,1700485571),h=r(h,i,a,l,e[3],10,-1894986606),l=r(l,h,i,a,e[10],15,-1051523),a=r(a,l,h,i,e[1],21,-2054922799),i=r(i,a,l,h,e[8],6,1873313359),h=r(h,i,a,l,e[15],10,-30611744),l=r(l,h,i,a,e[6],15,-1560198380),a=r(a,l,h,i,e[13],21,1309151649),i=r(i,a,l,h,e[4],6,-145523070),h=r(h,i,a,l,e[11],10,-1120210379),l=r(l,h,i,a,e[2],15,718787259),a=r(a,l,h,i,e[9],21,-343485551),t[0]=g(i,t[0]),t[1]=g(a,t[1]),t[2]=g(l,t[2]),t[3]=g(h,t[3])}function i(t,e,i,o,n,s){return e=g(g(e,t),g(o,s)),g(e&lt;&lt;n|e&gt;&gt;&gt;32-n,i)}function o(t,e,o,n,s,r,a){return i(e&amp;o|~e&amp;n,t,e,s,r,a)}function n(t,e,o,n,s,r,a){return i(e&amp;n|o&amp;~n,t,e,s,r,a)}function s(t,e,o,n,s,r,a){return i(e^o^n,t,e,s,r,a)}function r(t,e,o,n,s,r,a){return i(o^(e|~n),t,e,s,r,a)}function a(t){var i,o=t.length,n=[1732584193,-271733879,-1732584194,271733878];for(i=64;i&lt;=t.length;i+=64)e(n,l(t.substring(i-64,i)));t=t.substring(i-64);var s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i&lt;t.length;i++)s[i&gt;&gt;2]|=t.charCodeAt(i)&lt;&lt;(i%4&lt;&lt;3);if(s[i&gt;&gt;2]|=128&lt;&lt;(i%4&lt;&lt;3),i&gt;55)for(e(n,s),i=0;i&lt;16;i++)s[i]=0;return s[14]=8*o,e(n,s),n}function l(t){var e,i=[];for(e=0;e&lt;64;e+=4)i[e&gt;&gt;2]=t.charCodeAt(e)+(t.charCodeAt(e+1)&lt;&lt;8)+(t.charCodeAt(e+2)&lt;&lt;16)+(t.charCodeAt(e+3)&lt;&lt;24);return i}function h(t){for(var e="",i=0;i&lt;4;i++)e+=u[t&gt;&gt;8*i+4&amp;15]+u[t&gt;&gt;8*i&amp;15];return e}function p(t){for(var e=0;e&lt;t.length;e++)t[e]=h(t[e]);return t.join("")}function c(e){return p(a(t(e)))}function g(t,e){return t+e&amp;4294967295}var u="0123456789abcdef".split("");if("5d41402abc4b2a76b9719d911017c592"!=c("hello"));this.hexdigest=c};i={MD5:new e}}(),_.extend(rwgps,i)},,,,,,,,function(t,e){/*!
	 *
	 * Licensed under the Apache License, Version 2.0 (the "License");
	 * you may not use this file except in compliance with the License.
	 * You may obtain a copy of the License at
	 *
	 *       http://www.apache.org/licenses/LICENSE-2.0
	 *
	 * Unless required by applicable law or agreed to in writing, software
	 * distributed under the License is distributed on an "AS IS" BASIS,
	 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 * See the License for the specific language governing permissions and
	 * limitations under the License.
	 */
function i(t){if(!i.prototype.setValues)for(var e in google.maps.OverlayView.prototype)i.prototype[e]=google.maps.OverlayView.prototype[e];t=t||{},google.maps.OverlayView.apply(this,arguments),this.content_=t.content||"",this.disableAutoPan_=t.disableAutoPan||!1,this.maxWidth_=t.maxWidth||0,this.pixelOffset_=t.pixelOffset||new google.maps.Size(0,0),this.position_=t.position||new google.maps.LatLng(0,0),this.zIndex_=t.zIndex||null,this.boxClass_=t.boxClass||"infoBox",this.boxStyle_=t.boxStyle||{},this.closeBoxMargin_=t.closeBoxMargin||"2px",this.closeBoxURL_=t.closeBoxURL||"https://www.google.com/intl/en_us/mapfiles/close.gif",""===t.closeBoxURL&amp;&amp;(this.closeBoxURL_=""),this.infoBoxClearance_=t.infoBoxClearance||new google.maps.Size(1,1),this.isHidden_=t.isHidden||!1,this.alignBottom_=t.alignBottom||!1,this.pane_=t.pane||"floatPane",this.enableEventPropagation_=t.enableEventPropagation||!1,this.div_=null,this.closeListener_=null,this.eventListeners_=[],this.moveListener_=null,this.contextListener_=null,this.fixedWidthSet_=null}i.mouseFilter=function(t){trace("RAD"),t.returnValue="true",t.handled=!0},i.prototype.createInfoBoxDiv_=function(){var t,e=function(t){t.cancelBubble=!0,t.stopPropagation&amp;&amp;t.stopPropagation()},i=function(t){},o=this.getPanes(),n=this.div_;if(this.div_)this.div_.parentNode!=o[this.pane_]&amp;&amp;(this.div_.parentNode.removeChild(this.div_),o[this.pane_].appendChild(this.div_));else{n=this.div_=document.createElement("div");var s=this.contentDiv_=document.createElement("div");this.setBoxStyle_(),n.style.overflow="auto","undefined"==typeof this.content_.nodeType?this.div_.innerHTML=this.getCloseBoxImg_()+this.content_:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(s)),document.body.appendChild(n),o[this.pane_].appendChild(this.div_),this.addClickHandler_(),this.div_.style.width?this.fixedWidthSet_=!0:0!==this.maxWidth_&amp;&amp;this.div_.offsetWidth&gt;this.maxWidth_?(this.div_.style.width=this.maxWidth_,this.div_.style.overflow="auto",this.fixedWidthSet_=!0):(t=this.getBoxWidths_(),this.div_.style.width=this.div_.offsetWidth-t.left-t.right+"px",this.fixedWidthSet_=!1),this.panBox_(this.disableAutoPan_);var r=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove","wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],a=i;this.enableEventPropagation_||(a=e),this.eventListeners_=[];for(var l=0;l&lt;r.length;l++)this.eventListeners_.push(google.maps.event.addDomListener(this.div_,r[l],a));google.maps.event.trigger(this,"domready")}},i.prototype.getCloseBoxImg_=function(){var t="";return""!==this.closeBoxURL_&amp;&amp;(t="&lt;img",t+=" src='"+this.closeBoxURL_+"'",t+=" align=right",t+=" style='",t+=" position: relative;",t+=" cursor: pointer;",t+=" margin: "+this.closeBoxMargin_+";",t+="'&gt;"),t},i.prototype.addClickHandler_=function(){var t;""!==this.closeBoxURL_?(t=this.div_.firstChild,this.closeListener_=google.maps.event.addDomListener(t,"click",this.getCloseClickHandler_())):this.closeListener_=null},i.prototype.getCloseClickHandler_=function(){var t=this;return function(e){e.cancelBubble=!0,e.stopPropagation&amp;&amp;e.stopPropagation(),t.close(),google.maps.event.trigger(t,"closeclick")}},i.prototype.panBox_=function(t){var e,i,o=0,n=0;if(!t&amp;&amp;(e=this.getMap(),e instanceof google.maps.Map)){e.getBounds().contains(this.position_)||e.setCenter(this.position_),i=e.getBounds();var s=e.getDiv(),r=s.offsetWidth,a=s.offsetHeight,l=this.pixelOffset_.width,h=this.pixelOffset_.height,p=this.div_.offsetWidth,c=this.div_.offsetHeight,g=this.infoBoxClearance_.width,u=this.infoBoxClearance_.height,d=this.getProjection().fromLatLngToContainerPixel(this.position_);if(d.x&lt;-l+g?o=d.x+l-g:d.x+p+l+g&gt;r&amp;&amp;(o=d.x+p+l+g-r),this.alignBottom_?d.y&lt;-h+u+c?n=d.y+h-u-c:d.y+h+u&gt;a&amp;&amp;(n=d.y+h+u-a):d.y&lt;-h+u?n=d.y+h-u:d.y+c+h+u&gt;a&amp;&amp;(n=d.y+c+h+u-a),0!==o||0!==n){e.getCenter();e.panBy(o,n)}}},i.prototype.setBoxStyle_=function(){var t,e;if(this.div_){this.div_.className=this.boxClass_,this.div_.style.cssText="",e=this.boxStyle_;for(t in e)e.hasOwnProperty(t)&amp;&amp;(this.div_.style[t]=e[t]);"undefined"!=typeof this.div_.style.opacity&amp;&amp;""!==this.div_.style.opacity&amp;&amp;(this.div_.style.filter="alpha(opacity="+100*this.div_.style.opacity+")"),this.div_.style.position="absolute",null!==this.zIndex_&amp;&amp;(this.div_.style.zIndex=this.zIndex_)}},i.prototype.getBoxWidths_=function(){var t,e={top:0,bottom:0,left:0,right:0},i=this.div_;return document.defaultView&amp;&amp;document.defaultView.getComputedStyle?(t=i.ownerDocument.defaultView.getComputedStyle(i,""),t&amp;&amp;(e.top=parseInt(t.borderTopWidth,10)||0,e.bottom=parseInt(t.borderBottomWidth,10)||0,e.left=parseInt(t.borderLeftWidth,10)||0,e.right=parseInt(t.borderRightWidth,10)||0)):document.documentElement.currentStyle&amp;&amp;i.currentStyle&amp;&amp;(e.top=parseInt(i.currentStyle.borderTopWidth,10)||0,e.bottom=parseInt(i.currentStyle.borderBottomWidth,10)||0,e.left=parseInt(i.currentStyle.borderLeftWidth,10)||0,e.right=parseInt(i.currentStyle.borderRightWidth,10)||0),e},i.prototype.onRemove=function(){this.div_&amp;&amp;(this.div_.parentNode.removeChild(this.div_),this.div_=null)},i.prototype.onAdd=function(){this.createInfoBoxDiv_()},i.prototype.draw=function(){var t=this.getProjection().fromLatLngToDivPixel(this.position_);this.div_.style.left=t.x+this.pixelOffset_.width+"px",this.alignBottom_?this.div_.style.bottom=-(t.y+this.pixelOffset_.height)+"px":this.div_.style.top=t.y+this.pixelOffset_.height+"px",this.isHidden_?this.div_.style.visibility="hidden":this.div_.style.visibility="visible"},i.prototype.setOptions=function(t){"undefined"!=typeof t.boxClass&amp;&amp;(this.boxClass_=t.boxClass,this.setBoxStyle_()),"undefined"!=typeof t.boxStyle&amp;&amp;(this.boxStyle_=t.boxStyle,this.setBoxStyle_()),"undefined"!=typeof t.content&amp;&amp;this.setContent(t.content),"undefined"!=typeof t.disableAutoPan&amp;&amp;(this.disableAutoPan_=t.disableAutoPan),"undefined"!=typeof t.maxWidth&amp;&amp;(this.maxWidth_=t.maxWidth),"undefined"!=typeof t.pixelOffset&amp;&amp;(this.pixelOffset_=t.pixelOffset),"undefined"!=typeof t.position&amp;&amp;this.setPosition(t.position),"undefined"!=typeof t.zIndex&amp;&amp;this.setZIndex(t.zIndex),"undefined"!=typeof t.closeBoxMargin&amp;&amp;(this.closeBoxMargin_=t.closeBoxMargin),"undefined"!=typeof t.closeBoxURL&amp;&amp;(this.closeBoxURL_=t.closeBoxURL),"undefined"!=typeof t.infoBoxClearance&amp;&amp;(this.infoBoxClearance_=t.infoBoxClearance),"undefined"!=typeof t.isHidden&amp;&amp;(this.isHidden_=t.isHidden),"undefined"!=typeof t.enableEventPropagation&amp;&amp;(this.enableEventPropagation_=t.enableEventPropagation),this.div_&amp;&amp;this.draw()},i.prototype.setContent=function(t){this.content_=t,this.div_&amp;&amp;this.contentDiv_?(this.closeListener_&amp;&amp;(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.fixedWidthSet_||(this.div_.style.width=""),"undefined"==typeof t.nodeType?this.contentDiv_.innerHTML=t:(this.contentDiv_.innerHTML="",this.contentDiv_.appendChild(t)),this.fixedWidthSet_||(this.div_.style.width=this.div_.offsetWidth+"px",this.div_.innerHTML=this.contentDiv_),this.addClickHandler_()):this.createInfoBoxDiv_(),google.maps.event.trigger(this,"content_changed")},i.prototype.setPosition=function(t){this.position_=t,this.div_&amp;&amp;this.draw(),google.maps.event.trigger(this,"position_changed")},i.prototype.setZIndex=function(t){this.zIndex_=t,this.div_&amp;&amp;(this.div_.style.zIndex=t),google.maps.event.trigger(this,"zindex_changed")},i.prototype.getContent=function(){return this.content_},i.prototype.getPosition=function(){return this.position_},i.prototype.getZIndex=function(){return this.zIndex_},i.prototype.show=function(){this.isHidden_=!1,this.div_&amp;&amp;(this.div_.style.visibility="visible")},i.prototype.hide=function(){this.isHidden_=!0,this.div_&amp;&amp;(this.div_.style.visibility="hidden")},i.prototype.open=function(t,e){var i=this;e&amp;&amp;(this.position_=e.getPosition(),this.moveListener_=google.maps.event.addListener(e,"position_changed",function(){i.setPosition(this.getPosition())})),this.setMap(t),this.div_&amp;&amp;this.panBox_()},i.prototype.close=function(){if(this.closeListener_&amp;&amp;(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.eventListeners_&amp;&amp;this.eventListeners_.length&gt;0){for(var t=0;t&lt;this.eventListeners_.length;t++)google.maps.event.removeListener(this.eventListeners_[t]);this.eventListeners_=[]}this.moveListener_&amp;&amp;(google.maps.event.removeListener(this.moveListener_),this.moveListener_=null),this.contextListener_&amp;&amp;(google.maps.event.removeListener(this.contextListener_),this.contextListener_=null),this.setMap(null)},t.exports=i},function(t,e,i){(function(e){t.exports=e.InfoBox=i(25)}).call(e,function(){return this}())},,function(t,e,i){(function(e){t.exports=e.rwgpsG_js_maps_actions=i(7)}).call(e,function(){return this}())}]);
//# sourceMappingURL=map-c064a4b8e60099b6e0bf-bundle.js.map</pre></body></html>