{"id":3540,"date":"2014-05-28T14:10:51","date_gmt":"2014-05-28T05:10:51","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=3540"},"modified":"2014-05-29T11:16:32","modified_gmt":"2014-05-29T02:16:32","slug":"post-3540","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/d3-js\/3540","title":{"rendered":"\u5ba4\u862d\u5e02\u306e\u5730\u7406\u60c5\u5831\u4ed8\u304d\u30aa\u30fc\u30d7\u30f3\u30c7\u30fc\u30bf\uff08\u9078\u6319\u30dd\u30b9\u30bf\u30fc\u63b2\u793a\u5834\uff09\u3092\u4f7f\u3063\u3066\u307f\u305f"},"content":{"rendered":"<p><a href=\"http:\/\/shimz.me\/example\/gmapv3\/08\/\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/05\/muroran_senkyo.jpg\" alt=\"\u5ba4\u862d\u5e02\u3000\u9078\u6319\u30dd\u30b9\u30bf\u30fc\u63b2\u793a\u5834\" width=\"590\" height=\"373\" class=\"aligncenter size-full wp-image-3541\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/05\/muroran_senkyo.jpg 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/05\/muroran_senkyo-237x150.jpg 237w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/shimz.me\/example\/gmapv3\/08\/\">example<\/a><\/p>\n<p><a href=\"http:\/\/www.city.muroran.lg.jp\/main\/org2260\/odlib.php\">\u3080\u308d\u3089\u3093\u30aa\u30fc\u30d7\u30f3\u30c7\u30fc\u30bf\u30e9\u30a4\u30d6\u30e9\u30ea<\/a>\u306b\u3066\u3001\u300c\u9078\u6319\u30dd\u30b9\u30bf\u30fc\u63b2\u793a\u5834\u300d\u3068\u3044\u3046\u30c7\u30fc\u30bf\u304c\u516c\u958b\u3055\u308c\u305f\u3068\u3044\u3046\u60c5\u5831\u3092Facebook\u3067\u77e5\u3063\u305f\u306e\u3067\u89e6\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4f8b\u306b\u3088\u3063\u3066IE9\u4ee5\u4e0a\u3001Chrome\u63a8\u5968\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u306b\u4f4d\u7f6e\u60c5\u5831\u304c\u4ed8\u52a0\u3055\u308c\u3066\u3044\u308b\u3068\u3001\u7c21\u5358\u306b\u5730\u56f3\u4e0a\u306b\u30d7\u30ed\u30c3\u30c8\u3067\u304d\u3066\u697d\u3057\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u5ba4\u862d\u5e02\u3067\u306f\u3001\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u305d\u306e\u4ed6\u306eCSV\u30d5\u30a1\u30a4\u30eb\u306b\u3082\u5168\u3066\u5ea7\u6a19\u60c5\u5831\u304c\u8ffd\u52a0\u3055\u308c\u305f\u305d\u3046\u3067\u3059\u3002\u3059\u3070\u3089\u3057\u3044\uff01<br \/>\n(\u500b\u4eba\u7684\u306b\u306f\u3001\u300cX\u5ea7\u6a19,Y\u5ea7\u6a19\u300d\u3088\u308a\u300c\u7def\u5ea6,\u7d4c\u5ea6\u300d\u60c5\u5831\u306e\u65b9\u304c\u624b\u8efd\u306b\u4f7f\u3044\u3084\u3059\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3068\u601d\u3063\u305f\u308a\u3082\u3057\u307e\u3059\u304c)<\/p>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001\u4eca\u56de\u306fShape\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30fc\u30bf\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<br \/>\n\u63b2\u793a\u677f\u306e\u7dda\u30c7\u30fc\u30bf\u3060\u3051\u3067\u306f\u5c0f\u3055\u304f\u3066\u5730\u56f3\u4e0a\u3067\u306f\u898b\u3048\u306b\u304f\u3044\u306e\u3067circle\u8981\u7d20\u3092\u91cd\u306d\u3066\u307e\u3059\u3002\u3064\u3044\u3067\u306b\u6295\u7968\u533a\u3054\u3068\u306b\u8272\u5206\u3051\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u4ed6\u3001Google Maps\u3084D3.js\u3067\u8868\u793a\u3059\u308b\u305f\u3081\u306b\u884c\u3063\u305f\u30c7\u30fc\u30bf\u30b3\u30f3\u30d0\u30fc\u30c8\u51e6\u7406\u306b\u3064\u3044\u3066\u306f\u3001\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306e\u5f8c\u306b\u7c21\u5358\u3067\u3059\u304c\u624b\u9806\u3092\u63b2\u8f09\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb<\/h2>\n<pre class=\"lang:js decode:true \" >d3.json(\"senkyo.geojson\", function(line) {\r\n\td3.json(\"point.geojson\", function(point) {\r\n\t\tmain(line, point);\r\n\t});\r\n});\r\n\r\nfunction main(line, point) {\r\n     \/\/\u30ab\u30e9\u30fc\u30ea\u30b9\u30c8\u4f5c\u6210\r\n    var color =d3.scale.category20b();\r\n    var color2 = d3.scale.category20();\r\n    var color3 = d3.scale.category10();\r\n    var cl = color.range();\r\n    var colorList = cl.concat( color2.range() );\r\n    colorList = colorList.concat(  color3.range() );\r\n\t\r\n\t\/\/\u30c4\u30fc\u30eb\u30c1\u30c3\u30d7\r\n\tvar tooltip = d3.select(\"body\")\r\n\t\t.append(\"div\")\r\n\t\t.attr(\"class\", \"tooltip\")\r\n\t\t.style(\"position\", \"absolute\")\r\n\t\t.style(\"z-index\", \"10\")\r\n\t\t.style(\"visibility\", \"hidden\")\r\n\r\n\t\r\n\t\/\/Google Map \u521d\u671f\u5316\r\n\tvar map = new google.maps.Map(document.getElementById('map'), {\r\n\t\t\tzoom: 13,\r\n\t\t\tmapTypeId: google.maps.MapTypeId.ROADMAP,\r\n\t\t\tcenter: new google.maps.LatLng(42.3352306\u3000, 140.97379909999995),       \r\n\t\t});\r\n\r\n   \/\/\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u521d\u671f\u5316\r\n    var streetViewDiv = document.getElementById(\"streetview\");\r\n    var stOptions = {\r\n        pov: {\r\n            heading: 00,\r\n            pitch: 0,\r\n            zoom: 2\r\n        }\r\n    };\r\n    \/\/\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u751f\u6210\r\n    var streetViewPanorama = new google.maps.StreetViewPanorama(streetViewDiv, stOptions);\r\n    var streetViewService = new google.maps.StreetViewService();\r\n\t\r\n\t\/\/\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u3092\u8868\u793a\r\n\tshowStreetView =  function(d){\r\n\t\tvar latlng = new google.maps.LatLng(d[1], d[0]);\r\n\t\tstreetViewPanorama.setVisible(false);\r\n\t\tstreetViewService.getPanoramaByLocation(latlng, 30, function(status){\r\n\t\t\tif(status){\r\n\t\t\t\tstreetViewPanorama.setPosition(latlng);\r\n\t\t\t\tstreetViewPanorama.setVisible(true);\r\n\t\t\t}else{\r\n\t\t\t\tconsole.log(status);\r\n\t\t\t\talert(\"StreetView \u975e\u5bfe\u5fdc\u30a8\u30ea\u30a2\u3067\u3059\");\r\n\t\t\t};    \r\n\t\t});\r\n\t}\r\n\t\t\t\r\n\t\/\/OverLay\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u4f5c\u6210\t\r\n\tvar overlay = new google.maps.OverlayView(); \r\n\toverlay.onAdd = function () {\r\n\t\t\r\n\t\t\/\/\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u8a2d\u5b9a\r\n\t\tvar layer = d3.select(this.getPanes().overlayMouseTarget).append(\"div\").attr(\"class\", \"SvgOverlay\");\r\n\t\tvar svg = layer.append(\"svg\");\r\n\t\tvar svglayer = svg.append(\"g\").attr(\"class\", \"svglayer\");\r\n\t\tvar markerOverlay = this;\r\n\t\tvar overlayProjection = markerOverlay.getProjection();\r\n\r\n\t\t\/\/Google Projection\u4f5c\u6210\r\n\t\tvar googleMapProjection = function (coordinates) {\r\n\t\t\tvar googleCoordinates = new google.maps.LatLng(coordinates[1], coordinates[0]);\r\n\t\t\tvar pixelCoordinates = overlayProjection.fromLatLngToDivPixel(googleCoordinates);\r\n\t\t\treturn [pixelCoordinates.x + 4000, pixelCoordinates.y + 4000];\r\n\t\t}\r\n\r\n\t\t\/\/\u30d1\u30b9\u30b8\u30a7\u30cd\u30ec\u30fc\u30bf\u30fc\u4f5c\u6210\r\n\t\tpath = d3.geo.path().projection(googleMapProjection);\u3000\r\n\r\n\t\toverlay.draw = function () {\r\n\t\t\tvar linedata = line.features;\r\n\t\t\tvar pointdata = point.features;\r\n\t\t\t\r\n\t\t\t\r\n\t\t\tpointdata.forEach(function(d){\r\n\t\t\t\td.latlng = [ d.geometry.coordinates[0], d.geometry.coordinates[1] ];\r\n\t\t\t\tvar tmp = googleMapProjection(d.latlng);\r\n\t\t\t\td.x = tmp[0];\r\n\t\t\t\td.y = tmp[1];\r\n\t\t\t})\r\n\r\n\t\t\t\r\n\t\t\t\/\/\u5730\u7269(\u63b2\u793a\u677f)\u63cf\u304f\r\n\t\t\tsvglayer.selectAll(\"path\")\r\n\t\t\t\t.data(linedata)\r\n\t\t\t\t.attr(\"d\", function(d){ return path(d) }) \r\n\t\t\t\t.enter()\r\n\t\t\t\t.append(\"path\")\r\n\t\t\t\t.attr({\r\n\t\t\t\t\t\"d\": function(d){ return path(d)},\r\n\t\t\t\t\t\"fill\": \"red\",\r\n\t\t\t\t});\r\n\r\n\t\t\t\/\/\u30b5\u30fc\u30af\u30eb\u3092\u91cd\u306d\u308b\r\n\t\t\tvar circleAttr = {\r\n\t\t\t\t\"cx\":function(d) {  return d.x; },\r\n\t\t\t\t\"cy\":function(d) { return d.y; },\r\n\t\t\t\t\"r\":8,\r\n\t\t\t\t\"stroke\": \"gray\",\r\n\t\t\t\t\"fill\":function(d){ return colorList[+d.properties['\u6295\u7968\u533a']] },\r\n\t\t\t\t\"fill-opacity\":0.4\r\n\t\t\t}\t\r\n\t\t\tsvglayer.selectAll(\"circle\")\r\n\t\t\t\t.data(pointdata)\r\n\t\t\t\t.attr(circleAttr)\r\n\t\t\t\t.enter()\r\n\t\t\t\t.append(\"svg:circle\")\r\n\t\t\t\t.attr(circleAttr)\r\n\t\t\t\t.on(\"click\", function(d){\r\n\t\t\t\t\tshowStreetView(d.latlng)\r\n\t\t\t\t})\r\n\t\t\t\t.on(\"mouseover\", function(d) {\r\n\t\t\t\t\ttooltip.style(\"visibility\", \"visible\");\r\n\t\t\t\t})\r\n\t\t\t\t.on(\"mouseout\", function(d) {\r\n\t\t\t\t\ttooltip.style(\"visibility\", \"hidden\");\t\t\r\n\t\t\t\t})\r\n\t\t\t\t.on(\"mousemove\", function(d){\r\n\t\t\t\t\tvar content = \"\u6295\u7968:\"+d.properties['\u6295\u7968\u533a']+\"\u533a<br\/>\";\r\n\t\t\t\t\tcontent += d.properties['\u4f4f\u6240']\r\n\t\t\t\t\ttooltip\r\n\t\t\t\t\t .style(\"top\", (d3.event.pageY-10)+\"px\")\r\n\t\t\t\t\t .style(\"left\",(d3.event.pageX+10)+\"px\")\r\n\t\t\t\t\t .html(content);\r\n\t\t\t\t});\r\n\t\t\t\t\t\r\n\t\t};\r\n\r\n\t};\r\n\r\n\t\/\/\u4f5c\u6210\u3057\u305fSVG\u3092\u5730\u56f3\u306b\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3059\u308b\r\n\toverlay.setMap(map);\r\n};<\/pre>\n<h2>\u4f5c\u696d\u30e1\u30e2<\/h2>\n<p>\u308f\u308a\u3068\u56db\u82e6\u516b\u82e6\u3057\u305f\u306e\u3067\u3001\u81ea\u5206\u7528\u306b\u8a18\u9332\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li>QGIS\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u5185\u5bb9\u306e\u78ba\u8a8d\u3068GeoJSON\u3078\u306e\u30b3\u30f3\u30d0\u30fc\u30c8\u3002<\/li>\n<li>\u5143\u30c7\u30fc\u30bf\u304c\u30e9\u30a4\u30f3(\u7dda)\u30c7\u30fc\u30bf\u3060\u3063\u305f\u306e\u3067\u3001QGIS\u4e0a\u3067\u5404\u7dda\u30c7\u30fc\u30bf\u306e\u4e2d\u5fc3\u70b9\u3092\u6c42\u3081\u30dd\u30a4\u30f3\u30c8(\u70b9)\u30c7\u30fc\u30bf\u3092\u4f5c\u6210<br \/>(\u7dda\u30c7\u30fc\u30bf\u306b\u30d0\u30c3\u30d5\u30a1\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u91cd\u5fc3\u3092\u70b9\u30c7\u30fc\u30bf\u3068\u3057\u3066\u51fa\u529b)<\/li>\n<li>GeoJSON\u306e\u51fa\u529b\u6642\u306bCRS(\u5ea7\u6a19\u7cfb)\u3092\u300cWGS84\u300d\u306b\u5909\u63db\u3002<\/li>\n<\/ul>\n<p>\u6642\u9593\u304c\u3042\u3063\u305f\u3089\u3001\u3053\u306e\u8fba\u306e\u4f5c\u696d\u306b\u3064\u3044\u3066\u5225\u8a18\u4e8b\u306b\u8a73\u7d30\u3092\u66f8\u3053\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>example \u3080\u308d\u3089\u3093\u30aa\u30fc\u30d7\u30f3\u30c7\u30fc\u30bf\u30e9\u30a4\u30d6\u30e9\u30ea\u306b&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3541,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,51,37],"tags":[],"class_list":["post-3540","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3-js","category-datavis","category-google-map-api","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3540","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=3540"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3540\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/3541"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=3540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=3540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=3540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}