{"id":3733,"date":"2014-09-05T12:39:25","date_gmt":"2014-09-05T03:39:25","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=3733"},"modified":"2018-10-22T11:29:48","modified_gmt":"2018-10-22T02:29:48","slug":"post-3733","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3-js\/3733","title":{"rendered":"\u3010D3.js\u3011Google Map\u4e0a\u306b\u5186\u30b0\u30e9\u30d5\u3092\u8868\u793a\u3059\u308b"},"content":{"rendered":"<p><a href=\"https:\/\/shimz.me\/datavis\/gunma\/maebashi\/population\/pie.html\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/maebashi140905.png\" alt=\"google map\u4e0a\u306b\u5186\u30b0\u30e9\u30d5\u3092\u8868\u793a\u3059\u308b\" width=\"500\" height=\"388\" class=\"aligncenter size-full wp-image-3734\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/maebashi140905.png 500w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/09\/maebashi140905-193x150.png 193w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/shimz.me\/datavis\/gunma\/maebashi\/population\/pie.html\">example<\/a><\/p>\n<p>\u4ee5\u524d,\u524d\u6a4b\u306e\u30aa\u30fc\u30d7\u30f3\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066<a href=\"https:\/\/gunmagisgeek.com\/blog\/d3-js\/3463\">\u30b7\u30f3\u30dc\u30eb\u30de\u30c3\u30d7\u3092\u4f5c\u6210<\/a>\u3057\u307e\u3057\u305f\u304c\u3001\u540c\u3058\u300c<span class=\"removed_link\" title=\"https:\/\/www.city.maebashi.gunma.jp\/sisei\/499\/509\/p012146.html\">\u753a\u4e01\u3054\u3068\u306e\u5e74\u9f62\u5225\u4eba\u53e3\u69cb\u6210\u63a8\u79fb<\/span>\u300d\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u3001\u7537\u5973\u6bd4\u3092\u8868\u3059\u5186\u30b0\u30e9\u30d5\u3092\u5730\u56f3\u4e0a\u306b\u8868\u793a\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb<\/h2>\n<p>\u30b3\u30fc\u30c9\u304c\u7d50\u69cb\u9577\u304f\u306a\u3063\u305f\u306e\u3067\u3001Google Maps API\u306edraw\u30e1\u30bd\u30c3\u30c9\u5185\u3060\u3051\u53c2\u8003\u306b\u8f09\u305b\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >overlay.draw = function () {\n    var index = getIndex(); \u3000\/\/\u9078\u629e\u3055\u308c\u3066\u3044\u308b\u9805\u76ee\u3092\u53d6\u5f97\n    \n    \/\/\u30d4\u30af\u30bb\u30eb\u30dd\u30b8\u30b7\u30e7\u30f3\u60c5\u5831\n    pointdata.forEach(function(d) {\n        var point = googleMapProjection([d['X_CODE'] ,d['Y_CODE']]);\/\/\u4f4d\u7f6e\u60c5\u5831\u2192\u30d4\u30af\u30bb\u30eb\n        d['xpoint'] = point[0];\n        d['ypoint'] = point[1]; \n    });\n    \n    \/\/\u524d\u306e\u30b0\u30e9\u30d5\u3092\u3059\u3079\u3066\u524a\u9664\u3059\u308b\n    d3.selectAll(\".pie\").remove()\n    \n    \/\/\u30c7\u30fc\u30bf\u306e\u6570\u3060\u3051\u5186\u30b0\u30e9\u30d5\u3092\u5404\n    pointdata.forEach(function(point){\n        if (+point['\u7537'+index] &lt;= 0 &amp;&amp; +point['\u5973'+index] &lt;= 0) return ;  \/\/\u7537\u5973\u3068\u3082\u306b\uff10\u4eba\u306e\u5834\u5408\u306f\u629c\u3051\u308b\n        \n        \/\/\u5186\u30b0\u30e9\u30d5\u4f5c\u6210\u7528\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f5c\u308b\n        var data = [\n            {key:\"\u7537\", value:point['\u7537'+index], city:point.CITYNAME, town:point.NAME},\n            {key:\"\u5973\", value:point['\u5973'+index], city:point.CITYNAME, town:point.NAME}\n        ];\n            \n        \/\/  \u5186\u30b0\u30e9\u30d5\u3092\u4f5c\u6210\u3059\u308b\u306e\u306b\u5fc5\u8981\u306a\u5ea7\u6a19\u8a08\u7b97\n        var pie = d3.layout.pie().value(function(d) { return d.value; });           \n        var arc = d3.svg.arc().outerRadius(15).innerRadius(Math.floor(3));\u3000\/\/\u30d1\u30b9\u30c7\u30fc\u30bf\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\n        \n        var arcsGroup = gunmalayer \/\/Gmap\u4e0a\u306esvg\u30ec\u30a4\u30e4\n            .data([data])   \n            .append(\"g\")\n            .attr(\"class\", \"pie\")\n            .attr(\"transform\", \"translate(\" + point.xpoint+ \",\" + point.ypoint + \")\")\u3000\/\/\u5186\u30b0\u30e9\u30d5\u3092\u8868\u793a\u3059\u308b\u5ea7\u6a19\u3092\u6307\u5b9a\n\n        \n        \/\/\u5186\u30b0\u30e9\u30d5(\u30b0\u30eb\u30fc\u30d7)\u4f5c\u6210    \n        var circleGroup = arcsGroup.selectAll(\".pie\")     \n           .data(pie)                       \n           .enter()                        \n           .append(\"svg:g\")                \n           .attr(\"class\", \"pie\") ;\n         \n         \/\/\u5186\u30b0\u30e9\u30d5 path\u63cf\u753b \n        var circlePaths = circleGroup.append(\"svg:path\")\n           .attr(\"class\", \"pie\")\n           .attr({\n               fill:function(d){\n                   if(d.data.key == \"\u7537\"){\n                       return \"blue\";\n                   }else{\n                       return \"red\";\n                   }\n               },\n               \"stroke\":\"black\",\n               d: arc\n           })\n        \n        \/\/\u30de\u30a6\u30b9\u30aa\u30fc\u30d0\u30fc\u3057\u305f\u969b\u306b\u8a73\u7d30\u3092\u8868\u793a      \n        circleGroup.append(\"title\")\n            .text(function(d){ return d.data.town + \" \" + d.data.key + \"\uff1a\" +d.data.value + \"\u4eba\" })\n                \n                \n    })\n\n}<\/pre>\n<p>D3.js\u3092\u4f7f\u3066Google Map\u4e0a\u306bSVG\u3092\u8868\u793a\u3059\u308b\u65b9\u6cd5\u306f\u4ee5\u4e0b\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n<span class=\"removed_link\" title=\"https:\/\/gunmagisgeek.com\/blog\/d3-js\/2379\">\u3010D3.js\u3011Google Map\u306bSVG\u3092\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3059\u308b(SHAPE\u30c7\u30fc\u30bf\u8efd\u91cf\u5316)<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>example \u4ee5\u524d,\u524d\u6a4b\u306e\u30aa\u30fc\u30d7\u30f3\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3734,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,37],"tags":[],"class_list":["post-3733","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3-js","category-google-map-api","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3733","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=3733"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3733\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/3734"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=3733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=3733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=3733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}