{"id":5116,"date":"2016-08-05T21:05:07","date_gmt":"2016-08-05T12:05:07","guid":{"rendered":"https:\/\/gunmagisgeek.com\/wordpress\/?p=5116"},"modified":"2018-09-18T16:04:54","modified_gmt":"2018-09-18T07:04:54","slug":"post-5116","status":"publish","type":"post","link":"https:\/\/gunmagisgeek.com\/blog\/google-map-api\/5116","title":{"rendered":"\u300c\u30dd\u30b1\u30e2\u30f3GO\u307f\u305f\u3044\u306a\u30b2\u30fc\u30e0\u4f5c\u3063\u3066\u301c\u300d\u3068\u8a00\u308f\u308c\u305f\u3068\u304d\u306e\u305f\u3081\u306b\u3001\u5de8\u4eba(Google)\u306e\u529b\u3092\u304b\u308a\u3066\u3001\u9053\u8def\u4e0a\u306b\u30e9\u30f3\u30c0\u30e0\u306b\u30de\u30fc\u30ab\u30fc\u3092\u8a2d\u7f6e\u3059\u308b\u3002"},"content":{"rendered":"<p><a href=\"https:\/\/shimz.me\/example\/turf\/random\/index.html\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-55.png\" alt=\"\u9053\u8def\u4e0a\u306e\u30de\u30fc\u30ab\u30fc\" width=\"590\" height=\"326\" class=\"aligncenter size-full wp-image-5120\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-55.png 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-55-271x150.png 271w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/a><\/p>\n<p>\u305d\u308d\u305d\u308d\u3001\u4e16\u9593\u3067\u306f\u300c\u30dd\u30b1\u30e2\u30f3GO\u307f\u305f\u3044\u306e\u4f5c\u3063\u3066\u30fc\u4f5c\u3063\u3066\u30fc\u300d\u3068\u3044\u3046\u7121\u8336\u632f\u308a\u3068\u3001\u305d\u308c\u306b\u4f34\u3046\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u60b2\u9cf4\u304c\u805e\u3053\u3048\u3066\u304f\u308b\u5b63\u7bc0\u304c\u8fd1\u3065\u3044\u3066\u304d\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u305d\u3053\u3067\u3001\u3044\u3064\u305d\u3093\u306a\u7121\u8336\u632f\u308a\u304c\u6765\u3066\u3082\u5bfe\u5fdc\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u4f4d\u7f6e\u60c5\u5831\u3092\u7528\u3044\u305f\u30b2\u30fc\u30e0\u3092\u4f5c\u308b\u969b\u306e\u9ad8\u3044\u30cf\u30fc\u30c9\u30eb\u300c\u4eba\u304c\u884c\u3051\u308b\u5834\u6240\u306b\u30e2\u30f3\u30b9\u30bf\u30fc\u3092\u914d\u7f6e\u3059\u308b\u300d\u3068\u3044\u3046\u96e3\u554f\u3092\u30b0\u30fc\u30b0\u30eb\u69d8\u306e\u304a\u529b\u3092\u5229\u7528\u3057\u3066\u3001\u3068\u308a\u3042\u3048\u305a\u5f62\u3060\u3051\u3067\u3082\u306a\u3093\u3068\u304b\u53d6\u308a\u7e55\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e00\u5fdc\u8a00\u3063\u3066\u304a\u304d\u307e\u3059\u3068\u2026\u2026\u3042\u3093\u307e\u308a\u3001\u5b9f\u7528\u7684\u3067\u306f\u306a\u3044\u3067\u3059\u3088\u3002<\/p>\n<h3>\u30e9\u30f3\u30c0\u30e0\u306b\u7def\u5ea6\u7d4c\u5ea6\u3092\u751f\u6210\u3059\u308b<\/h3>\n<p>\u307e\u305a\u3001\u624b\u59cb\u3081\u306b\u65e5\u672c\u304c\u53ce\u307e\u308b\u7bc4\u56f2\u306b\u9650\u5b9a\u3057\u3066\u30e9\u30f3\u30c0\u30e0\u306b1000\u4ef6\u306e\u7def\u5ea6\u7d4c\u5ea6\u3092\u751f\u6210\u3057\u307e\u3059\u3002<br \/>\nturf.js\u3092\u4f7f\u7528\u3059\u308b\u3068\u30e9\u30f3\u30c0\u30e0\u306a\u30dd\u30a4\u30f3\u30c8\u30c7\u30fc\u30bf\u3092geojson\u3068\u3057\u3066\u7c21\u5358\u306b\u751f\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \">var points = turf.random('points', 1000, {\n    bbox:[117.195432271875, 25.96808355647172,160.877072896875,46.460689156557244]\n})<\/pre>\n<p>\u751f\u6210\u3057\u305fgeojson\u3092\u30de\u30fc\u30ab\u30fc\u3068\u3057\u3066\u5730\u56f3\u4e0a\u306b\u8868\u793a\u3057\u305f\u306e\u304c\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-16-53-03.png\" alt=\"\u30e9\u30f3\u30c0\u30e0\u306b\u751f\u6210\u3055\u308c\u305f1000\u4ef6\u306e\u30de\u30fc\u30ab\u30fc\" width=\"590\" height=\"326\" class=\"alignnone size-full wp-image-5117\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-16-53-03.png 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-16-53-03-271x150.png 271w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<p>\u30e9\u30f3\u30c0\u30e0\u306b\u751f\u6210\u3055\u308c\u3066\u306f\u3044\u307e\u3059\u304c\u3001\u6d77\u306e\u4e0a\u306a\u3069\u4e0d\u8981\u306a\u5834\u6240\u306b\u5927\u91cf\u306b\u30de\u30fc\u30ab\u30fc\u304c\u914d\u7f6e\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u6b21\u306e\u30d5\u30a7\u30fc\u30ba\u3067\u306f\u3001\u65e5\u672c\u5217\u5cf6\u4ee5\u5916\u306b\u914d\u7f6e\u3055\u308c\u305f\u4e0d\u8981\u306a\u30de\u30fc\u30ab\u30fc\u3092\u9664\u53bb\u3057\u307e\u3059\u3002<\/p>\n<h3>\u65e5\u672c\u5217\u5cf6\u4e0a\u306e\u4f4d\u7f6e\u60c5\u5831\u306e\u307f\u6b8b\u3057\u3066\u307b\u304b\u3092\u6d88\u3059<\/h3>\n<p>\u4e0d\u8981\u306a\u7def\u5ea6\u7d4c\u5ea6\u30c7\u30fc\u30bf\u3092\u305d\u304e\u843d\u3068\u3057\u3001 \u65e5\u672c\u5217\u5cf6\u4e0a\u306b\u53ce\u307e\u308b\u30c7\u30fc\u30bf\u3060\u3051\u3092\u53d6\u308a\u51fa\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\nturf.js\u306b\u306f\u3001\u30dd\u30a4\u30f3\u30c8\u30c7\u30fc\u30bf\u304c\u7279\u5b9a\u306e\u30dd\u30ea\u30b4\u30f3\u5185\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u5224\u5225\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308b\u306e\u3067\u3001\u5927\u307e\u304b\u306a\u65e5\u672c\u5217\u5cf6\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u3092\u30dd\u30ea\u30b4\u30f3\u3068\u3057\u3066\u751f\u6210\u3057\u3001\u305d\u306e\u30dd\u30ea\u30b4\u30f3\u5185\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u3092\u6761\u4ef6\u3068\u3057\u3066\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<p>\u30fb\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u30dd\u30ea\u30b4\u30f3<br \/>\n<a href=\"https:\/\/gist.github.com\/shimizu\/627b37e303efaf4045f637322e9898ee\">\u65e5\u672c\u5217\u5cf6\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3 | Github Gist <\/a><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/japan_outline-2016-08-05-20-38-44.png\" alt=\"japan_outline 2016-08-05 20-38-44\" width=\"590\" height=\"330\" class=\"alignnone size-full wp-image-5121\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/japan_outline-2016-08-05-20-38-44.png 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/japan_outline-2016-08-05-20-38-44-268x150.png 268w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<p>\u4e0a\u8a18\u3001geojson\u3092\u8aad\u307f\u8fbc\u307f\u5148\u307b\u3069\u751f\u6210\u3057\u305f\u30de\u30fc\u30ab\u30fc\u7fa4\u3068\u306e\u30de\u30c3\u30c1\u30f3\u30b0\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \">var insidePoints = {type: \"FeatureCollection\", features: []}\npoints.features.forEach(function(d){\n    if (turf.inside(d, geojson.features[0])) insidePoints.features.push(d)\n})\n<\/pre>\n<p>\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u5f8c\u306e\u7def\u5ea6\u7d4c\u5ea6\u3092\u5730\u56f3\u4e0a\u306b\u30de\u30fc\u30ab\u30fc\u3068\u3057\u3066\u8868\u793a\u3059\u308b\u3068\u4ee5\u4e0b\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-16-56-26.png\" alt=\"\u65e5\u672c\u5217\u5cf6\u4e0a\u306e\u307f\u306b\u7d5e\u308a\u8fbc\u3093\u3060\u30de\u30fc\u30ab\u30fc\" width=\"590\" height=\"327\" class=\"alignnone size-full wp-image-5118\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-16-56-26.png 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-16-56-26-271x150.png 271w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<h3>\u9053\u8def\u4e0a\u306e\u7def\u5ea6\u7d4c\u5ea6\u306e\u307f\u3092\u9078\u3076<\/h3>\n<p>\u3055\u3066\u3001\u3053\u3053\u304b\u3089\u304c\u672c\u756a\u3067\u3059\u3002<br \/>\n\u6d77\u4e0a\u306b\u914d\u7f6e\u3055\u308c\u3066\u3044\u305f\u30de\u30fc\u30ab\u30fc\u306f\u7dba\u9e97\u3055\u3063\u3071\u308a\u6d88\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u304c\u3001\u4eca\u306e\u307e\u307e\u3067\u306f\u3001\u5c71\u306e\u4e0a\u3060\u3063\u305f\u308a\u5ddd\u306e\u4e2d\u3060\u3063\u305f\u308a\u3068\u3001\u4eba\u306e\u884c\u3051\u306a\u3044\u3088\u3046\u306a\u5834\u6240\u306b\u3082\u305f\u304f\u3055\u3093\u306e\u30de\u30fc\u30ab\u30fc\u304c\u8a2d\u7f6e\u3055\u308c\u3066\u3057\u307e\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u306e\u4e2d\u304b\u3089\u3001\u9053\u8def\u4e0a\u306b\u914d\u7f6e\u3055\u308c\u305f\u30de\u30fc\u30ab\u30fc\u306e\u307f\u3092\u6b8b\u3059\u3001\u3042\u308b\u3044\u306f\u8fd1\u304f\u306e\u9053\u8def\u307e\u3067\u30de\u30fc\u30ab\u30fc\u3092\u79fb\u52d5\u3059\u308b\u306b\u306f\u3069\u3046\u3057\u305f\u3089\u3088\u3044\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>\u306a\u304b\u306a\u304b\u306e\u96e3\u554f\u3067\u3059\u304c\u3001Google\u69d8\u306e\u529b\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067\u4e00\u90e8\u89e3\u6c7a\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u30ad\u30fc\u3068\u306a\u308b\u306e\u306f\u300c\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fcAPI\u300d<\/p>\n<p>\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u3092\u8868\u793a\u3059\u308b\u4ee5\u5916\u306b\u3082\u3001\u975e\u5e38\u306b\u4fbf\u5229\u306a\u6a5f\u80fd\u304c\u8a70\u307e\u3063\u305f\u3053\u306eAPI\u3092\u4f7f\u3063\u3066\u3001\u30e9\u30f3\u30c0\u30e0\u306b\u751f\u6210\u3055\u308c\u305f\u7def\u5ea6\u7d4c\u5ea6\u304b\u3089\u9053\u8def\u4e0a\u306e\u7def\u5ea6\u7d4c\u5ea6\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>StreetViewService\u30af\u30e9\u30b9\u304c\u6301\u3064\u3001getPanoramaByLocation\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u7279\u5b9a\u306e\u7def\u5ea6\u7d4c\u5ea6\u304b\u3089\u6307\u5b9a\u3057\u305f\u534a\u5f84\uff08\u4e0b\u8a18\u3067\u306f100m\uff09\u4ee5\u5185\u306b\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u306b\u5bfe\u5fdc\u3057\u305f\u30dd\u30a4\u30f3\u30c8\u304c\u306a\u3044\u304b\u3092\u691c\u7d22\u3057\u3001\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308c\u3070\u305d\u306e\u7def\u5ea6\u7d4c\u5ea6\u3092\u8fd4\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306b\u3001\u6b8b\u308a\u306e\u7def\u5ea6\u7d4c\u5ea6\u30c7\u30fc\u30bf\u3092\u5168\u3066\u7a81\u3063\u8fbc\u3093\u3067\u3001\u624b\u5f53\u305f\u308a\u3057\u3060\u3044\u306b\u691c\u7d22\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6295\u3052\u307e\u3059\u3002<br \/>\ngetPanoramaByLocation\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u306b\u542b\u307e\u308c\u308b\u7def\u5ea6\u7d4c\u5ea6\u306f\u3001\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u306b\u5bfe\u5fdc\u3057\u305f\u300c\u4eba\u304c\u8a2a\u308c\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u5834\u6240\u300d\u3068\u3057\u3066\u5225\u9014\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \">var streetViewService = new google.maps.StreetViewService();\n\nfunction searchStreetViewPoint(coordinates, callback){\n    var latlng = new google.maps.LatLng(coordinates[1], coordinates[0]);\n    var reslut\n    \n    setTimeout(function(){\n        streetViewService.getPanoramaByLocation(latlng, 100, function(status){\n            if(status){\n                reslut =  [status.location.latLng.lng() , status.location.latLng.lat()]\n            }else{\n                reslut =  false \n            }            \n            callback(reslut)\n        })\n    }, 100)\n}<\/pre>\n<p>\u3061\u306a\u307f\u306b\u3001getPanoramaByLocation\u30e1\u30bd\u30c3\u30c9\u306f\u975e\u540c\u671f\u51e6\u7406\u306b\u306a\u308b\u306e\u3067\u3001\u30d7\u30ed\u30df\u30b9\u3067\u5305\u3093\u3067\u6700\u5f8c\u306b\u307e\u3068\u3081\u3066\u53d6\u5f97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \">var PromiseArray = []\n\/\/\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u3078\u306e\u554f\u3044\u5408\u308f\u305b\u3092\u30d7\u30ed\u30df\u30b9\u3067\u5305\u3080\nvar pGen = (function(d){\n    return new Promise(function(resolve, reject){\n        var coordinates = d.geometry.coordinates\n        var latlng = new google.maps.LatLng(coordinates[1], coordinates[0])\n        streetViewService.getPanoramaByLocation(latlng, 100, function(status){\n            if(status){\n                reslut =  [status.location.latLng.lng() , status.location.latLng.lat()]\n            }else{\n                reslut =  false \n            }               \n            resolve(reslut)\n        })          \n    })\n})\n    \n    \n\/\/\u30dd\u30a4\u30f3\u30c8\u5206\u306e\u554f\u3044\u5408\u308f\u305b\u3092\u914d\u5217\u306b\u4fdd\u5b58\ninsidePoints.features.forEach(function(d){\n    PromiseArray.push(pGen(d))\n})\n\n\n\/\/\u307e\u3068\u3081\u3066\u554f\u3044\u5408\u308f\u305b\nPromise.all(PromiseArray).then(function(data){\n    var filtertedPoint = {type: \"FeatureCollection\", features: []}\n\n    data.filter(function(d){ return d })\n        .forEach(function(d){\n            filtertedPoint.features.push({\n                \"type\": \"Feature\",\n                \"properties\": {},\n                \"geometry\": {\n                    \"type\": \"Point\",\n                    \"coordinates\": d\n                }\n            })\n        \n        })\n        \n    var onEachFeature = function(feature, layer) {\n        layer.on('click', function (e) {\n            map.setView(e.latlng, 16);\n        })      \n    }\n        \n        \n    L.geoJson(filtertedPoint, {onEachFeature: onEachFeature}).addTo(map)\n})<\/pre>\n<p>\u4e0a\u8a18\u306e\u65b9\u6cd5\u3067\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\u3057\u305f\u7def\u5ea6\u7d4c\u5ea6\u3092\u5730\u56f3\u4e0a\u306b\u8868\u793a\u3057\u305f\u306e\u304c\u4ee5\u4e0b\u3002\u3060\u3044\u3076\u6570\u304c\u6e1b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u304c\u3001\u8868\u793a\u3055\u308c\u3066\u3044\u308b\u30de\u30fc\u30ab\u30fc\u306f\u3001\u3059\u3079\u3066\u4eba\u304c\u884c\u3051\u308b\u5834\u6240(\u307b\u3068\u3093\u3069\u304c\u9053\u8def\u4e0a)\u306b\u914d\u7f6e\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-13.png\" alt=\"\u9053\u8def\u4e0a\u306b\u30de\u30c3\u30d4\u30f3\u30b0\u3057\u305f\u30de\u30fc\u30ab\u30fc\" width=\"590\" height=\"328\" class=\"alignnone size-full wp-image-5119\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-13.png 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-13-270x150.png 270w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<p>\u30de\u30fc\u30ab\u30fc\u306b\u306f\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u305d\u306e\u4f4d\u7f6e\u3078\u30ba\u30fc\u30e0\u3059\u308b\u30a4\u30d9\u30f3\u30c8\u304c\u30d0\u30a4\u30f3\u30c9\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u6b63\u3057\u304f\u914d\u7f6e\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-55.png\" alt=\"\u9053\u8def\u4e0a\u306e\u30de\u30fc\u30ab\u30fc\" width=\"590\" height=\"326\" class=\"alignnone size-full wp-image-5120\" srcset=\"https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-55.png 590w, https:\/\/gunmagisgeek.com\/blog\/wp-content\/uploads\/2016\/08\/random-marker-2016-08-05-17-10-55-271x150.png 271w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/p>\n<h3>\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"height-set:true lang:js decode:true \">d3.json(\"japan_outline.geojson\", main)\n\nfunction main(geojson) {\n\n    var map = initMap()\n    var streetViewService = new google.maps.StreetViewService();\n    \n    var points = turf.random('points', 1000, {\n        bbox:[117.195432271875, 25.96808355647172,160.877072896875,46.460689156557244]\n    })\n    \n\n    var insidePoints = {type: \"FeatureCollection\", features: []}\n    points.features.forEach(function(d){\n        if (turf.inside(d, geojson.features[0])) insidePoints.features.push(d)\n    })\n\n    \n    var PromiseArray = []\n    \/\/\u30b9\u30c8\u30ea\u30fc\u30c8\u30d3\u30e5\u30fc\u3078\u306e\u554f\u3044\u5408\u308f\u305b\u3092\u30d7\u30ed\u30df\u30b9\u3067\u5305\u3080\n    var pGen = (function(d){\n        return new Promise(function(resolve, reject){\n            var coordinates = d.geometry.coordinates\n            var latlng = new google.maps.LatLng(coordinates[1], coordinates[0])\n            streetViewService.getPanoramaByLocation(latlng, 100, function(status){\n                if(status){\n                    reslut =  [status.location.latLng.lng() , status.location.latLng.lat()]\n                }else{\n                    reslut =  false \n                }               \n                resolve(reslut)\n            })          \n        })\n    })\n        \n        \n    \/\/\u30dd\u30a4\u30f3\u30c8\u5206\u306e\u554f\u3044\u5408\u308f\u305b\u3092\u914d\u5217\u306b\u4fdd\u5b58\n    insidePoints.features.forEach(function(d){\n        PromiseArray.push(pGen(d))\n    })\n    \n    \n    \/\/\u307e\u3068\u3081\u3066\u554f\u3044\u5408\u308f\u305b\n    Promise.all(PromiseArray).then(function(data){\n        var filtertedPoint = {type: \"FeatureCollection\", features: []}\n\n        data.filter(function(d){ return d })\n            .forEach(function(d){\n                filtertedPoint.features.push({\n                    \"type\": \"Feature\",\n                    \"properties\": {},\n                    \"geometry\": {\n                        \"type\": \"Point\",\n                        \"coordinates\": d\n                    }\n                })\n            \n            })\n            \n        var onEachFeature = function(feature, layer) {\n            layer.on('click', function (e) {\n                map.setView(e.latlng, 16);\n            })      \n        }\n            \n            \n        L.geoJson(filtertedPoint, {onEachFeature: onEachFeature}).addTo(map)\n    })\n\n    \/\/\u5730\u56f3\u521d\u671f\u5316 \n    function initMap(){\n    \n        var map = L.map('map').setView([36.322356, 139.013057], 4);\n        \n        var GmapsROA = new L.Google('ROADMAP'); \/\/\u5730\u56f3\n        var GmapsSAT = new L.Google('SATELLITE'); \/\/\u822a\u7a7a\u5199\u771f\n        var GmapsHYB = new L.Google('HYBRID');  \/\/\u822a\u7a7a\u5199\u771f&amp;\u30e9\u30d9\u30eb\n        var GmapsTER = new L.Google('TERRAIN'); \/\/\u5730\u5f62\u5730\u56f3\n        \n        map.addLayer(GmapsROA);\n        map.addControl(new L.Control.Layers({\n           'Google Roadmap':GmapsROA,\n           'Google Satellite':GmapsSAT,\n           'Google Hybrid':GmapsHYB,\n           'Google Terrain':GmapsTER\n        }, {}));\n        \n        return map\n        \n    }\n    \n\n\n\n    \n}<\/pre>\n<p>\u66f4\u65b0\u3055\u308c\u308b\u305f\u3073\u306b\u30e9\u30f3\u30c0\u30e0\u306b\u30de\u30fc\u30ab\u30fc\u3092\u8a2d\u7f6e\u3057\u307e\u3059\u3002<br \/>\nAPI\u306e\u5236\u9650\u6570\u3092\u8d8a\u3048\u308b\u3068\u8a2d\u7f6e\u3055\u308c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/shimz.me\/example\/turf\/random\/index.html\">example<\/a><\/p>\n<h3>\u307e\u3068\u3081<\/h3>\n<p>\u6700\u521d\u306b\u751f\u6210\u3059\u308b\u7def\u5ea6\u7d4c\u5ea6\u306e\u6570\u3092\u5897\u3084\u305b\u3070\u3001\u6700\u7d42\u7684\u306b\u53d6\u5f97\u3067\u304d\u308b\u6570\u3082\u5897\u3048\u308b\u308f\u3051\u3067\u3059\u304c\u3001\u305d\u306e\u5206Streetview\u3078\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3082\u5897\u3048\u308b\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4eca\u56de\u306fAPI\u306e\u7121\u6599\u5236\u9650(1\u65e52500\u30ea\u30af\u30a8\u30b9\u30c8)\u306e\u7bc4\u56f2\u3067\u53ce\u307e\u308b\u3088\u3046\u306b\u5c11\u306a\u3081\u306e\u6570\u3067\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u305d\u308d\u305d\u308d\u3001\u4e16\u9593\u3067\u306f\u300c\u30dd\u30b1\u30e2\u30f3GO\u307f\u305f\u3044\u306e\u4f5c\u3063\u3066\u30fc\u4f5c&hellip;<\/p>\n","protected":false},"author":1,"featured_media":5120,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,55,62],"tags":[],"class_list":["post-5116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-google-map-api","category-leaflet-js","category-turf-js","has-post-thumbnail-archive"],"_links":{"self":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/5116","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=5116"}],"version-history":[{"count":0,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/posts\/5116\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media\/5120"}],"wp:attachment":[{"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/media?parent=5116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/categories?post=5116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gunmagisgeek.com\/blog\/wp-json\/wp\/v2\/tags?post=5116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}