{"id":5145,"date":"2016-10-03T21:56:19","date_gmt":"2016-10-03T12:56:19","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=5145"},"modified":"2016-10-03T21:56:19","modified_gmt":"2016-10-03T12:56:19","slug":"post-5145","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/leaflet-js\/5145","title":{"rendered":"\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3API Hacks! D3.js\u3092\u4f7f\u3063\u3066SVG\u3092\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3059\u308b\u3002"},"content":{"rendered":"<p>\u65b0\u3057\u3044\u5730\u56f3\u30b5\u30fc\u30d3\u30b9\u304c\u59cb\u307e\u3063\u305f\u3068\u304d\u3001\u8ab0\u3082\u304c\u6c17\u306b\u306a\u308b\u306e\u306f\u300c\u3053\u306e\u5730\u56f3\u30b5\u30fc\u30d3\u30b9\u3067D3.js\u306f\u4f7f\u3048\u308b\u306e\u3060\u308d\u3046\u304b\uff1f\u300d\u3068\u3044\u3046\u70b9\u3067\u3057\u3087\u3046\u3002\u5fc3\u914d\u3042\u308a\u307e\u305b\u3093\u3002\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3\u3067D3.js\u306f\u4f7f\u3048\u307e\u3059\u3088\uff01<\/p>\n<p><a href=\"http:\/\/internet.watch.impress.co.jp\/docs\/news\/1017418.html\">\u65e5\u672c\u5168\u56fd\u30b7\u30fc\u30e0\u30ec\u30b9\u306a\u9244\u9053\u8def\u7dda\u56f3API\u300c\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3\u300d\u3001\u30f4\u30a1\u30eb\u7814\u7a76\u6240\u304c\u7121\u511f\u63d0\u4f9b\u3092\u958b\u59cb<\/a><\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/pVndPdf8esQ\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3API\u306e\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u3092\u53d6\u5f97\u3057\u305f\u306e\u3067\u3001\u3055\u3063\u305d\u304f\u904a\u3093\u3067\u307f\u307e\u3057\u305f\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\u3001D3\u3092\u4f7f\u3046\u307e\u3067\u306e\u89e3\u8aac\u3092\u8f09\u305b\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u203b example\u306f\u30d5\u30ea\u30fc\u30d7\u30e9\u30f3\u3092\u5229\u7528\u3057\u3066\u4f5c\u6210\u3057\u3066\u3044\u308b\u305f\u30811\u65e5100\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u8d8a\u3048\u308b\u3068\u52d5\u4f5c\u3057\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30b2\u30c3\u30c8\u30b9\u30bf\u30fc\u30c8<\/h2>\n<p>\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3API\u306f\u3001\u6c4e\u7528\u5730\u56f3\u30e9\u30a4\u30d6\u30e9\u30ea\u306eleaflet.js\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3068\u306e\u3053\u3068\u306a\u306e\u3067\u3001\u307e\u305a\u306f\u30d9\u30fc\u30b7\u30c3\u30af\u306a\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u3066D3.js\u3092\u4f7f\u3046\u306e\u306b\u5fc5\u8981\u3068\u306a\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<br \/>\n\u958b\u767a\u7528\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3084\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306f\u4e0b\u8a18\u30da\u30fc\u30b8\u306b\u3066\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/ekiworld.net\/service\/sier\/railmap\/index.html\">\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3 &#8211; \u99c5\u3059\u3071\u3042\u3068\u30ef\u30fc\u30eb\u30c9<\/a><\/p>\n<p>\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u3001\u4e0a\u8a18\u30da\u30fc\u30b8\u3088\u308a\u30d5\u30ea\u30fc\u30d7\u30e9\u30f3\u306b\u7533\u3057\u8fbc\u3080\u3053\u3068\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var rosen\r\n\r\nfunction init() {\r\n  rosen = new Rosen(\"map\", {    \r\n    apiKey: \"***\" \/\/ \u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u30b5\u30f3\u30d7\u30eb\u7528\u3067\u3059\u3002\u5b9f\u969b\u306b\u3054\u5229\u7528\u3055\u308c\u308b\u3068\u304d\u306f\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002\r\n  })\r\n}\r\n\r\nwindow.addEventListener('load', init)<\/pre>\n<p><a href=\"http:\/\/shimz.me\/example\/ekispaert\/getstart\/\">example<\/a><\/p>\n<p><a href=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaert01index.html-2016-10-03-11-38-13.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaert01index.html-2016-10-03-11-38-13-300x169.png\" alt=\"\u99c5\u30b9\u30d1\u30fc\u30c8\u8def\u7dda\u56f3Hacks.1\" width=\"300\" height=\"169\" class=\"alignnone size-medium wp-image-5146 border\" \/><\/a><\/p>\n<p>\u8def\u7dda\u56f3\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u30da\u30fc\u30b8\u3067\u958b\u767a\u8005\u30c4\u30fc\u30eb\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u958b\u304d\u300cL\u300d\u3092\u5165\u529b\u5b9f\u884c\u3059\u308b\u3068\u30b0\u30ed\u30fc\u30d0\u30eb\u306bleaflet\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u8aad\u307f\u8fbc\u307e\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001map\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306frosen._map\u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u89e3\u308a\u307e\u3057\u305f\u3002<br \/>\n\u3053\u306e\u4e8c\u3064\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308c\u3070\u3001leaflet.js\u306e\u6a5f\u80fd\u3084D3.js\u3092\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3059\u308b\u3053\u3068\u304c\u554f\u984c\u306a\u304f\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u5ea7\u6a19\u53d6\u5f97<\/h2>\n<p>\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3\u306f\u3001\u30c7\u30d5\u30a9\u30eb\u30e1\u3055\u308c\u305f\u65e5\u672c\u5730\u56f3\u4e0a\u306b\u8def\u7dda\u304c\u63cf\u753b\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u305f\u3081leaflet\u4e0a\u3067\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u5ea7\u6a19\u3082\u4e00\u822c\u7684\u306a\u7def\u5ea6\u7d4c\u5ea6\u3067\u306f\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u305d\u3053\u3067\u3001map\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u4ed5\u8fbc\u307f\u3001\u30af\u30ea\u30c3\u30af\u3057\u305f\u5834\u6240\u306e\u5ea7\u6a19\u3092\u53d6\u5f97\u3057\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var output = document.querySelector(\"#output\")\r\nvar rosen\r\n\r\nfunction init() {\r\n    rosen = new Rosen(\"map\", {   \r\n      apiKey: \"***\" \/\/ \u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u30b5\u30f3\u30d7\u30eb\u7528\u3067\u3059\u3002\u5b9f\u969b\u306b\u3054\u5229\u7528\u3055\u308c\u308b\u3068\u304d\u306f\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002\r\n    });\r\n\r\n    \/\/\u30af\u30ea\u30c3\u30af\u3057\u305f\u4f4d\u7f6e\u306e\u5ea7\u6a19\u3092\u53d6\u5f97\u3059\u308b\r\n    rosen._map.on('click', function(e) {\r\n        output.value = e.latlng.lat + \", \" + e.latlng.lng\r\n    });\r\n}\r\n\r\nwindow.addEventListener('load', init)  <\/pre>\n<p><a href=\"http:\/\/shimz.me\/example\/ekispaert\/Getlatlong\/\">example<\/a><\/p>\n<p><a href=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertlatlongindex.html-2016-10-03-11-38-47.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertlatlongindex.html-2016-10-03-11-38-47-300x174.png\" alt=\"\u99c5\u30b9\u30d1\u30fc\u30c8\u8def\u7dda\u56f3Hacks.1\" width=\"300\" height=\"174\" class=\"alignnone size-medium wp-image-5147 border\" \/><\/a><\/p>\n<p>\u6771\u4eac\u99c5\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001[-0.378570556640625, 0.4677581787109375]\u3068\u3044\u3046\u5ea7\u6a19\u304c\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\u4f4d\u7f6e\u5ea7\u6a19\u3092\u53d6\u5f97\u3067\u304d\u305f\u306e\u3067\u3001\u6b21\u306fD3.js\u3092\u4f7f\u3063\u3066SVG\u3092\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<h2>D3\u3067\u30b5\u30fc\u30af\u30eb\u3092\u8f09\u305b\u308b<\/h2>\n<p>\u4e0a\u8a18\u30b3\u30fc\u30c9\u3067\u53d6\u5f97\u3057\u305f\u5ea7\u6a19\u3092\u5143\u306b\u3001D3.js\u3092\u4f7f\u3063\u3066\u30b5\u30fc\u30af\u30eb\u3092\u63cf\u753b\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\nleaflet\u306elatLngToLayerPoint\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u4f4d\u7f6e\u5ea7\u6a19\u304b\u3089\u753b\u9762\u4e0a\u306e\u5ea7\u6a19\u3078\u3068\u5909\u63db\u3067\u304d\u308b\u306e\u3067\u3001\u305d\u306e\u5024\u3092\u7528\u3044\u3066SVG\u4e0a\u306b\u30b5\u30fc\u30af\u30eb\u3092\u63cf\u753b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var output = document.querySelector(\"#output\")\r\nvar rosen\r\n\r\nvar tokyoLatLng = [-0.378570556640625, 0.4677581787109375]\r\n\r\nfunction init() {\r\n\trosen = new Rosen(\"map\", {    \/\/ \"map\"\u306f&lt;div&gt;\u306eid\u3068\u4e00\u81f4\u3055\u305b\u308b\r\n\t\tapiKey: \"***\" \/\/ \u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u30b5\u30f3\u30d7\u30eb\u7528\u3067\u3059\u3002\u5b9f\u969b\u306b\u3054\u5229\u7528\u3055\u308c\u308b\u3068\u304d\u306f\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002\r\n\t});\r\n\r\n    var width = document.querySelector(\"#map\").clientWidth\r\n    var height = document.querySelector(\"#map\").clientHeight\r\n    \r\n    \/leaflet\u306eoverlayer\u306bsvg\u8981\u7d20\u3092\u8ffd\u52a0\u3059\u308b\r\n\tvar svg = d3.select(rosen._map.getPanes().overlayPane).append(\"svg\")\r\n        .attr(\"width\", width).attr(\"height\", height)\r\n    \r\n\r\n\tvar g = svg.append(\"g\").attr(\"class\", \"leaflet-zoom-hide\")\r\n    \r\n\t\r\n    var circle = g.selectAll(\".tokyo\")\r\n        .data([tokyoLatLng])\r\n\r\n\t\/\/\u30a2\u30fc\u30af\u30eb\u8981\u7d20\u3092\u8ffd\u52a0\r\n\tcircle.enter().append(\"circle\")\r\n\t\t.attr(\"class\", \"tokyo\")\r\n\t\t.attr(\"fill\", \"red\")\r\n\t\t.attr(\"fill-opacity\", 0.5)\r\n\t\t.attr(\"r\", 100)\r\n    \r\n    var update = function() {\r\n\t\r\n\t\t\/\/\u30b5\u30fc\u30af\u30eb\u8981\u7d20\u306e\u4f4d\u7f6e\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\r\n\t\tg.select(\".tokyo\").attr(\"transform\", function(d) {\r\n\t\t\tvar pos = rosen._map.latLngToLayerPoint(d)\r\n            return \"translate(\"+ pos.x +\",\"+ pos.y +\")\";\r\n\t\t})\r\n\t}\r\n    \r\n    rosen._map.on(\"viewreset zoom\", update)\r\n\t\r\n\tupdate()\r\n    \r\n}\r\n\r\nwindow.addEventListener('load', init) <\/pre>\n<p><a href=\"http:\/\/shimz.me\/example\/ekispaert\/d3circle\/\">example<\/a><\/p>\n<p><a href=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertd3.jsindex.html-2016-10-03-11-39-39.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertd3.jsindex.html-2016-10-03-11-39-39-300x170.png\" alt=\"\u99c5\u30b9\u30d1\u30fc\u30c8\u8def\u7dda\u56f3Hacks.3\" width=\"300\" height=\"170\" class=\"alignnone size-medium wp-image-5148 border\" \/><\/a><\/p>\n<h2>Truf\u3067\u30d0\u30c3\u30d5\u30a1\u3092\u751f\u6210\u3059\u308b<\/h2>\n<p>\u3055\u3066\u3001\u30b5\u30fc\u30af\u30eb\u3092\u8868\u793a\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u3057\u305f\u304c\u3001\u3042\u304f\u307e\u3067\u5358\u306a\u308b\u5186\u306a\u306e\u3067\u30d1\u30f3\u30fb\u30ba\u30fc\u30e0\u306b\u9023\u52d5\u3057\u307e\u305b\u3093\u3002<br \/>\n\u305d\u3053\u3067<a href=\"https:\/\/gunmagisgeek.com\/blog\/category\/turf-js\">turf.js<\/a>\u3092\u4f7f\u3063\u3066100m\u30d0\u30c3\u30d5\u30a1\u306eGeoJSON\u3092\u751f\u6210\u3057D3.js\u3092\u4f7f\u3063\u3066\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n\u99c5\u3059\u3071\u3042\u3068\u7528\u306b\u751f\u6210\u3057\u305f\u30ab\u30b9\u30bf\u30e0\u30d7\u30ed\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3092geoPath\u95a2\u6570\u306b\u30d0\u30a4\u30f3\u30c9\u3059\u308b\u3053\u3068\u3067\u3001GeoJSON\u3092\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var output = document.querySelector(\"#output\")\r\nvar rosen\r\n\r\n\/\/\u30d0\u30c3\u30d5\u30a1\u751f\u6210\r\nvar pointGeojson = turf.point([-0.378570556640625, 0.4677581787109375])\r\nvar bufferGeojson = turf.buffer(pointGeojson, 100, \"meters\")\r\n\r\nfunction init() {\r\n    rosen = new Rosen(\"map\", {    \/\/ \"map\"\u306f&lt;div&gt;\u306eid\u3068\u4e00\u81f4\u3055\u305b\u308b\r\n\t\tapiKey: \"***\" \/\/ \u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u30b5\u30f3\u30d7\u30eb\u7528\u3067\u3059\u3002\u5b9f\u969b\u306b\u3054\u5229\u7528\u3055\u308c\u308b\u3068\u304d\u306f\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002\r\n    })\r\n\r\n\t\/\/\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3\u7528\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3092\u751f\u6210\u3059\u308b\r\n    var projectPoint = function(x, y) {\r\n        var point = rosen._map.latLngToLayerPoint([x,y])\r\n        this.stream.point(point.x, point.y)\r\n    }\r\n    \r\n    var transform = d3.geoTransform({point: projectPoint})\r\n    var path = d3.geoPath().projection(transform)\r\n        \r\n    var svg = d3.select(rosen._map.getPanes().overlayPane).append(\"svg\")\r\n\r\n    var g = svg.append(\"g\").attr(\"class\", \"leaflet-zoom-hide\")\r\n    \r\n    var buffer = g.append(\"path\").datum(bufferGeojson)\r\n            .attr(\"fill\", \"red\")\r\n            .attr(\"fill-opacity\", 0.5)\r\n        \r\n    var update = function() {\r\n\t\t\/\/leaflet\u306e\u63cf\u753b\u9818\u57df\u306b\u8ffd\u5f93\u3059\u308b\u3088\u3046\u306bsvg\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3059\u308b\r\n\t\tvar bounds = path.bounds(bufferGeojson)\r\n\t\tvar topLeft = bounds[0]\r\n\t\tvar bottomRight = bounds[1]\r\n\t\t\r\n\t\tsvg .attr(\"width\", bottomRight[0] - topLeft[0])\r\n\t\t\t.attr(\"height\", bottomRight[1] - topLeft[1])\r\n\t\t\t.style(\"left\", topLeft[0] + \"px\")\r\n\t\t\t.style(\"top\", topLeft[1] + \"px\");\r\n\t\t\r\n\t\tg.attr(\"transform\", \"translate(\" + -topLeft[0] + \",\" + -topLeft[1] + \")\")\r\n\r\n\t\t\/\/\u30d0\u30c3\u30d5\u30a1\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\r\n        buffer.attr(\"d\", path)\r\n\t}\r\n    \r\n    rosen._map.on(\"viewreset zoom\", update)\r\n \r\n\tupdate()\r\n    \r\n}\r\n\r\nwindow.addEventListener('load', init)   <\/pre>\n<p><a href=\"http:\/\/shimz.me\/example\/ekispaert\/buffer\/\">example<\/a><\/p>\n<p><a href=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertbufferindex.html-2016-10-03-11-40-06.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertbufferindex.html-2016-10-03-11-40-06-300x169.png\" alt=\"\u99c5\u30b9\u30d1\u30fc\u30c8\u8def\u7dda\u56f3Hacks.4\" width=\"300\" height=\"169\" class=\"alignnone size-medium wp-image-5149 border\" \/><\/a><\/p>\n<h2>GeoJSON\u30a8\u30c7\u30a3\u30bf\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>GeoJSON\u3092\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u306e\u3067\u3001\u3042\u3068\u306f\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3\u306b\u72ec\u81ea\u306eGeoJSON\u3092\u4f5c\u6210\u3067\u304d\u308c\u3070\u3001\u307b\u307cD3\u3067\u3084\u308a\u305f\u3044\u3053\u3068\u306f\u3067\u304d\u305d\u3046\u3067\u3059\u3002<br \/>\n\u305d\u3053\u3067\u3001\u99c5\u3059\u3071\u3042\u3068\u8def\u7dda\u56f3\u7528\u306eGeoJSON\u3092\u4f5c\u6210\u3059\u308b\u305f\u3081\u306b\u3001<a href=\"https:\/\/github.com\/Leaflet\/Leaflet.draw\">leaflet.draw\u30d7\u30e9\u30b0\u30a4\u30f3<\/a>\u3092\u3064\u304b\u3063\u3066\u30a8\u30c7\u30a3\u30bf\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3067\u3001\u8def\u7dda\u56f3\u4e0a\u3092\u30c8\u30ec\u30fc\u30b9\u3057\u3066GeoJSON\u3092\u4f5c\u6210\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u203b \u306a\u304a\u3001\u5730\u56f3\u3092\u30c8\u30ec\u30fc\u30b9\u3059\u308b\u306e\u306f\u3044\u308d\u3044\u308d\u3068\u554f\u984c\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u6012\u3089\u308c\u305f\u308a\u8a34\u3048\u3089\u308c\u305f\u308a\u6bb4\u3089\u308c\u305f\u308a\u3057\u305f\u3089\u6b62\u3081\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var geo = \"\"\r\nvar output = document.querySelector(\"#output\")    \r\nvar geo = \"\"\r\nvar rosen\r\n\r\nfunction init() {\r\n    rosen = new Rosen(\"map\", {   \r\n        apiKey: \"***\" \/\/ \u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u30b5\u30f3\u30d7\u30eb\u7528\u3067\u3059\u3002\u5b9f\u969b\u306b\u3054\u5229\u7528\u3055\u308c\u308b\u3068\u304d\u306f\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002\r\n    })\r\n  \r\n    \/\/\u30a8\u30c7\u30a3\u30c3\u30c8\u30ec\u30a4\u30e4\u30fc\u3092\u751f\u6210  \r\n    var drawnItems = new L.FeatureGroup()\r\n    rosen._map.addLayer(drawnItems);\r\n    \/\/\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u306b\u30a8\u30c7\u30a3\u30bf\u3092\u8ffd\u52a0\u3059\u308b\r\n    var drawControl = new L.Control.Draw({\r\n        edit: {\r\n            featureGroup: drawnItems\r\n        }\r\n    })\r\n    rosen._map.addControl(drawControl)\r\n    \r\n    \r\n    \/\/\u30a8\u30c7\u30a3\u30c3\u30c8\u5f8c\u51e6\u7406\r\n    rosen._map.on('draw:created', function (e) {\r\n        geo = e.layer.toGeoJSON()\r\n        \r\n        \/\/lat,lng\u306e\u9806\u756a\u304c\u9006\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u4fee\u6b63\u3059\u308b\r\n        geo.geometry.coordinates[0].forEach(function(d){\r\n            var tmp0 = d[0]\r\n            var tmp1 = d[1]\r\n            \r\n            d[0] = tmp1\r\n            d[1] = tmp0\r\n        })\r\n        \r\n        output.value = JSON.stringify(geo)\r\n        \r\n    })      \r\n    \r\n}\r\n\r\nwindow.addEventListener('load', init) <\/pre>\n<p><a href=\"http:\/\/shimz.me\/example\/ekispaert\/editor\/\">example<\/a><\/p>\n<p><a href=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaerteditindex.html-2016-09-30-18-14-51.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaerteditindex.html-2016-09-30-18-14-51-300x191.png\" alt=\"\u99c5\u30b9\u30d1\u30fc\u30c8\u8def\u7dda\u56f3Hacks.5\" width=\"300\" height=\"191\" class=\"alignnone size-medium wp-image-5150 border\" \/><\/a><\/p>\n<p>draw\u30d7\u30e9\u30b0\u30a4\u30f3\u3067\u751f\u6210\u3055\u308c\u308bGeoJSON\u306fcoordinates\u306e\u4e2d\u8eab\u304clonglat\u5f62\u5f0f\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001latlong\u5f62\u5f0f\u306b\u5909\u66f4\u3057\u3066\u51fa\u529b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\u3001\u7fa4\u99ac\u770c\u306e\u30dd\u30ea\u30b4\u30f3\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<h2>D3\u3092\u4f7f\u3063\u3066Geojson\u8868\u793a<\/h2>\n<p>\u4e0a\u8a18\u30a8\u30c7\u30a3\u30bf\u3067\u4f5c\u6210\u3057\u305fGeoJSON\u3092D3\u3092\u4f7f\u3063\u3066\u8def\u7dda\u56f3\u4e0a\u306b\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3057\u307e\u3059\u3002<br \/>\n\u57fa\u672c\u7684\u306b\u306fturf.js\u3067\u751f\u6210\u3057\u305fGeoJSON\u3092\u8868\u793a\u3059\u308b\u306e\u3068\u304b\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var rosen\r\nfunction init(args) {\r\n\t\/\/geojson\u306e\u8aad\u307f\u8fbc\u307f\r\n    d3.json(\"..\/gunma.geojson?1\", main)    \r\n}\r\n\r\nfunction main(geojson) {\r\n\t\r\n    rosen = new Rosen(\"map\", {    \/\/ \"map\"\u306f&lt;div&gt;\u306eid\u3068\u4e00\u81f4\u3055\u305b\u308b\r\n      apiKey: \"***\" \/\/ \u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306f\u30b5\u30f3\u30d7\u30eb\u7528\u3067\u3059\u3002\u5b9f\u969b\u306b\u3054\u5229\u7528\u3055\u308c\u308b\u3068\u304d\u306f\u66f8\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002\r\n    });\r\n\r\n\t\/\/\u99c5\u30b9\u30d1\u30fc\u30c8\u8def\u7dda\u56f3\u7528\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30b7\u30e7\u30f3\u3092\u751f\u6210\r\n    var projectPoint = function(x, y) {\r\n        var point = rosen._map.latLngToLayerPoint([x,y])\r\n        this.stream.point(point.x, point.y);\r\n    }\r\n    \r\n    var transform = d3.geoTransform({point: projectPoint})\r\n    var path = d3.geoPath().projection(transform)\r\n    \r\n    \r\n    var width = document.querySelector(\"#map\").clientWidth\r\n    var height = document.querySelector(\"#map\").clientHeight\r\n    \r\n    var svg = d3.select(rosen._map.getPanes().overlayPane).append(\"svg\")\r\n\t\r\n    var g = svg.append(\"g\").attr(\"class\", \"leaflet-zoom-hide\")\r\n    \r\n    g.append(\"path\").datum(geojson)\r\n            .attr(\"fill\", \"red\")\r\n            .attr(\"fill-opacity\", 0.5)\r\n    \r\n    \r\n    var update = function() {\r\n\t\tvar bounds = path.bounds(geojson)\r\n\t\tvar topLeft = bounds[0]\r\n\t\tvar bottomRight = bounds[1]\r\n\t\t\r\n\t\tsvg .attr(\"width\", bottomRight[0] - topLeft[0])\r\n\t\t\t.attr(\"height\", bottomRight[1] - topLeft[1])\r\n\t\t\t.style(\"left\", topLeft[0] + \"px\")\r\n\t\t\t.style(\"top\", topLeft[1] + \"px\")\r\n\t\t\r\n\t\tg.attr(\"transform\", \"translate(\" + -topLeft[0] + \",\" + -topLeft[1] + \")\")\r\n\t\t\r\n\t\t\r\n        g.select(\"path\").attr(\"d\", path)\r\n\t}\r\n    \r\n    rosen._map.on(\"viewreset zoom\", update)\r\n \r\n\tupdate()\r\n    \r\n}\r\n\r\n\r\nwindow.addEventListener('load', init)   <\/pre>\n<p><a href=\"http:\/\/shimz.me\/example\/ekispaert\/d3gunma\/\">example<\/a><\/p>\n<p><a href=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertd3.jsgunma.html-2016-10-03-11-40-51.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/10\/shimz.meexampleekispaertd3.jsgunma.html-2016-10-03-11-40-51-300x169.png\" alt=\"\u99c5\u30b9\u30d1\u30fc\u30c8\u8def\u7dda\u56f3Hacks.7\" width=\"300\" height=\"169\" class=\"alignnone size-medium wp-image-5151 border\" \/><\/a><\/p>\n<p>\u7121\u4e8b\u3001\u5730\u56f3\u4e0a\u306b\u7fa4\u99ac\u770c\u306e\u30dd\u30ea\u30b4\u30f3\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001D3.js\u3092\u4f7f\u3063\u3066\u8def\u7dda\u56f3\u4e0a\u306b\u3055\u307e\u3056\u307e\u306a\u30d3\u30b8\u30e5\u30a2\u30e9\u30a4\u30bc\u30fc\u30b7\u30e7\u30f3\u3092\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3067\u304d\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u3057\u3044\u5730\u56f3\u30b5\u30fc\u30d3\u30b9\u304c\u59cb\u307e\u3063\u305f\u3068\u304d\u3001\u8ab0\u3082\u304c\u6c17\u306b\u306a\u308b\u306e&hellip;<\/p>\n","protected":false},"author":1,"featured_media":5152,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69,55,62],"tags":[],"class_list":["post-5145","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-d3v4","category-leaflet-js","category-turf-js","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/5145","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=5145"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/5145\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/5152"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=5145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=5145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=5145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}