javascript - Map zooming with D3 and Datamaps -
i need help. i'm using datamaps , want implement zoom on country. can find loads of examples how can achieve this, difference is, want able external button.
let's outside of <div id="worldmap"></div>
map being rendered have button: <button data-location="aus">
. how able zoom using these values? know datamaps uses these short names (aus = australia) notate name. can provide long lat
coordinates if way it.
can me issue? i'm new d3 , datamaps.
one way translate , scale region of choice using translate scale
shown below.
function gotoaustralia(){ map.svg.selectall(".datamaps-subunits").transition().duration(750).attr("transform", "scale(1.5)translate(-400,-100)"); } function gotosouthamerica(){ map.svg.selectall(".datamaps-subunits").transition().duration(750).attr("transform", "scale(1.5)translate(-50,-300)"); } function reset(){ map.svg.selectall(".datamaps-subunits").transition().duration(750).attr("transform", ""); }
working code here
Comments
Post a Comment