function initrotate(){initP=d3.mouse(this),currRot=projection.rotate()}function rotate(){var t=d3.mouse(this),e=projection.invert(t);if(!isNaN(e[0])){var a=projection.invert(initP),r=[e[0]-a[0],e[1]-a[1]];projection.rotate([currRot[0]+r[0],currRot[1]+r[1]]),svg.selectAll("path").attr("d",path)}}var w=1200,h=600,ocean_visibility=!1,drag=d3.behavior.drag().on("drag",rotate).on("dragstart",initrotate),projection=d3.geo.orthographic().center([0,0]).translate([w/2,h/2]).scale([w/5]).clipAngle(90),path=d3.geo.path().projection(projection),svg=d3.select("body").append("svg").attr("width",w).attr("height",h),initP=[],currRot=[];d3.json("water.json",function(t,e){if(t)return console.error(t);var a=svg.selectAll(".ocean").data(topojson.feature(e,e.objects.ocean).features).enter().append("path").attr("class","ocean").style("stroke","none").style("fill","#c4d3dd").attr("d",path);svg.selectAll(".land").data(topojson.feature(e,e.objects.land).features).enter().append("path").attr("class","land").style("stroke","none").style("fill","black").attr("d",path);svg.selectAll(".lake").data(topojson.feature(e,e.objects.lakes).features).enter().append("path").attr("class","lake").style("fill","#c4d3dd").attr("d",path),svg.selectAll(".river").data(topojson.feature(e,e.objects.rivers).features).enter().append("path").attr("class","river").style("stroke","#c4d3dd").style("fill","none").attr("d",path);svg.append("circle").attr("cx",projection([0,0])[0]).attr("cy",projection([0,0])[1]).attr("r",projection([90,0])[0]-projection([0,0])[0]).attr("fill","rgba(255, 0, 0, 0)").style("cursor","pointer").call(drag);d3.select("#showOcean").on("click",function(){console.log("rien"),ocean_visibility?(a.style("visibility","hidden"),ocean_visibility=!1,d3.select(this).html("Show oceans")):(a.style("visibility","visible"),ocean_visibility=!0,d3.select(this).html("Hide oceans"))})});