{"id":3659,"date":"2014-08-02T14:35:28","date_gmt":"2014-08-02T05:35:28","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=3659"},"modified":"2018-03-06T12:01:04","modified_gmt":"2018-03-06T03:01:04","slug":"post-3659","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3-js\/3659","title":{"rendered":"[D3+Leaflet]\u56fd\u571f\u5730\u7406\u9662\u3055\u3093\u6e3e\u8eab\u306e\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u3067\u904a\u3093\u3067\u307f\u305f\u3002"},"content":{"rendered":"<p><a href=\"https:\/\/shimz.me\/example\/leaflet\/vectolMap\/index2.html#17\/36.32236\/139.01306\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/08\/vectoltilemap140802.jpg\" alt=\"\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u30de\u30c3\u30d7\" width=\"590\" height=\"282\" class=\"alignnone size-full wp-image-3660\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/08\/vectoltilemap140802.jpg 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/08\/vectoltilemap140802-300x143.jpg 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.gsi.go.jp\/johofukyu\/johofukyu40039.html\">\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u306e\u63d0\u4f9b\u5b9f\u9a13\u306b\u3064\u3044\u3066\uff5c\u56fd\u571f\u5730\u7406\u9662<\/a><\/p>\n<p><a href=\"https:\/\/gunmagisgeek.com\/blog\/d3-js\/3595\">FOSS4G 2014 Hokkaido<\/a>\u306b\u3066\u4f1a\u5834\u3092\u30b6\u30ef\u3064\u304b\u305b\u305f\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u304c\u3068\u3046\u3068\u3046\u516c\u958b\u3055\u308c\u307e\u3057\u305f\u3002<br \/>\n\u79c1\u3082\u53bb\u5e74\u306e<a href=\"https:\/\/gunmagisgeek.com\/blog\/d3-js\/3181\">Advent Calendar<\/a>\u3067\u3061\u3087\u3053\u3063\u3068\u3060\u3051\u7d39\u4ecb\u3057\u305f\u3053\u3068\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u308c\u4ee5\u6765\u3042\u307e\u308a\u89e6\u3063\u3066\u3044\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u3053\u308c\u3092\u6a5f\u306b\u3044\u308d\u3044\u308d\u904a\u3093\u3067\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/gsi-cyberjapan.github.io\/vector-tile-experiment\/#17\/36.10347\/140.08741\">\u9053\u8def\u4e2d\u5fc3\u7dda\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u8868\u793a\u30b5\u30f3\u30d7\u30eb<\/a><\/p>\n<p>\u56fd\u571f\u5730\u7406\u9662\u3055\u3093\u304c\u7528\u610f\u3057\u3066\u304f\u308c\u305f\u4e0a\u8a18\u30b5\u30f3\u30d7\u30eb\u3092\u5f04\u3063\u3066\u904a\u3093\u3067\u3044\u305f\u306e\u3067\u3059\u304c\u2026\u2026\u30b5\u30f3\u30d7\u30eb\u3067\u4f7f\u308f\u308c\u3066\u3044\u308bTileLayer.GeoJSON.js\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u306f\u3001\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3055\u308c\u308bPath\u3092\u76f4\u63a5\u5f04\u308b\u65b9\u6cd5\u304c\u5206\u304b\u3089\u305a\u53f3\u5f80\u5de6\u5f80\u3002<br \/>\n\uff08onEachFeature\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u5185\u3067Path\u8981\u7d20\u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u304b\u306a\uff1f \u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u30a4\u30d9\u30f3\u30c8\u767a\u706b\u6642\u306b\u306fDOM\u4e0a\u306bpath\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\uff09<\/p>\n<p>TileLayer.GeoJSON.js\u3067\u3082\u30b9\u30bf\u30a4\u30eb\u306e\u6307\u5b9a\u3084\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u306a\u3069\u884c\u3048\u308b\u306e\u3067\u7279\u306b\u554f\u984c\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u305b\u3063\u304b\u304f\u306e\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u30c7\u30fc\u30bf\u3001\u3067\u304d\u308b\u3053\u3068\u306a\u3089\u9053\u8def\u306e\u4e00\u672c\u4e00\u672c\u307e\u3067\u81ea\u5206\u81ea\u8eab\u3067\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3057\u305f\u3044\uff01<\/p>\n<p>\u305d\u3046\u601d\u3063\u3066\u3001\u3044\u308d\u3044\u308d\u63a2\u3057\u3066\u307f\u305f\u306e\u3067\u3059\u304c\u30bf\u30a4\u30eb\u30c7\u30fc\u30bf\u30ed\u30fc\u30c9\u6642\u306bPath\u8981\u7d20\u306b\u76f4\u63a5\u30a2\u30af\u30bb\u30b9\u3059\u308b\u65b9\u6cd5\u3092\u7d50\u5c40\u307f\u3064\u3051\u3089\u308c\u306a\u304b\u3063\u305f\u306e\u3067\u3001TileLayer.GeoJSON.js\u3092\u4f7f\u308f\u305a\u3001D3.js\u3092\u4f7f\u3063\u3066\u63cf\u753b\u3059\u308bTileLayer.d3GeoJSON.js\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>D3.js\u3067\u63cf\u753b\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3055\u308c\u3066\u3044\u308bPath\u5168\u3066\u306bGeoJSON\u30c7\u30fc\u30bf\u304c\u675f\u7e1b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3067\u3001\u3044\u3064\u3082\u901a\u308aD3\u3092\u4f7f\u3063\u3066\u3044\u304b\u3088\u3046\u306b\u3082\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3088\uff01<\/p>\n<h2>D3\u3067\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u3092\u63cf\u753b\u3059\u308b<\/h2>\n<p>\u4eca\u306e\u3068\u3053\u308d\u3001\u30ec\u30a4\u30e4\u30fc\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3068\u9023\u52d5\u3057\u306a\u3044\u306a\u3069\u3001\u3044\u305f\u308b\u3068\u3053\u308d\u306b\u30d0\u30b0\u304c\u3042\u308a\u307e\u3059\u3002\u4f8b\u306e\u5982\u304fChrome\u3067\u3057\u304b\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"lang:js decode:true \" title=\"TileLayer.d3GeoJSON.js\" >L.TileLayer.d3GeoJSON =  L.TileLayer.extend({\n    tileNodes:null,\n    onAdd : function(map) {\n        this._map = map;\n        L.TileLayer.prototype.onAdd.call(this,map);\n        this._path = d3.geo.path().projection(function(d) {\n            var point = map.latLngToLayerPoint(new L.LatLng(d[1],d[0]));\n            return [point.x,point.y];\n        });\n        this.on(\"tileunload\",function(d) {\n            if (d.tile.xhr) d.tile.xhr.abort();\n            if (d.tile.nodes) d.tile.nodes.remove();\n            d.tile.nodes = null;\n            d.tile.xhr = null;\n        });\n    },\n    onRemove: function (map) {\n        d3.selectAll(\".d3-geojson-layer\").remove();\n    },  \n    _loadTile : function(tile,tilePoint) {\n        var self = this;\n        this._adjustTilePoint(tilePoint);\n\n        if (!tile.nodes &amp;&amp; !tile.xhr) {\n            tile.xhr = d3.json(this.getTileUrl(tilePoint),function(error, geojson) {\n                if (error) {\n                    console.log(error);\n                } else {\n                    \n                    if (self.options.filter){\n                        var tmp;\n                        tmp = geojson.features.filter(self.options.filter);\n                        geojson.features = tmp;\n                    }\n                    \n                    tile.xhr = null;\n                    tile.nodes = d3.select(map._container).select(\"svg\").append(\"g\")\n                        .attr(\"class\", \"d3-geojson-layer leaflet-zoom-hide\");\n                    tile.nodes.selectAll(\"path\")\n                    .data(geojson.features).enter()\n                    .append(\"path\")\n                    .attr(\"d\", self._path)\n                    .attr(self.options.attr)\n                    .style(self.options.style)\n                    .on(\"click\", self.options.onClick)\n                    .on(\"mouseover\", self.options.onMouseover )\n                    .on(\"mouseout\", self.options.onMouseoute )\n                    ;\n                }\n            });\n        }\n    }\n});\n<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u4f7f\u3044\u307e\u3059<\/p>\n<pre class=\"lang:js decode:true \" >\/\/\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u8a2d\u5b9a\nvar vec =  new L.TileLayer.d3GeoJSON(\n    \"http:\/\/cyberjapandata.gsi.go.jp\/xyz\/experimental_rdcl\/{z}\/{x}\/{y}.geojson\",\n    {\n        \"attr\":{\n            \"class\":function(d){\n                return d.properties.rID ;\n            },\n            \"stroke-width\": 4,\n            \"stroke\": \"black\"\n        },\n        \"style\": {\n            \"cursor\": \"pointer\"\n        },\n        \"layerName\": \"vectile\",\n        \"onClick\":function(d){\n              alert(JSON.stringify(d.properties, null, \" \"));\n        }\n    }\n)\n\n\n\/\/\u5730\u7406\u9662\u30bf\u30a4\u30eb\uff08\u6a19\u6e96\u5730\u56f3\uff09\u8a2d\u5b9a    \nvar std = new  L.tileLayer(\n    'http:\/\/cyberjapandata.gsi.go.jp\/xyz\/std\/{z}\/{x}\/{y}.png',\n    {\n        attribution: \"\u5730\u7406\u9662\u30bf\u30a4\u30eb\uff08\u6a19\u6e96\u5730\u56f3\uff09\", \n        opacity: 0.4,\n    })\n\nvar map = L.map(\"map\", {\n        center: [36.322356, 139.013057], zoom: 17,\n        layers: [vec, std]\n    });\n\nmap.options.maxZoom = 18;\nmap.options.minZoom = 10\n\nmap._initPathRoot();\n\nL.control.scale({imperial: false}).addTo(map);\nL.control.layers({}, {\n    '\u5730\u7406\u9662\u30bf\u30a4\u30eb\uff08\u6a19\u6e96\u5730\u56f3\uff09': std,\n    '\u9053\u8def\u4e2d\u5fc3\u7dda': vec\n}).addTo(map);\n<\/pre>\n<h3>\u904a\u3093\u3067\u307f\u305f<\/h3>\n<p>d3.js\u3092\u7528\u3044\u3066\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u3092\u63cf\u753b\u3002\u9053\u8def\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u5c5e\u6027\u30c7\u30fc\u30bf\u304c\u898b\u308c\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/shimz.me\/example\/leaflet\/vectolMap\/index2.html#17\/36.32236\/139.01306\">example1<\/a><\/p>\n<p>Path\u8981\u7d20\u306b\u30de\u30a6\u30b9\u30aa\u30fc\u30d0\u30fc\u30a4\u30d9\u30f3\u30c8\u3092\u8a2d\u5b9a\u3002\u56fd\u9053\u3001\u5e02\u533a\u753a\u6751\u9053\u7b49\u3001\u90fd\u9053\u5e9c\u770c\u9053\u3001\u305d\u308c\u305e\u308c\u3067\u30de\u30a6\u30b9\u30aa\u30fc\u30d0\u30fc\u3057\u305f\u3068\u304d\u306e\u8272\u3092\u5909\u3048\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u7121\u99c4\u306b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3057\u307e\u3059\u3002\u2026\u2026\u91cd\u3044deth\u3002<br \/>\n<a href=\"http:\/\/shimz.me\/example\/leaflet\/vectolMap\/index3.html#17\/36.32236\/139.01306\">example2<\/a><\/p>\n<p>zoom\u30ec\u30d9\u30eb\u306b\u5fdc\u3058\u3066\u8868\u793a\u3059\u308b\u9053\u8def\u3092\u9593\u5f15\u3044\u305f\u308a\u7dda\u306e\u592a\u3055\u3092\u5909\u3048\u3066\u307f\u305f\u308a\u3057\u307e\u3057\u305f\u3002<br \/>\n\u9593\u5f15\u304f\u9053\u8def\u306f\u3001\u5e45(rnkWidth)\u306e\u5024\u3092\u3064\u304b\u3063\u3066\u5224\u5225\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/shimz.me\/example\/leaflet\/vectolMap\/index4.html#16\/36.3154\/139.0481\">example3<\/a><\/p>\n<p>\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u30c7\u30fc\u30bf\u306f\u3001\u30e9\u30b9\u30bf\u30bf\u30a4\u30eb\u306b\u6bd4\u3079\u3066\u5229\u7528\u3059\u308b\u5074\u304c\u597d\u304d\u52dd\u624b\u306b\u64cd\u4f5c\u3057\u3066\u904a\u3076\u3053\u3068\u304c\u3067\u304d\u308b\u9762\u767d\u3044\u30b5\u30fc\u30d3\u30b9\u3067\u3059\u3002<br \/>\n\u7686\u3055\u3093\u3082\u305c\u3072\u6d3b\u7528\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30d9\u30af\u30c8\u30eb\u30bf\u30a4\u30eb\u306e\u63d0\u4f9b\u5b9f\u9a13\u306b\u3064\u3044\u3066\uff5c\u56fd\u571f\u5730\u7406\u9662 FO&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3660,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,55],"tags":[],"class_list":["post-3659","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3-js","category-leaflet-js","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3659","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=3659"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3659\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/3660"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=3659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=3659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=3659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}