{"id":3445,"date":"2014-03-20T14:21:58","date_gmt":"2014-03-20T05:21:58","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=3445"},"modified":"2014-10-14T08:45:50","modified_gmt":"2014-10-13T23:45:50","slug":"post-3445","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/google-map-api\/3445","title":{"rendered":"Google Map\u4e0a\u306bGeoJSON\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3059\u308b"},"content":{"rendered":"<p><a href=\"http:\/\/jp.techcrunch.com\/2014\/03\/20\/20140319google-maps-makes-creating-maps-easier-for-developers-adds-geojson-support-to-its-javascript-api\/\">Google\u3001\u5730\u56f3\u30a2\u30d7\u30ea\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u5411\u3051JavaScript API\u3067GeoJSON\u3092\u30b5\u30dd\u30fc\u30c8<\/a><\/p>\n<p>Google Maps API\u3067<a href=\"http:\/\/ja.wikipedia.org\/wiki\/GeoJSON\">GeoJSON<\/a>\u30c7\u30fc\u30bf\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u305f\u3089\u3057\u3044\u306e\u3067\u3001\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002\uff08\u4e00\u90e8\u3001D3.js\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\uff09<\/p>\n<p>\u3010\u53c2\u8003\u3011<br \/>\n<a href=\"https:\/\/developers.google.com\/maps\/articles\/combining-data\">Combining and visualising multiple data sources &#8211; Google Maps API \u2014 Google Developers<\/a><\/p>\n<h2>\u30dd\u30a4\u30f3\u30c8\u30c7\u30fc\u30bf\u3092\u8868\u793a<\/h2>\n<p>\u30dd\u30a4\u30f3\u30c8(\u70b9)\u30c7\u30fc\u30bf\u306f\u3001\u30b9\u30bf\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068\u30de\u30fc\u30ab\u30fc\u3067\u8868\u793a\u3055\u308c\u308b\u3002<br \/>\n<a href=\"http:\/\/shimz.me\/example\/gmapv3\/geoJSON\/\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/a9037c7d0d0fc74c6ea57bcbccdec794.jpg\" alt=\"GMPSAPI geojson(\u30dd\u30a4\u30f3\u30c8)\u8aad\u307f\u8fbc\u307f\" width=\"590\" height=\"545\" class=\"alignnone size-full wp-image-3443\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/a9037c7d0d0fc74c6ea57bcbccdec794.jpg 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/a9037c7d0d0fc74c6ea57bcbccdec794-162x150.jpg 162w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/shimz.me\/example\/gmapv3\/geoJSON\/\">example<\/a><\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"lang:js decode:true \" >google.maps.event.addDomListener(window, 'load', function() {\r\n\t\r\n\t\/\/Google Maps\u521d\u671f\u5316\r\n\tvar map = new google.maps.Map(document.getElementById('map-canvas'), {\r\n\t\tcenter: { lat: 36.3894816, lng: 139.0634281 },\r\n\t\tzoom: 12\r\n\t});\r\n\r\n\t\/\/GeoJSON\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f\r\n\td3.json('aed.geojson', function(data) {\t\t\r\n\t\t\/\/\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u30fc\u306b\u8ffd\u52a0\r\n\t\tmap.data.addGeoJson(data);\r\n\t\t\/\/\u30a4\u30d9\u30f3\u30c8(\u30de\u30fc\u30ab\u30fc\u30af\u30ea\u30c3\u30af\u6642)\u3092\u8a2d\u5b9a\r\n\t\tmap.data.addListener('click', mouseClick);\r\n\t});\r\n\t\r\n\tfunction mouseClick(e) {\r\n\t\t\/\/features-&gt;properties\u306eaddress\u30c7\u30fc\u30bf\u3092\u30af\u30ea\u30c3\u30af\u6642\u306b\u8868\u793a\u3059\u308b\r\n\t\talert(e.feature.getProperty('address'));\t\r\n\t}\r\n   \r\n});<\/pre>\n<h2>\u30dd\u30a4\u30f3\u30c8\u30c7\u30fc\u30bf\u3092\u8868\u793a\uff12<\/h2>\n<p>\u30b9\u30bf\u30a4\u30eb\u6307\u5b9a\u3057\u3066\u307f\u305f\u3002<br \/>\n<a href=\"http:\/\/shimz.me\/example\/gmapv3\/geoJSON\/index3.html\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/googlemap_geojson201403203.jpg\" alt=\"GMPSAPI geojson(\u30dd\u30a4\u30f3\u30c8)\u8aad\u307f\u8fbc\u307f\" width=\"590\" height=\"540\" class=\"alignnone size-full wp-image-3446\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/googlemap_geojson201403203.jpg 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/googlemap_geojson201403203-164x150.jpg 164w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/shimz.me\/example\/gmapv3\/geoJSON\/index3.html\">example<\/a><\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb<\/h3>\n<pre class=\"lang:js decode:true \" >google.maps.event.addDomListener(window, 'load', function() {\r\n\t\r\n\t\/\/Google Maps\u521d\u671f\u5316\r\n\tvar map = new google.maps.Map(document.getElementById('map-canvas'), {\r\n\t\tcenter: { lat: 36.3894816, lng: 139.0634281 },\r\n\t\tzoom: 12\r\n\t});\r\n\r\n\t\r\n\t\/\/\u30de\u30fc\u30ab\u30fc\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u6307\u5b9a\r\n\tvar styleFeature = function(feature) {\r\n\t\treturn {\r\n\t\t\ticon: {\r\n\t\t\t\tpath: google.maps.SymbolPath.CIRCLE,\r\n\t\t\t\tscale:  ~~(Math.random() * 20), \/\/\u5186\u306e\u30b5\u30a4\u30ba(\u4eca\u56de\u306f\u30e9\u30f3\u30c0\u30e0\u306b\u8a2d\u5b9a)\r\n\t\t\t\tfillColor: '#f00',\r\n\t\t\t\tfillOpacity: 0.35,\r\n\t\t\t\tstrokeWeight: 0\r\n\t\t\t}\r\n\t\t};\r\n\t};\r\n\t\r\n\t\/\/GeoJSON\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f\r\n\td3.json('aed.geojson', function(data) {\t\t\r\n\t\t\/\/\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u30fc\u306b\u8ffd\u52a0\r\n\t\tmap.data.addGeoJson(data);\r\n\t\t\/\/\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u6307\u5b9a\r\n\t\tmap.data.setStyle(styleFeature);\r\n\t\t\/\/\u30a4\u30d9\u30f3\u30c8(\u30de\u30fc\u30ab\u30fc\u30af\u30ea\u30c3\u30af\u6642)\u3092\u8a2d\u5b9a\r\n\t\tmap.data.addListener('click', mouseClick);\r\n\t});\r\n\t\r\n\tfunction mouseClick(e) {\r\n\t\t\/\/features-&gt;properties\u306eaddress\u30c7\u30fc\u30bf\u3092\u30af\u30ea\u30c3\u30af\u6642\u306b\u8868\u793a\u3059\u308b\r\n\t\talert(e.feature.getProperty('address'));\t\r\n\t}\r\n   \r\n});<\/pre>\n<h2>\u30dd\u30ea\u30b4\u30f3\u30c7\u30fc\u30bf\u3092\u8868\u793a<\/h2>\n<p>\u90fd\u9053\u5e9c\u770c\u5883\u754c\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3057\u3001\u5404\u770c\u306e\u4eba\u53e3\u5bc6\u5ea6\u306b\u5408\u308f\u305b\u3066\u5857\u308a\u5206\u3051\u3092\u3057\u3066\u307f\u305f\u3002<br \/>\n<a href=\"http:\/\/shimz.me\/example\/gmapv3\/geoJSON\/index2.html\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/googlemap_geojson20140320.jpg\" alt=\"GMPSAPI geojson(\u30dd\u30ea\u30b4\u30f3)\u8aad\u307f\u8fbc\u307f\" width=\"590\" height=\"545\" class=\"alignnone size-full wp-image-3444\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/googlemap_geojson20140320.jpg 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2014\/03\/googlemap_geojson20140320-162x150.jpg 162w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/shimz.me\/example\/gmapv3\/geoJSON\/index2.html\">example<\/a><\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"lang:js decode:true \" >google.maps.event.addDomListener(window, 'load', function() {\r\n\t\/\/Google Maps API\u521d\u671f\u5316\r\n\tvar map = new google.maps.Map(document.getElementById('map-canvas'), {\r\n\t\tcenter: { lat: 36.322356, lng: 139.013057 },\r\n\t\tzoom: 5\r\n\t});\r\n\r\n\t\/\/\u30dd\u30ea\u30b4\u30f3\u30c7\u30fc\u30bf\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u6307\u5b9a\r\n\tvar styleFeature = function(max){\t\r\n\t\t\/\/\u30ab\u30e9\u30fc\u30b9\u30b1\u30fc\u30eb\u3092\u6307\u5b9a\r\n\t\tvar colorScale = d3.scale.linear().domain([0, max]).range([\"#CCFFCC\", \"red\"]);\r\n\t\treturn function(feature){\r\n\t\t\treturn {\r\n\t\t\t\tstrokeWeight: 2,\r\n\t\t\t\tstrokeColor: 'blue',\r\n\t\t\t\tzIndex: 4,\r\n\t\t\t\tfillColor: colorScale(+feature.getProperty('\u4eba\u53e3\u5bc6\u5ea6')),\u3000\/\/\u4eba\u53e3\u5bc6\u5ea6\u306b\u3088\u3063\u3066\u8272\u3092\u5857\u308a\u5206\u3051\u308b \r\n\t\t\t\tfillOpacity: 0.75,\r\n\t\t\t\tvisible: true\r\n\t\t\t};\t\t\r\n\t\t}\r\n\t\r\n\t}\r\n\t\r\n\t\/\/geojson\u30c7\u30fc\u30bf(\u30dd\u30ea\u30b4\u30f3)\u3092\u8aad\u307f\u8fbc\u307f\r\n\td3.json('japank.geojson', function(data) {\r\n\t\t\/\/\u5404\u770c\u306e\u4eba\u53e3\u5bc6\u5ea6\u304b\u3089\u6700\u5927\u5024\u3092\u53d6\u5f97\r\n\t\tvar max = d3.max(data.features, function(d){ return +d.properties['\u4eba\u53e3\u5bc6\u5ea6'] })\r\n\t\t\/\/\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u30fc\u306b\u8ffd\u52a0\r\n\t\tmap.data.addGeoJson(data);\r\n\t\t\/\/\u30c7\u30fc\u30bf\u30ec\u30a4\u30e4\u306e\u30b9\u30bf\u30a4\u30eb\u3092\u6307\u5b9a\r\n\t\tmap.data.setStyle(styleFeature(max));\r\n\t});\r\n   \r\n});<\/pre>\n<h2>\u95a2\u9023<\/h2>\n<p><a href=\"https:\/\/gunmagisgeek.com\/blog\/web\/3789\">GeoJSON\u3092\u4f7f\u3044\u3053\u306a\u3059\u305f\u3081\u306eWeb\u30b5\u30fc\u30d3\u30b9\u307e\u3068\u3081<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google\u3001\u5730\u56f3\u30a2\u30d7\u30ea\u306e\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u5411\u3051Java&hellip;<\/p>\n","protected":false},"author":1,"featured_media":3444,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-3445","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-map-api","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3445","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=3445"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/3445\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/3444"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=3445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=3445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=3445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}