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

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -