i trying make simple zoom/pan solution, using code
var map = document.getelementbyid('map'), svg = d3.select('#map') .call(d3.behavior.zoom().on("zoom", function () { svg.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")") })) .append('g');
but @ this moment gives:
uncaught typeerror: cannot read property 'zoom' of undefined
in html have this:
<svg id="map" class="map" viewbox="0 0 8000 2000"></svg>
p.s. inspired this
try below code: in v4 of d3.js, d3.behavior.zoom changed d3.zoom
var svg; svg= d3.select("svg") .call(d3.zoom().on("zoom", function () { svg.attr("transform", d3.event.transform) })) .append("g");
Comments
Post a Comment