zhmap = {
function viewcounties(d) {
d3.select("body").selectAll(".district").remove();
var bounds = geoGenerator.bounds(d),
dx = bounds[1][0] - bounds[0][0],
dy = bounds[1][1] - bounds[0][1],
x = (bounds[0][0] + bounds[1][0]) / 2,
y = (bounds[0][1] + bounds[1][1]) / 2,
scale = .9 / Math.max(dx / width, dy / height),
translate = [width / 2 - scale * x, height / 2 - scale * y];
layers.transition()
.duration(2050)
.attr("transform", "translate(" + translate + ")scale(" + scale + ")" );
d3.select("body").selectAll(".graticule").style("stroke-width", 0.02);
const distri = dataMap.has(d.id) ? dataMap.get(d.id).features : [];
dis.append('g').selectAll('path')
.data(distri)
.enter()
.append("path")
.attr("class", "district")
.attr("d", geoGenerator)
.attr('stroke','#fff')
.attr("stroke-linejoin", "round")
.attr("stroke-width", 0.02)
.on("mousemove",
function(d) {locator(d,this)})
.on('mouseenter', function(d) {
d3.select(this).style('fill','red').style('fill-opacity', 0.2);
d3.select('#infos').text(d.properties.Name)
})
.on('mouseleave', function() {
d3.select(this).style('fill', 'grey').style('fill-opacity', 0.7);
d3.select('#infos').text('');
d3.select("#coo").text('');
d3.select(this)
.transition()
.duration(2000)
.delay(100)
.style("fill", "grey")
.style('fill-opacity', 0.2);
})
.on('click', function(d) {
var bounds = geoGenerator.bounds(d),
dx = bounds[1][0] - bounds[0][0],
dy = bounds[1][1] - bounds[0][1],
x = (bounds[0][0] + bounds[1][0]) / 2,
y = (bounds[0][1] + bounds[1][1]) / 2,
scale = .9 / Math.max(dx / width, dy / height),
translate = [width / 2 - scale * x, height / 2 - scale * y];
layers.transition()
.duration(2050)
//.style("stroke-width", 0.1 / scale + "px")
.attr("transform", "translate(" + translate + ")scale(" + scale + ")" );
gro.selectAll("path").attr('d',geoGenerator.pointRadius(0.03));
d3.select("body").selectAll(".district").style("stroke-width", 0.02);
d3.select("body").selectAll(".graticule").style("stroke-width", 0.01);
console.log(scale);//debug
console.log(k, (scale-scale+0.2));//debug
})
gro.selectAll("path").attr('d',geoGenerator.pointRadius(0.03));
}
monde();
province();
karsts()
if ( morelayers[0] == 'Karsts' ) {
kars.selectAll("path").style("fill", 'blue').attr('fill','blue')
//.attr("fill", "none");
};
makescalegra();
//cancer();
//equator();
//capricorne();
grotte();
// info text
svg.append('text')
.attr('x', 24)
.attr('y', 36)
.append('tspan')
.attr('id','infos')
.attr("class", "infos");
svg.append('text')
.attr('x', 20)
.attr('y', (height-10))
.append('tspan')
.attr('id','coo')
.attr("font-size", "11");
svg.call(zoom);
return svg.node()
}