arcgis-visualization について
arcgis-visualizationは、ArcGIS Maps SDK for JavaScriptでレイヤーをスタイリングする開発者向けスキルです。レンダラー、シンボル、データ駆動の視覚変数、2D・3Dマップのラベル設定を扱います。
主な機能
- 01カテゴリ・範囲・密度別のレンダラー例
- 022D・3Dシンボルの設定
- 03色・サイズ・不透明度・回転の変数
- 04ラベル配置とArcade式
- 05オートキャストとESMインポート例
活用シーン
- 01カテゴリや数値範囲に応じたフィーチャのスタイル設定
- 02ポイント密度図や属性の円グラフ表示
- 03データフィールドに基づくシンボル外観の調整
- 04Arcade式を使ったラベル追加
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ saschabrunnerch/ arcgis-maps-sdk-js-ai-context --skill arcgis-visualizationインストール後、Claude Code で/arcgis-visualizationを入力して読み込まれたか確認します。
同梱ファイルAGENTS.md
詳細
ArcGIS の視覚化
レンダラー、シンボル、視覚変数、ラベル、エフェクトを使ってレイヤーをスタイル設定する際に、このスキルを使用します。
インポートパターン
ESM の直接インポート
import SimpleRenderer from "@arcgis/core/renderers/SimpleRenderer.js";
import UniqueValueRenderer from "@arcgis/core/renderers/UniqueValueRenderer.js";
import ClassBreaksRenderer from "@arcgis/core/renderers/ClassBreaksRenderer.js";
import SimpleMarkerSymbol from "@arcgis/core/symbols/SimpleMarkerSymbol.js";
import SimpleLineSymbol from "@arcgis/core/symbols/SimpleLineSymbol.js";
import SimpleFillSymbol from "@arcgis/core/symbols/SimpleFillSymbol.js";
CDN の動的インポート
const [SimpleRenderer, SimpleMarkerSymbol] = await $arcgis.import([
"@arcgis/core/renderers/SimpleRenderer.js",
"@arcgis/core/symbols/SimpleMarkerSymbol.js",
]);
注: 以下の例ではオートキャスト(
typeを指定したプレーンオブジェクト)を使用しています。CDN を使用する場合は、import X from "path"をconst X = await $arcgis.import("path")に置き換えてください。
レンダラーの種類の概要
| レンダラー | オートキャストの型 | 用途 |
|---|---|---|
| SimpleRenderer | "simple" | すべてのフィーチャに同じシンボルを使用 |
| UniqueValueRenderer | "unique-value" | カテゴリごとに異なるシンボルを使用 |
| ClassBreaksRenderer | "class-breaks" | 数値範囲ごとに異なるシンボルを使用 |
| HeatmapRenderer | "heatmap" | 密度の視覚化(ポイントのみ) |
| DotDensityRenderer | "dot-density" | ドット密度マップ(ポリゴンのみ) |
| PieChartRenderer | "pie-chart" | フィーチャごとの円グラフ |
| DictionaryRenderer | "dictionary" | 軍事用シンボル(MIL-STD-2525) |
| FlowRenderer | "flow" | アニメーション付きフローライン(画像) |
SimpleRenderer
const renderer = {
type: "simple",
symbol: {
type: "simple-marker",
color: "blue",
size: 8,
outline: {
color: "white",
width: 1,
},
},
};
layer.renderer = renderer;
視覚変数を使用する場合
const renderer = {
type: "simple",
symbol: {
type: "simple-marker",
color: "#13EB0C",
outline: { color: "#A9A9A9", width: 0.5 },
},
visualVariables: [
{
type: "size",
field: "population",
stops: [
{ value: 1000, size: 4 },
{ value: 10000, size: 12 },
{ value: 100000, size: 24 },
],
},
],
};
UniqueValueRenderer
基本的なユニーク値
const renderer = {
type: "unique-value",
field: "type",
defaultSymbol: { type: "simple-fill", color: "gray" },
uniqueValueInfos: [
{
value: "residential",
symbol: { type: "simple-fill", color: "#FFFF00" },
label: "Residential",
},
{
value: "commercial",
symbol: { type: "simple-fill", color: "#FF0000" },
label: "Commercial",
},
{
value: "industrial",
symbol: { type: "simple-fill", color: "#800080" },
label: "Industrial",
},
],
};
グループ化したユニーク値(凡例に見出しを表示)
const renderer = {
type: "unique-value",
field: "zonecode",
uniqueValueGroups: [
{
heading: "Commercial",
classes: [
{
label: "C-1 | Neighborhood Commercial",
symbol: createFillSymbol([189, 145, 145]),
values: "C-1",
},
{
label: "C-2 | Community Commercial",
symbol: createFillSymbol([255, 179, 219]),
values: "C-2",
},
],
},
{
heading: "Residential",
classes: [
{
label: "R-1 | Low Density",
symbol: createFillSymbol([255, 255, 224]),
values: "R-1",
},
{
label: "Special Areas",
symbol: createFillSymbol([161, 237, 237]),
values: ["S-DW", "S-DR", "S-RP"], // Multiple values
},
],
},
],
};
function createFillSymbol(color) {
return {
type: "simple-fill",
color: color,
outline: null,
};
}
ClassBreaksRenderer
const renderer = {
type: "class-breaks",
field: "population",
normalizationField: "area", // Optional: divide by this field
legendOptions: {
title: "Population Density",
},
defaultSymbol: {
type: "simple-fill",
color: "black",
style: "backward-diagonal",
},
defaultLabel: "No data",
classBreakInfos: [
{
minValue: 0,
maxValue: 100,
symbol: { type: "simple-fill", color: "#fffcd4" },
label: "< 100",
},
{
minValue: 100,
maxValue: 500,
symbol: { type: "simple-fill", color: "#b1cdc2" },
label: "100 - 500",
},
{
minValue: 500,
maxValue: 1000,
symbol: { type: "simple-fill", color: "#38627a" },
label: "500 - 1,000",
},
{
minValue: 1000,
maxValue: Infinity,
symbol: { type: "simple-fill", color: "#0d2644" },
label: "> 1,000",
},
],
};
HeatmapRenderer
const renderer = {
type: "heatmap",
colorStops: [
{ color: "rgba(63, 40, 102, 0)", ratio: 0 },
{ color: "#472b77", ratio: 0.083 },
{ color: "#563098", ratio: 0.25 },
{ color: "#7139d4", ratio: 0.5 },
{ color: "#853fff", ratio: 0.664 },
{ color: "#c29f80", ratio: 0.83 },
{ color: "#ffff00", ratio: 1 },
],
maxDensity: 0.01,
minDensity: 0,
radius: 18, // Blur radius in pixels
};
PieChartRenderer
const renderer = {
type: "pie-chart",
attributes: [
{ field: "asian_pop", label: "Asian", color: "#ed5151" },
{ field: "black_pop", label: "Black", color: "#149ece" },
{ field: "white_pop", label: "White", color: "#a7c636" },
{ field: "other_pop", label: "Other", color: "#9e559c" },
],
size: 18,
othersCategory: {
threshold: 0.05,
color: "gray",
label: "Other",
},
};
2D シンボルの種類
SimpleMarkerSymbol(ポイント)
const symbol = {
type: "simple-marker",
style: "circle", // circle, square, cross, x, diamond, triangle
color: [255, 0, 0],
size: 12,
outline: {
color: [255, 255, 255],
width: 2,
},
};
SimpleLineSymbol
const symbol = {
type: "simple-line",
style: "solid", // solid, dash, dot, dash-dot, etc.
color: [0, 0, 255],
width: 2,
cap: "round", // round, butt, square
join: "round", // round, miter, bevel
};
SimpleFillSymbol(ポリゴン)
const symbol = {
type: "simple-fill",
style: "solid", // solid, none, horizontal, vertical, cross, etc.
color: [255, 255, 0, 0.5], // RGBA
outline: {
type: "simple-line",
color: [0, 0, 0],
width: 1,
},
};
PictureMarkerSymbol
const symbol = {
type: "picture-marker",
url: "https://example.com/icon.png",
width: 24,
height: 24,
xoffset: 0,
yoffset: 0,
};
TextSymbol
const symbol = {
type: "text",
text: "Label",
color: "white",
font: {
family: "Arial",
size: 12,
weight: "bold",
},
haloColor: "black",
haloSize: 1,
};
3D シンボルの種類
PointSymbol3D
// Icon marker
const symbol = {
type: "point-3d",
symbolLayers: [
{
type: "icon",
resource: { primitive: "circle" },
material: { color: "red" },
size: 12,
},
],
};
// Object marker
const objectSymbol = {
type: "point-3d",
symbolLayers: [
{
type: "object",
resource: { primitive: "cylinder" }, // cone, cube, sphere, diamond
material: { color: "blue" },
height: 100,
width: 10,
depth: 10,
},
],
};
WebStyleSymbol(ギャラリーの 3D アイコン)
const symbol = {
type: "web-style",
name: "Pushpin 1",
styleName: "Esri2DPointSymbolsStyle",
};
MeshSymbol3D(SceneLayer 用)
const symbol = {
type: "mesh-3d",
symbolLayers: [
{
type: "fill",
material: { color: [244, 247, 134] },
},
],
};
LineSymbol3D
const symbol = {
type: "line-3d",
symbolLayers: [
{
type: "path",
profile: "quad", // circle, quad
material: { color: "red" },
width: 5,
height: 5,
},
],
};
PolygonSymbol3D
const symbol = {
type: "polygon-3d",
symbolLayers: [
{
type: "extrude",
material: { color: "blue" },
size: 100, // Extrusion height
},
],
};
視覚変数
視覚変数のクラス:ColorVariable、SizeVariable、OpacityVariable、RotationVariable。
import ColorVariable from "@arcgis/core/renderers/visualVariables/ColorVariable.js";
import SizeVariable from "@arcgis/core/renderers/visualVariables/SizeVariable.js";
サイズ変数
visualVariables: [
{
type: "size",
field: "magnitude",
stops: [
{ value: 1, size: 4 },
{ value: 5, size: 20 },
{ value: 10, size: 40 },
],
},
];
色変数
visualVariables: [
{
type: "color",
field: "temperature",
stops: [
{ value: 0, color: "blue" },
{ value: 50, color: "yellow" },
{ value: 100, color: "red" },
],
},
];
不透明度変数
visualVariables: [
{
type: "opacity",
field: "confidence",
stops: [
{ value: 0, opacity: 0.1 },
{ value: 100, opacity: 1 },
],
},
];
回転変数
visualVariables: [
{
type: "rotation",
field: "heading",
rotationType: "geographic", // or "arithmetic"
},
];
ラベリング
layer.labelingInfo = [
{
symbol: {
type: "text",
color: "white",
font: {
family: "Noto Sans",
size: 10,
weight: "bold",
},
haloColor: "#472b77",
haloSize: 1,
},
labelPlacement: "above-center", // Various placement options
labelExpressionInfo: {
expression: "$feature.name", // Arcade expression
},
where: "population > 10000", // SQL filter
minScale: 500000,
maxScale: 0,
},
];
layer.labelsVisible = true;
ラベルの配置
- ポイント:
above-center、below-center、center-center、above-leftなど - ライン:
above-along、below-along、center-along - ポリゴン:
always-horizontal
Arcade のラベル式
labelExpressionInfo: {
expression: `
var pop = $feature.population;
if (pop > 1000000) {
return $feature.name + " (" + Round(pop/1000000, 1) + "M)";
}
return $feature.name;
`;
}
オートキャスト
すべてのシンボルとレンダラーオブジェクトはオートキャストに対応しています。クラスをインスタンス化せず、プレーンオブジェクトを使用してください。
// Autocast: plain object with type property
layer.renderer = {
type: "simple",
symbol: {
type: "simple-marker",
color: "red",
size: 8,
},
};
TypeScript では、as const または satisfies を使用します。
layer.renderer = {
type: "simple",
symbol: {
type: "simple-marker",
color: "red",
size: 8,
},
} as const;
インスタンスメソッドが必要な場合は、明示的にクラスを使用します。
import SimpleRenderer from "@arcgis/core/renderers/SimpleRenderer.js";
import SimpleMarkerSymbol from "@arcgis/core/symbols/SimpleMarkerSymbol.js";
layer.renderer = new SimpleRenderer({
symbol: new SimpleMarkerSymbol({ color: "red", size: 8 }),
});
レイヤーエフェクト(ブルーム、ぼかし、ドロップシャドウ)とブレンドモードについては、
arcgis-feature-effectsを参照してください。
スマートマッピングのレンダラーとデータ駆動型の視覚化については、
arcgis-smart-mappingを参照してください。
CIM を使用した高度な地図記号については、
arcgis-cim-symbolsを参照してください。
参考サンプル
get-started-visualization- データ視覚化の入門visualization-classbreaks- 数値データ用の ClassBreaksRenderervisualization-unique-value-groups- グループ化したユニーク値レンダラーvisualization-vv-color- 色を使った視覚変数visualization-pie-chart- 多変量データ用の PieChartRenderervisualization-heatmap- ヒートマップによる視覚化visualization-dot-density- ドット密度マップvisualization-point-styles- ポイントシンボルのスタイルlabels-basic- 基本的なラベル設定labels-multiline- 複数行のラベルlabels-multiple-classes- 複数のラベルクラス
よくある落とし穴
-
typeプロパティの欠落:レンダラーとシンボルのどちらにも、自動キャストに必要なtypeプロパティがあります。// Anti-pattern: missing type on renderer and symbol layer.renderer = { symbol: { color: "red", size: 8 }, };// Correct: include type at both renderer and symbol level layer.renderer = { type: "simple", symbol: { type: "simple-marker", color: "red", size: 8, }, };影響:
typeがないと、自動キャストはエラーを出さずに失敗します。フィーチャはデフォルトのシンボル設定で描画されます。 -
色の形式:色は、16 進数、名前付き、RGB 配列、または RGBA 配列で指定できます。
color: "red"; color: "#FF0000"; color: [255, 0, 0]; color: [255, 0, 0, 0.5]; // With transparency -
ビジュアル変数には数値フィールドが必要です:サイズや色に文字列フィールドを使用すると、変化が反映されません。
// Anti-pattern: string field for size visualVariables: [ { type: "size", field: "city_name", // String field - no variation stops: [ { value: 0, size: 4 }, { value: 100, size: 40 }, ], }, ];// Correct: numeric field for size visualVariables: [ { type: "size", field: "population", // Numeric field stops: [ { value: 10000, size: 4 }, { value: 1000000, size: 40 }, ], }, ]; -
ラベル式は Arcade です:JavaScript ではなく、Arcade の構文(
$feature.fieldName)を使用してください。 -
3D シンボルには SceneView が必要です:PointSymbol3D、LineSymbol3D、PolygonSymbol3D は SceneView でのみ動作し、MapView では動作しません。
関連スキル
arcgis-cim-symbols- 高度なカートグラフィック シンボル(CIM)arcgis-smart-mapping- データから自動生成されるレンダラーarcgis-feature-effects- 視覚効果とフィルターarcgis-core-maps- マップとビューの設定arcgis-layers- レイヤーの種類と設定