!function(a,b,c){vard={getElevation:function(){"undefined"!=typeofa.navigator?this.getElevationClient.apply(this,arguments):this.getElevationServer.apply(this,arguments)},getElevationClient:function(b,c){if(!a.google)thrownewError("Google maps api not loaded");if(0===b.length)returnc(null,null);if(1===b.length)returnc(newError("getElevation requires at least 2 points."));for(vard=[],e=0;e<b.length;e++)d.push(newgoogle.maps.LatLng(this.latitude(b[e]),this.longitude(b[e])));varf={path:d,samples:d.length},g=newgoogle.maps.ElevationService,h=this;g.getElevationAlongPath(f,function(a,d){h.elevationHandler(a,d,b,c)})},getElevationServer:function(a,b){if(0===a.length)returnb(null,null);if(1===a.length)returnb(newError("getElevation requires at least 2 points."));for(varc=require("googlemaps"),d=[],e=0;e<a.length;e++)d.push(this.latitude(a[e])+","+this.longitude(a[e]));varf=this;c.elevationFromPath(d.join("|"),d.length,function(c,d){f.elevationHandler(d.results,d.status,a,b)})},elevationHandler:function(a,b,c,d){vare=[];if("OK"==b){for(varf=0;f<a.length;f++)e.push({lat:this.latitude(c[f]),lng:this.longitude(c[f]),elev:a[f].elevation});d(null,e)}elsed(newError("Could not get elevation using Google's API"),elevationResult.status)},getGrade:function(a){varb=Math.abs(this.elevation(a[a.length-1])-this.elevation(a[0])),c=this.getPathLength(a);returnMath.floor(b/c*100)},getTotalElevationGainAndLoss:function(a){for(varb=0,c=0,d=0;d<a.length-1;d++){vare=this.elevation(a[d])-this.elevation(a[d+1]);e>0?c+=e:b+=Math.abs(e)}return{gain:b,loss:c}}};"undefined"!=typeofmodule&&"undefined"!=typeofmodule.exports?(b=require("geolib"),b.extend(d)):"function"==typeofdefine&&define.amd?define(["geolib"],function(a){returna.extend(d),a}):b.extend(d)}(this,this.geolib);