viewof point = {
const height = Math.round(width * 600 / 960);
const context = DOM.context2d(width, height);
const path = d3.geoPath(projection, context);
const pointPath = d3.geoPath(projection, context);
const scale = width / 960;
context.scale(scale, scale);
context.lineJoin = "round";
context.lineCap = "round";
context.beginPath();
path(topojson.mesh(us, us.objects.counties, (a, b) => a !== b && (a.id / 1000 | 0) === (b.id / 1000 | 0)));
context.lineWidth = 0.5 / scale;
context.strokeStyle = "#aaa";
context.stroke();
context.beginPath();
path(topojson.mesh(us, us.objects.states, (a, b) => a !== b));
context.lineWidth = 0.5 / scale;
context.strokeStyle = "#000";
context.stroke();
context.beginPath();
path(topojson.feature(us, us.objects.nation));
context.lineWidth = 1 / scale;
context.strokeStyle = "#000";
context.stroke();
context.lineWidth = 2, context.strokeStyle = "#f00";
const image = context.getImageData(0, 0, context.canvas.width, context.canvas.height);
function render(coordinates) {
context.canvas.value = coordinates;
context.clearRect(0, 0, width, height);
context.putImageData(image, 0, 0);
context.beginPath(), pointPath({type: "Point", coordinates: coordinates}), context.stroke();
}
context.canvas.onmousemove = ({layerX, layerY}) => {
render(projection.invert([layerX / scale, layerY / scale]));
context.canvas.dispatchEvent(new CustomEvent("input"));
};
context.canvas.onmouseout = () => {
render(dc);
context.canvas.dispatchEvent(new CustomEvent("input"));
};
render(dc);
return context.canvas;
}