// PointCircleLayerの使用例
const geojson = await d3.json("../geojson/world.geojson");
const map = new Thematika.Map({
container: '#map',
width: 800,
height: 600,
projection: d3.geoNaturalEarth1()
});
// PointCircleLayerインスタンスを作成
const circleLayer = new Thematika.PointCircleLayer({
data: geojson,
r: 5, // 固定半径
attr: {
"fill": '#ff6b6b',
"stroke": '#d63031',
"stroke-width": 1,
"opacity": 0.8
}
});
// または関数を使った動的半径設定
const dynamicCircleLayer = new Thematika.PointCircleLayer({
data: geojson,
r: (feature, index) => {
// 人口に基づいて半径を決定
const population = feature.properties?.POP_EST || 0;
return Math.sqrt(population / 1000000) + 2;
},
attr: {
"fill": (d, i) => i % 2 === 0 ? '#74b9ff' : '#fd79a8',
"stroke": '#2d3436',
"stroke-width": 0.5
}
});
// レイヤーを地図に追加
map.addLayer('circles', circleLayer);
// 半径を動的に更新
circleLayer.updateRadius((feature, index) => index % 3 + 3);