{"id":4225,"date":"2015-04-21T22:18:42","date_gmt":"2015-04-21T13:18:42","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=4225"},"modified":"2018-09-18T16:43:28","modified_gmt":"2018-09-18T07:43:28","slug":"post-4225","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/google-map-api\/4225","title":{"rendered":"Google Maps API\u306bGeoJSON\u3092\u7de8\u96c6\u3059\u308b\u6a5f\u80fd\u304c\u4ed8\u3044\u305f\u306e\u3067\u3001\u30b5\u30af\u30c3\u3068GeoJSON\u30a8\u30c7\u30a3\u30bf\u4f5c\u3063\u3066\u307f\u305f\u3002"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/04\/gmap_geojsoneditor2.jpg\" alt=\"Graphically Edit a Data Layer\" width=\"452\" height=\"422\" class=\"aligncenter size-full wp-image-4227\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/04\/gmap_geojsoneditor2.jpg 452w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/04\/gmap_geojsoneditor2-161x150.jpg 161w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/p>\n<p>\u4ee5\u524d\u3001<a href=\"https:\/\/gunmagisgeek.com\/blog\/google-map-api\/3445\">Google Map\u4e0a\u306bGeoJSON\u3092\u8868\u793a\u3059\u308b<\/a>\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u30fc\u306b\u3064\u3044\u3066\u304a\u4f1d\u3048\u3057\u307e\u3057\u305f\u304c\u3001\u65b0\u305f\u306b\u7de8\u96c6\u6a5f\u80fd\u304c\u642d\u8f09\u3055\u308c\u305f\u305d\u3046\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/googlegeodevelopers.blogspot.jp\/2015\/04\/interactive-data-layers-in-javascript.html\">Google Geo Developers Blog: Interactive Data Layers in the JavaScript Maps API<\/a><\/p>\n<p>\u3068\u3066\u3082\u7c21\u5358\u306b\u4f7f\u3048\u308b\u306e\u3067\u3001\u5730\u56f3\u306b\u7de8\u96c6\u6a5f\u80fd\u3092\u4ed8\u3051\u305f\u3044\u65b9\u306b\u304a\u52e7\u3081\u3067\u3059\u3002<\/p>\n<p>\u203b \u305f\u3060\u3057\u3001\u65e5\u672c\u56fd\u5185\u306eGoogle\u5730\u56f3\u3092\u30c8\u30ec\u30fc\u30b9\u3057\u3066GeoJSON\u3092\u4f5c\u308b\u3068\u3001\u305f\u3076\u3093\u8457\u4f5c\u6a29\u7684\u306b\u554f\u984c\u306b\u306a\u308b\u306e\u3067\u3084\u3081\u305f\u65b9\u304c\u3044\u3044\u304b\u3082\u3002<\/p>\n<h2>GeoJSON\u30a8\u30c7\u30a3\u30c3\u30c8\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc<\/h2>\n<p>\u30a8\u30c7\u30a3\u30c3\u30c8\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092Google Map\u306b\u8ffd\u52a0\u3059\u308b\u306e\u306f\uff12\u884c\u3067\u6e08\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >var map = new google.maps.Map(document.getElementById('map-canvas'), {\n    center: { lat: 36.322356, lng: 139.013057 },\n    zoom: 5\n});\n\nmap.data.setStyle({draggable: true, editable: true}); \/\/\u30c9\u30e9\u30c3\u30b0\u3068\u30a8\u30c7\u30a3\u30c3\u30c8\u3092\u6709\u52b9\u306b\u3059\u308b\nmap.data.setControls(['Point', 'LineString', 'Polygon']); \/\/\u30a8\u30c7\u30a3\u30c3\u30c8\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u8868\u793a<\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u5730\u56f3\u4e0a\u90e8\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/04\/gmap_geojsoneditor.jpg\" alt=\"GeoJSON\u3000\u30a8\u30c7\u30a3\u30c3\u30c8\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\" width=\"118\" height=\"34\" class=\"alignnone size-full wp-image-4226 border\" \/><\/p>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u5730\u56f3\u4e0a\u306b\u30de\u30fc\u30ab\u30fc\u3092\u8a2d\u7f6e\u3057\u305f\u308a\u3001\u30e9\u30a4\u30f3\u3084\u30dd\u30ea\u30b4\u30f3\u3092\u63cf\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u63cf\u3044\u305f\u30c7\u30fc\u30bf\u306ftoGeoJson\u30e1\u30bd\u30c3\u30c9\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \" >map.data.toGeoJson(function(geojson){\n    console.log(geojson);\n})<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u3068\u3066\u3082\u7c21\u5358\u306b\u7de8\u96c6\u6a5f\u80fd\u3092\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>GeoJSON\u30a8\u30c7\u30a3\u30bf\u4f5c\u3063\u3066\u307f\u305f\u3002<\/h2>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u30b5\u30af\u30c3\u3068\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002UI\u90e8\u5206\u306fWebix\u3092\u4f7f\u3063\u3066\u307e\u3059\u304c\u3001\u7d0450\u884c(js)\u7a0b\u3067\u30b7\u30f3\u30d7\u30eb\u306aGeoJSON\u30a8\u30c7\u30a3\u30bf\u304c\u51fa\u6765\u304d\u307e\u3057\u305f\u3002<br \/>\n<a href=\"http:\/\/shimz.me\/example\/gmapv3\/geojsonControls\/\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/04\/gmap_geojsoneditor3.jpg\" alt=\"GeoJSON \u30a8\u30c7\u30a3\u30bf\u30fc\" width=\"690\" height=\"396\" class=\"aligncenter size-full wp-image-4228 border\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/04\/gmap_geojsoneditor3.jpg 690w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2015\/04\/gmap_geojsoneditor3-261x150.jpg 261w\" sizes=\"auto, (max-width: 690px) 100vw, 690px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/shimz.me\/example\/gmapv3\/geojsonControls\/\">example<\/a><\/p>\n<pre class=\"lang:js decode:true \" >(function(){\n    \"use strict\";\n    \n    \/\/\u30a8\u30c7\u30a3\u30bf\u30fc\u90e8\u5206\u306e\u30ec\u30a4\u30a2\u30a6\u30c8\u6307\u5b9a       \n    var editor = {cols:[\n        { id:\"textarea_view\",view:\"textarea\", width:300, css:\"bg\"}  ,\n        {view:\"resizer\"},\n        {id:\"map_view\",template:'<div id=\"map-canvas\"><\/div>', }\n    ]}\n    \n    \/\/Webix\u30ec\u30a4\u30a2\u30a6\u30c8\n    webix.ui({\n        rows:[\n            {template:'<h1>Simple GeoJSON Editor<h1>', height:40, css:\"bg\"},\n            editor,\n            {template:'by <a href=\"https:\/\/gunmagisgeek.com\/blog\/\">@_shimizu<\/a>', height:20, css:\"bg\"}\n        ]\n    }).show();\n    \n    \/\/view\u306e\u30b5\u30a4\u30ba\u304c\u5909\u308f\u3063\u305f\u3089Gmap\u306b\u30ea\u30b5\u30a4\u30ba\u30a4\u30d9\u30f3\u30c8\u3092\u9001\u308b\n    var resized = function(){\n        google.maps.event.trigger(map, 'resize');   \n    }\n    $$(\"map_view\").attachEvent(\"onViewResize\", resized);\n    \n    \/\/Google Map\u521d\u671f\u5316\n    var map = new google.maps.Map(document.getElementById('map-canvas'), {\n        center: { lat: 36.322356, lng: 139.013057 },\n        zoom: 5\n    });\n    \n    \/\/\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u30fc\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\n    var dataLayer = map.data;\n    \n    \/\/\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u30fc\u306e\u30c9\u30e9\u30c3\u30b0\u3068\u30a8\u30c7\u30a3\u30c3\u30c8\u3092\u8a31\u53ef\n    dataLayer.setStyle({draggable: true, editable: true});\n    \/\/\u30a8\u30c7\u30a3\u30c3\u30c8\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u8868\u793a\n    dataLayer.setControls(['Point', 'LineString', 'Polygon']);  \n    \n    \/\/GeoJSON\u3092\u51fa\u529b\n    var bindOutputGeoJSON = function(dataLayer){\n        return function(){\n            dataLayer.toGeoJson(function(geojson){\n                $$('textarea_view').setValue(JSON.stringify(geojson, null, \"t\"));\n            })\n        };  \n    }\n    var outputGeoJSON = bindOutputGeoJSON(dataLayer);\n    \n    \/\/data\u30ec\u30a4\u30e4\u30fc\u306b\u8ffd\u52a0\u30fb\u7de8\u96c6\u30fb\u524a\u9664\u304c\u884c\u308f\u308c\u305f\u3089\u30c6\u30ad\u30b9\u30c8\u30a8\u30ea\u30a2\u306bGeoJSON\u3092\u51fa\u529b\u3059\u308b\n    dataLayer.addListener('addfeature', outputGeoJSON);\n    dataLayer.addListener('removefeature', outputGeoJSON);\n    dataLayer.addListener('setgeometry', outputGeoJSON);\n})();<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u524d\u3001Google Map\u4e0a\u306bGeoJSON\u3092\u8868\u793a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":4227,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,58],"tags":[],"class_list":["post-4225","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-map-api","category-webix","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4225","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=4225"}],"version-history":[{"count":1,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4225\/revisions"}],"predecessor-version":[{"id":5425,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/4225\/revisions\/5425"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/4227"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=4225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=4225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=4225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}