{"id":7590,"date":"2021-12-17T09:10:16","date_gmt":"2021-12-17T00:10:16","guid":{"rendered":"https:\/\/gunmagisgeek.com\/blog\/?p=7590"},"modified":"2021-12-17T09:11:56","modified_gmt":"2021-12-17T00:11:56","slug":"deck-gl%e3%81%a7%e5%a1%97%e3%82%8a%e3%81%ab%e3%83%86%e3%82%af%e3%82%b9%e3%83%81%e3%83%a3%e3%82%92%e9%81%a9%e7%94%a8%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/deck-gl\/7590","title":{"rendered":"deck.gl\u3067\u5857\u308a\u306b\u30c6\u30af\u30b9\u30c1\u30e3\u3092\u9069\u7528\u3059\u308b"},"content":{"rendered":"\n<p>\u3053\u306e\u8a18\u4e8b\u306f<a href=\"https:\/\/qiita.com\/advent-calendar\/2021\/deckgl\">deck.gl Advent Calendar 2021&nbsp;<\/a>\u53c2\u52a0\u8a18\u4e8b\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6982\u8981<\/h2>\n\n\n\n<p>GeoJSON\u30ec\u30a4\u30e4\u30fc\u306a\u3069\u3067\u30dd\u30ea\u30b4\u30f3\u3092\u63cf\u753b\u3059\u308b\u969b\u306b\u3001\u5857(fill)\u306b\u30c6\u30af\u30b9\u30c1\u30e3\u3092\u9069\u7528\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<p>\u30d1\u30bf\u30fc\u30f3\u30d5\u30a1\u30a4\u30eb\uff08\u900f\u904epng\uff09\u3092\u8aad\u307f\u8fbc\u3093\u3067\u30dd\u30ea\u30b4\u30f3\u306b\u7db2\u639b\u3051\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<iframe src=\"https:\/\/codesandbox.io\/embed\/deck-gl-tu-ritubusinitekusutiyawoshi-yong-suru1-p8iy0?fontsize=14&amp;hidenavigation=1&amp;theme=dark&amp;view=split\" style=\"width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;\" title=\"deck.gl - \u5857\u308a\u3064\u3076\u3057\u306b\u30c6\u30af\u30b9\u30c1\u30e3\u3092\u9069\u7528\u3059\u308b\uff11\" allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\" sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"><\/iframe>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u8aac<\/h2>\n\n\n\n<p>FillStyleExtension\u3092GeoJSON\u30ec\u30a4\u30e4\u30fc\u306b\u9069\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5857\u308a(Fill)\u30b9\u30bf\u30a4\u30eb\u3092\u62e1\u5f35\u3057\u30c6\u30af\u30b9\u30c1\u30e3\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>extension\u306fdeck.gl\u3068\u306f\u5225\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:sh decode:true \" title=\"\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\">&gt; npm install @deck.gl\/extensions<\/pre><\/div>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:js decode:true \">\/\/\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3\u306e\u8aad\u307f\u8fbc\u307f\nimport { FillStyleExtension } from \"@deck.gl\/extensions\";\n\n\/\/texure\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u8a2d\u5b9a\nconst textureMapping = {\n  \"hatch-1x\": {\n    x: 4,\n    y: 4,\n    width: 120,\n    height: 120,\n    mask: true\n  },\n  \"hatch-2x\": {\n    x: 132,\n    y: 4,\n    width: 120,\n    height: 120,\n    mask: true\n  },\n  \"hatch-cross\": {\n    x: 4,\n    y: 132,\n    width: 120,\n    height: 120,\n    mask: true\n  },\n  dots: {\n    x: 132,\n    y: 132,\n    width: 120,\n    height: 120,\n    mask: true\n  }\n};\n\nexport function renderLayers(props) {\n    \n  \/\/\u770c\u5883\u754c\u30c7\u30fc\u30bf\u3092\u53ef\u8996\u5316\n  const geoJSONlayer = new GeoJsonLayer({\n    id: \"geojson-layer\",\n    data: \".\/data\/pref.geojson\",\n    stroked: true,\n    filled: true,\n    getLineColor: [0, 0, 0, 255],\n    lineWidthMinPixels: 1,\n    getFillColor: [255, 0, 0],\n    \/\/\u30c6\u30af\u30b9\u30c1\u30e3\u306b\u30de\u30b9\u30af\u3092\u9069\u7528\u3059\u308b\u304b\u30fb\u3044\u306a\u304b\u3002\n    fillPatternMask: true,\n    \/\/\u900f\u904epng\u306e\u30d1\u30bf\u30fc\u30f3\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\n    fillPatternAtlas: \".\/texture\/pattern.png\",\n    \/\/mapping\u8a2d\u5b9a\u3092\u53cd\u6620\n    fillPatternMapping: textureMapping,\n    \/\/\u30dd\u30ea\u30b4\u30f3\u306b\u9069\u7528\u3059\u308b\u30c6\u30af\u30b9\u30c1\u30e3\u3092\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u305f\u540d\u524d\u3067\u6307\u5b9a\u3059\u308b\n    getFillPattern: (f, { index }) =&gt; \"hatch-2x\", \/\/\u5225\u306e\u540d\u524d\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u547c\u3073\u51fa\u3059\u30c6\u30af\u30b9\u30c1\u30e3\u3092\u5909\u66f4\u3067\u304d\u307e\u3059\n    getFillPatternScale: 100,\n    getFillPatternOffset: [0, 0],\n    \/\/\u30a8\u30af\u30b9\u30c6\u30f3\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\n    extensions: [new FillStyleExtension({ pattern: true })]\n  });\n\n  return [geoJSONlayer];\n}\n<\/pre><\/div>\n\n\n\n<p>\u30de\u30c3\u30d4\u30f3\u30b0\u8a2d\u5b9a\u306b\u3066\u3001\u30d1\u30bf\u30fc\u30f3\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u753b\u50cf\u306e\u6a2a\u5e45\u3084\u7e26\u5e45\u3001\u4f4d\u7f6e\u306a\u3069\u3092\u6b63\u78ba\u306b\u8a2d\u5b9a\u3057\u306a\u3044\u3068\u6b63\u3057\u304f\u30c6\u30af\u30b9\u30c1\u30e3\u304c\u9069\u7528\u3055\u308c\u306a\u3044\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u8a2d\u5b9a\u3057\u305f\u30de\u30c3\u30d4\u30f3\u30b0\u304b\u3089\u5b9f\u969b\u306b\u9069\u7528\u3059\u308b\u3082\u306e\u3092\u6307\u5b9a\u3059\u308bgetFillPattern\u30a2\u30af\u30bb\u30b5\u306f\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u306e\u4e2d\u3067\u30de\u30c3\u30d4\u30f3\u30b0\u540d\u3092\u623b\u308a\u5024\u3068\u3057\u3066\u8fd4\u3055\u306a\u3044\u3068\u884c\u3051\u306a\u3044\u4ed5\u69d8\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e00\u822c\u7684\u306a\u753b\u50cf\u3082\u30c6\u30af\u30b9\u30c1\u30e3\u3068\u3057\u3066\u9069\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u753b\u50cf\u3092\u305d\u306e\u307e\u307e\u9069\u7528\u3057\u305f\u3044\u5834\u5408\u306f\u3001fillPatternMask\u3092\u300cfalse\u300d\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"802\" src=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture2.jpg\" alt=\"\" class=\"wp-image-7592\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture2.jpg 946w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture2-177x150.jpg 177w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture2-768x651.jpg 768w\" sizes=\"auto, (max-width: 946px) 100vw, 946px\" \/><figcaption><a href=\"https:\/\/codesandbox.io\/s\/deck-gl-tu-ritubusinitekusutiyawoshi-yong-suru2-myhlg\" data-type=\"URL\" data-id=\"https:\/\/codesandbox.io\/s\/deck-gl-tu-ritubusinitekusutiyawoshi-yong-suru2-myhlg\">https:\/\/codesandbox.io\/s\/deck-gl-tu-ritubusinitekusutiyawoshi-yong-suru2-myhlg<\/a><\/figcaption><\/figure>\n\n\n\n<p>\u8907\u6570\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u30dd\u30ea\u30b4\u30f3\u3054\u3068\u306b\u9069\u7528\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"942\" height=\"800\" src=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture3.jpg\" alt=\"\" class=\"wp-image-7593\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture3.jpg 942w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture3-177x150.jpg 177w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2021\/11\/texture3-768x652.jpg 768w\" sizes=\"auto, (max-width: 942px) 100vw, 942px\" \/><figcaption><a href=\"https:\/\/codesandbox.io\/s\/deck-gl-tu-ritubusinitekusutiyawoshi-yong-suru3-x03mg\" data-type=\"URL\" data-id=\"https:\/\/codesandbox.io\/s\/deck-gl-tu-ritubusinitekusutiyawoshi-yong-suru3-x03mg\">https:\/\/codesandbox.io\/s\/deck-gl-tu-ritubusinitekusutiyawoshi-yong-suru3-x03mg<\/a><\/figcaption><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u8a18\u4e8b\u306fdeck.gl Advent Calen&hellip;<\/p>\n","protected":false},"author":1,"featured_media":7596,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"class_list":["post-7590","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-deck-gl","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/7590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/comments?post=7590"}],"version-history":[{"count":6,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/7590\/revisions"}],"predecessor-version":[{"id":7844,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/7590\/revisions\/7844"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/7596"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=7590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=7590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=7590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}