{"id":9724,"date":"2021-11-29T07:00:28","date_gmt":"2021-11-28T22:00:28","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=9724"},"modified":"2021-11-16T18:29:53","modified_gmt":"2021-11-16T09:29:53","slug":"laravel-leaflet-%e5%9c%b0%e5%9b%b3%e3%81%a7%e9%a7%85%e5%90%8d%e6%a4%9c%e7%b4%a2%e3%81%a7%e3%81%8d%e3%82%8b%e3%82%88%e3%81%86%e3%81%ab%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=9724","title":{"rendered":"Laravel + Leaflet \u5730\u56f3\u3067\u99c5\u540d\u691c\u7d22\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u9593\u300c<strong>\u591c\u666f\u30de\u30c3\u30d7\u3092\u4f5c\u3063\u3066\u307f\u308b<\/strong>\u300d\u3067<code>leaflet.js<\/code>\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u3053\u308c\u3059\u3054\u304f\u4fbf\u5229\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u6a5f\u80fd\u3067\u306f\u304b\u306a\u308f\u306a\u3044\u3067\u3059\u304c Google\u30de\u30c3\u30d7\u306f\u6709\u6599\u5316\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u300c<strong>\u3061\u3087\u3063\u3068\u3057\u305f\u5730\u56f3<\/strong>\u300d\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3001\u5341\u5206\u3059\u304e\u308b\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u524d\u56de\u4f7f\u3063\u3066\u307f\u305f\u3068\u304d\u306b\u4e00\u70b9\u3042\u308b\u4e0d\u6e80\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u308c\u304c\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\u691c\u7d22\u304c\u3067\u304d\u306a\u3044<\/strong><\/p>\n<p>\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u5927\u962a\u99c5\u5468\u8fba\u306e\u5730\u56f3\u304c\u307f\u305f\u3044<\/strong>\u300d\u3068\u601d\u3063\u3066\u3082\u3001\u4eca\u3044\u308b\u5834\u6240\u304c\u5927\u962a\u3058\u3083\u306a\u3044\u5834\u5408GPS\u30c7\u30fc\u30bf\u3092\u4f7f\u3048\u308b\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001<\/p>\n<p><strong>\uff11\uff0e\u5730\u56f3\u3092\u63b4\u3093\u3067\u3001\uff12\uff0e\u6ed1\u3089\u305b\u308b<\/strong><\/p>\n<p>\u3092\u5ef6\u3005\u3068\u3084\u3089\u306a\u3044\u3068\u3044\u3051\u306a\u304f\u306a\u308a\u307e\u3059\u3002\uff08\u30ba\u30fc\u30e0\u3092\u5909\u3048\u308b\u306b\u3057\u3066\u3082\u3053\u306e\u4f5c\u696d\u3001\u9762\u5012\u3067\u3059\u3088\u306d\uff09<\/p>\n<p>\u305d\u3053\u3067\u2757<\/p>\n<p>\u4eca\u56de\u306f\u3001\u3053\u306e\u6b20\u70b9\u3092<code>leaflet<\/code>\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u300c<strong>leaflet-search<\/strong>\u300d\u3092\u4f7f\u3063\u3066\u5b9f\u88c5\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u3064\u304f\u308a\u305f\u3044\u306e\u306f\u3001\u300c<strong>\u99c5\u540d\u3067\u691c\u7d22\u3057\u3066\u3001\u81ea\u52d5\u3067\u305d\u306e\u4f4d\u7f6e\u3078\u79fb\u52d5\u3059\u308b<\/strong>\u300d\u6a5f\u80fd\u3067\u3059\u3002<br \/>\n\u305c\u3072\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002\ud83d\ude04\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3405 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png\" alt=\"\" width=\"310\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18.png 310w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_18-291x300.png 291w\" sizes=\"auto, (max-width: 310px) 100vw, 310px\" \/>\u300cGPS\u3092\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u3067\u53d6\u5f97\u3067\u304d\u308c\u3070\u3001<br \/>\nPusher\u3068\u304b\u3068\u9023\u643a\u3057\u3066\u3001<br \/>\n\u300e\u898b\u5b88\u308a\u6a5f\u80fd\u300f\u3082\u3064\u304f\u308c\u305d\u3046\u3067\u3059\u306d\ud83d\udc4d\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 8.x\u3001leaflet 1.7\u3001leaflet-search 3<\/p>\n<h1>\u51e6\u7406\u306e\u6d41\u308c<\/h1>\n<p>\u99c5\u540d\u691c\u7d22\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306e\u51e6\u7406\u306f\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>\u5730\u56f3\u4e0a\u306b\u3042\u308b\u691c\u7d22\u30dc\u30c3\u30af\u30b9\u306b\u99c5\u540d\u3092\u5165\u529b<\/li>\n<li>Ajax \u3067\u305d\u306e\u99c5\u540d\u3092\u9001\u4fe1<\/li>\n<li>\u9001\u4fe1\u5148\u3067\u8a72\u5f53\u3059\u308b\u30c7\u30fc\u30bf\u3092\u691c\u7d22\u3059\u308b<\/li>\n<li>\u691c\u7d22\u30dc\u30c3\u30af\u30b9\u306e\u4e0b\u306b\u5019\u88dc\u3092\u8868\u793a<\/li>\n<li>\u9078\u629e\u3059\u308b\u3068\u305d\u306e\u99c5\u306e\u4f4d\u7f6e\u3078\u79fb\u52d5<\/li>\n<\/ol>\n<p>\u3067\u306f\u5b9f\u969b\u306b\u4f5c\u696d\u3092\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u2757<\/p>\n<h1>\u99c5\u306e\u4f4d\u7f6e\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3059\u308b<\/h1>\n<p>\u3067\u306f\u3001\u307e\u305a\u306f<code>Ajax<\/code>\u3092\u901a\u3057\u3066\u53d6\u5f97\u3059\u308b\u99c5\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u306a\u3093\u3068\u3042\u308a\u304c\u305f\u3044\u3053\u3068\u306b\u3001<a href=\"https:\/\/ekidata.jp\/\">\u99c5\u30c7\u30fc\u30bf.jp<\/a> \u3068\u3044\u3046\u30b5\u30a4\u30c8\u3055\u3093\u304c\u7121\u6599\uff06\u5546\u7528OK\u306a\u30c7\u30fc\u30bf\u3092\u516c\u958b\u3057\u3066\u304f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306b\u306f\u4f1a\u54e1\u767b\u9332\u304c\u5fc5\u8981\u306a\u306e\u3067\u4ee5\u4e0b\u306eURL\u304b\u3089\u767b\u9332\u3059\u307e\u305b\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd \u65b0\u898f\u767b\u9332\u30da\u30fc\u30b8<\/strong>\uff1a<a href=\"https:\/\/ekidata.jp\/dl\/\">\u99c5\u30c7\u30fc\u30bf.jp\uff1a\u65b0\u898f\u767b\u9332<\/a><\/p>\n<p>\u4f1a\u54e1\u767b\u9332\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001<a href=\"https:\/\/ekidata.jp\/dl\/\" target=\"_blank\" rel=\"noopener\">\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30da\u30fc\u30b8<\/a> \u304b\u3089\u30ed\u30b0\u30a4\u30f3\u3057\u307e\u3059\u3002<br \/>\n\u3059\u308b\u3068\u3001\u30da\u30fc\u30b8\u5de6\u5074\u306e\u30e1\u30cb\u30e5\u30fc\u304c\u3042\u308b\u306e\u3067\u3001\u305d\u306e\u4e2d\u306e\u300c<strong>\u30c7\u30fc\u30bf\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/strong>\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9725\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_1.png\" alt=\"\" width=\"251\" height=\"258\" \/><\/p>\n<p>\u30da\u30fc\u30b8\u304c\u79fb\u52d5\u3059\u308b\u306e\u3067\u3001\u300c<strong>\u99c5\u30c7\u30fc\u30bf<\/strong>\u300d\u306e\u6700\u65b0\u30c7\u30fc\u30bf\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5f62\u5f0f\u306f<code>CSV<\/code>\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9726\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_2.png\" alt=\"\" width=\"452\" height=\"491\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_2.png 452w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_2-276x300.png 276w\" sizes=\"auto, (max-width: 452px) 100vw, 452px\" \/><\/p>\n<p>\u305d\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u305f\u3089<code>storage\/app\/csv<\/code>\u30d5\u30a9\u30eb\u30c0\u306b\u79fb\u52d5\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9727\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_4.png\" alt=\"\" width=\"548\" height=\"215\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_4.png 548w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_4-300x118.png 300w\" sizes=\"auto, (max-width: 548px) 100vw, 548px\" \/><\/p>\n<p>\u3053\u308c\u3067\u30c7\u30fc\u30bf\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306f\u5b8c\u4e86\u3067\u3059\u3002<\/p>\n<h1>\u99c5\u30c7\u30fc\u30bf\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u79fb\u3059<\/h1>\n<p>\u3055\u3059\u304c\u306b<code>CSV<\/code>\u306e\u307e\u307e\u3067\u306f\u691c\u7d22\u306a\u3069\u306b\u5229\u7528\u3057\u306b\u304f\u3044\u306e\u3067\u3001\u5185\u5bb9\u3092\u5168\u3066DB\u3078\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:model Station -msc<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u300c<strong>\u30e2\u30c7\u30eb<\/strong>\u300d\u3060\u3051\u3067\u306a\u304f\u300c<strong>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3<\/strong>\u300d\u3068\u300c<strong>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc<\/strong>\u300d\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u5909\u66f4\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a<\/h2>\n<p>\u307e\u305a\u306f\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3067\u3059\u3002<\/p>\n<p><strong>database\/migrations\/****_**_**_******_create_stations_table.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565\r\n\r\npublic function up()\r\n{\r\n    Schema::create('stations', function (Blueprint $table) {\r\n        $table-&gt;id();\r\n        <strong>$table-&gt;string('name')-&gt;comment('\u99c5\u540d');<\/strong>\r\n<strong>        $table-&gt;double('latitude', 9, 6)-&gt;comment('\u7def\u5ea6');<\/strong>\r\n<strong>        $table-&gt;double('longitude', 9, 6)-&gt;comment('\u7d4c\u5ea6');<\/strong>\r\n        $table-&gt;timestamps();\r\n    });\r\n}<\/pre>\n<p>\u203b \u4eca\u56de\u306f\u5fc5\u8981\u6700\u4f4e\u9650\u306e\u30ab\u30e9\u30e0\u3060\u3051\u7528\u610f\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u304a\u597d\u307f\u3067\u8ffd\u52a0\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>Seeder\u306e\u8a2d\u5b9a<\/h2>\n<p>\u7d9a\u3044\u3066<code>Seeder<\/code>\u3067DB\u518d\u69cb\u7bc9\u3059\u308b\u969b\u306b\u3001\u5148\u307b\u3069\u306e<code>CSV<\/code>\u304b\u3089\u30c7\u30fc\u30bf\u304c\u79fb\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>database\/seeders\/StationSeeder.php<\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace Database\\Seeders;\r\n\r\n<strong>use App\\Models\\Station;<\/strong>\r\nuse Illuminate\\Database\\Seeder;\r\n\r\nclass StationSeeder extends Seeder\r\n{\r\n    \/**\r\n     * Run the database seeds.\r\n     *\r\n     * @return void\r\n     *\/\r\n    <strong>public function run()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $csv_path = storage_path('app\/csv\/station20210312free.csv'); \/\/ \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u30d1\u30b9<\/strong>\r\n<strong>        $file = new \\SplFileObject($csv_path);<\/strong>\r\n<strong>        $file-&gt;setFlags(\\SplFileObject::READ_CSV);<\/strong>\r\n\r\n<strong>        foreach ($file as $index =&gt; $row) {<\/strong>\r\n\r\n<strong>            if($index &gt; 0 &amp;&amp; !is_null($row[0])) {<\/strong>\r\n\r\n<strong>                $station_name = $row[2];<\/strong>\r\n<strong>                $longitude = floatval($row[9]);<\/strong>\r\n<strong>                $latitude = floatval($row[10]);<\/strong>\r\n\r\n<strong>                $station = new Station();<\/strong>\r\n<strong>                $station-&gt;name = $station_name;<\/strong>\r\n<strong>                $station-&gt;longitude = $longitude;<\/strong>\r\n<strong>                $station-&gt;latitude = $latitude;<\/strong>\r\n<strong>                $station-&gt;save();<\/strong>\r\n\r\n<strong>            }<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u6b21\u306b\u3001<code>Seeder<\/code>\u306f\u3064\u304f\u3063\u305f\u3060\u3051\u3067\u306f\u6709\u52b9\u306b\u306a\u3089\u306a\u3044\u306e\u3067\u3001<code>Laravel<\/code>\u5074\u3078\u767b\u9332\u3057\u307e\u3059\u3002<\/p>\n<p><strong>database\/seeders\/DatabaseSeeder.php<\/strong><\/p>\n<pre>public function run()\r\n{\r\n    \/\/ \u7701\u7565\r\n\r\n    <strong>$this-&gt;call(StationSeeder::class);<\/strong>\r\n}<\/pre>\n<p>\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u518d\u69cb\u7bc9\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u26a0\u3054\u6ce8\u610f\uff1a<\/strong> \u306a\u304a\u300110,000\u4ef6\u4ee5\u4e0a\u306e\u99c5\u30c7\u30fc\u30bf\u304c\u3042\u308b\u306e\u3067\u5c11\u3057\u6642\u9593\u304c\u304b\u304b\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<pre><strong>php artisan migrate:fresh --seed<\/strong><\/pre>\n<p>\u518d\u69cb\u7bc9\u304c\u5b8c\u4e86\u3059\u308b\u3068\u3001\u30c6\u30fc\u30d6\u30eb\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9728\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_5.png\" alt=\"\" width=\"450\" height=\"370\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_5.png 450w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/10\/leaflet_with_search_5-300x247.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/p>\n<h2>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u8a2d\u5b9a<\/h2>\n<p>\u305d\u3057\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306b\u3001\u300c<strong>\u30de\u30c3\u30d7\u306e\u8868\u793a<\/strong>\u300d\u3068\u300c<strong>Ajax\u3067\u99c5\u540d\u691c\u7d22\u3059\u308b<\/strong>\u300d\u6a5f\u80fd\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<p><strong>app\/Http\/Controllers\/StationController.php<\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse App\\Models\\Station;\r\nuse Illuminate\\Http\\Request;\r\n\r\nclass StationController extends Controller\r\n{\r\n    <strong>public function index() {<\/strong>\r\n\r\n<strong>        return view('station.index');<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function list(Request $request)<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        if($request-&gt;filled('keyword')) {<\/strong>\r\n\r\n<strong>            return Station::where('name', 'LIKE', '%'. $request-&gt;keyword .'%')<\/strong>\r\n<strong>                -&gt;take(5)<\/strong>\r\n<strong>                -&gt;get()<\/strong>\r\n<strong>                -&gt;map(function($station){ \/\/ leaflet-search \u7528\u306b\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3059\u308b<\/strong>\r\n\r\n<strong>                    return [<\/strong>\r\n<strong>                        'loc' =&gt; [<\/strong>\r\n<strong>                            $station-&gt;latitude,<\/strong>\r\n<strong>                            $station-&gt;longitude<\/strong>\r\n<strong>                        ],<\/strong>\r\n<strong>                        'title' =&gt; $station-&gt;name<\/strong>\r\n<strong>                    ];<\/strong>\r\n\r\n<strong>                });<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        return [];<\/strong>\r\n<strong>    }<\/strong>\r\n}<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u306f\u3001\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u3042\u308b\u3068\u304d\u306f\u99c5\u540d\u3067\u691c\u7d22\u3057\u3001\u3055\u3089\u306b\u53d6\u5f97\u3067\u304d\u305f\u30c7\u30fc\u30bf\u3092\u3053\u306e\u5f8c\u3067\u767b\u5834\u3059\u308b\u30d7\u30e9\u30b0\u30a4\u30f3\u300c<strong>leaflet-search<\/strong>\u300d\u306b\u5408\u308f\u305b\u3066\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u7d9a\u3044\u3066\u306f\u3001\u30eb\u30fc\u30c8\u3067\u3059\u3002<\/p>\n<pre>use App\\Http\\Controllers\\StationController;\r\n\r\n\/\/ \u7701\u7565\r\n\r\nRoute::get('station', [StationController::class, 'index'])-&gt;name('station.index');\r\nRoute::get('station\/list', [StationController::class, 'list'])-&gt;name('station.list');<\/pre>\n<h1>\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u6700\u5f8c\u306b\u3001\u5148\u307b\u3069\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u6307\u5b9a\u3057\u305f\u30d3\u30e5\u30fc\u3092\u3064\u304f\u308a\u307e\u3059\u3002<\/p>\n<p><strong>resources\/views\/station\/index.blade.php<\/strong><\/p>\n<pre>&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;link href=\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.0.1\/dist\/css\/bootstrap.min.css\" rel=\"stylesheet\"&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"https:\/\/unpkg.com\/leaflet@1.7.1\/dist\/leaflet.css\"&gt;\r\n    &lt;link rel=\"stylesheet\" href=\"https:\/\/cdn.jsdelivr.net\/npm\/leaflet-search@3.0.2\/dist\/leaflet-search.min.css\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=\"app\" class=\"p-4\"&gt;\r\n    &lt;h1&gt;Leaflet \u306b\u99c5\u540d\u691c\u7d22\u3092\u3064\u304f\u308b\u30b5\u30f3\u30d7\u30eb&lt;\/h1&gt;\r\n    &lt;div id=\"my-map\" style=\"height:500px;\"&gt;&lt;\/div&gt;\r\n&lt;\/div&gt;\r\n&lt;script src=\"https:\/\/unpkg.com\/leaflet@1.7.1\/dist\/leaflet.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/leaflet-search@3.0.2\/dist\/leaflet-search.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n\r\n    window.addEventListener('load', () =&gt; {\r\n\r\n        const tileLayerUrl = 'https:\/\/cyberjapandata.gsi.go.jp\/xyz\/pale\/{z}\/{x}\/{y}.png';\r\n        const attribution = '&lt;a href=\"https:\/\/www.gsi.go.jp\/kikakuchousei\/kikakuchousei40182.html\" target=\"_blank\" rel=\"noopener\"&gt;\u56fd\u571f\u5730\u7406\u9662&lt;\/a&gt;';\r\n\r\n        <strong>const map = L.map('my-map').setView([35.71006814475588, 139.81069905886525], 15); \/\/ \u30b9\u30bf\u30fc\u30c8\u306f\u6771\u4eac\u30b9\u30ab\u30a4\u30c4\u30ea\u30fc<\/strong>\r\n<strong>        L.tileLayer(tileLayerUrl, { attribution: attribution }).addTo(map);<\/strong>\r\n<strong>        L.control.search({<\/strong>\r\n<strong>            url: '{{ route('station.list') }}?keyword={s}',<\/strong>\r\n<strong>            position: 'topright',<\/strong>\r\n<strong>            textErr: '\u5019\u88dc\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f',<\/strong>\r\n<strong>            textPlaceholder: '\u99c5\u540d\u3067\u691c\u7d22...',<\/strong>\r\n<strong>            textCancel: '\u30ad\u30e3\u30f3\u30bb\u30eb'<\/strong>\r\n<strong>        }).addTo(map);<\/strong>\r\n\r\n    });\r\n\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u306f\u3001\u30d7\u30e9\u30b0\u30a4\u30f3\u300c<strong><a href=\"https:\/\/github.com\/stefanocudini\/leaflet-search\" target=\"_blank\" rel=\"noopener\">leaflet-search<\/a><\/strong>\u300d\u3092\u4f7f\u3063\u3066\u3044\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u306e<code>url<\/code>\u306b\u5148\u307b\u3069\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3067\u4f5c\u3063\u305f<code>list()<\/code>\u3078\u306eURL\u3092\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u3053\u3053\u306e<code>{s}<\/code>\u306e\u90e8\u5206\u304c\u691c\u7d22\u30dc\u30c3\u30af\u30b9\u306b\u5165\u529b\u3055\u308c\u305f\u30c6\u30ad\u30b9\u30c8\u3068\u7f6e\u304d\u63db\u308f\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u5b9f\u969b\u306e<code>URL<\/code>\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>URL\u4f8b\uff1a<\/strong><\/p>\n<pre><strong>http:\/\/******\/station\/list?keyword=\uff08URL\u30a8\u30f3\u30b3\u30fc\u30c9\u3055\u308c\u305f\u30c6\u30ad\u30b9\u30c8\uff09<\/strong><\/pre>\n<p>\u3053\u308c\u3067\u4f5c\u696d\u3092\u7d42\u4e86\u3067\u3059\u3002<br \/>\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\u2728\ud83d\ude04\ud83d\udc4d<\/p>\n<h1>\u3061\u306a\u307f\u306b\uff1a Vue 3\u3068\u306e\u9023\u643a\u306f\u30fb\u30fb\u30fb<\/h1>\n<p>\u79c1\u306f\u30d3\u30eb\u30c9\u306a\u3057\u3067\u4f7f\u3048\u308b<code>Vue<\/code>\u304c\u597d\u304d\u306a\u306e\u3067\u3059\u304c\u3001<code>Vue 3<\/code> + <code>leaflet<\/code>\u3092\u4f7f\u3046\u3068\u30ba\u30fc\u30e0\u6642\u306b\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001Vue 3\u306f<code>data()<\/code>\u5185\u306b\u5165\u3063\u305f\u5024\u3092<code>Proxy<\/code>\u5316\u3059\u308b\u306e\u3067\u3001\u3069\u3046\u3084\u3089\u305d\u308c\u304c\u5f71\u97ff\u3059\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u3082\u3057\u4f7f\u3046\u306a\u3089\u300c<strong>Vue\u5916\u306b\u3042\u308b\u5909\u6570<\/strong>\u300d<code>map<\/code>\u306b<code>leaflet<\/code>\u306e<code>map<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30bb\u30c3\u30c8\u3057\u3066\u4f7f\u3046\u3088\u3046\u306b\u3059\u308b\u3068\u3044\u3044\u3088\u3046\u3067\u3059\u3002\uff08\u305f\u3060\u3057\u3001\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306a\u3069\u591a\u91cd\u3067\u547c\u3073\u51fa\u3059\u5834\u5408\u306f\u3046\u307e\u304f\u3044\u304d\u307e\u305b\u3093\u306e\u3067\u3001\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\uff09<\/p>\n<p>\u203b \u306a\u304a\u3001<code>markRaw<\/code>\u3092\u4f7f\u3063\u3066\u300c\u305d\u306e\u307e\u307e\u300d\u6307\u5b9a\u3092\u3057\u3066\u3082\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<code>Vue 2<\/code>\u306a\u3089\u554f\u984c\u306a\u304f\u52d5\u304f\u306e\u3067\u3059\u304c\u30fb\u30fb\u30fb\u3084\u306f\u308a\u300c\u30b7\u30f3\u30d7\u30eb\u306a\u306e\u306b\u9ad8\u6a5f\u80fd\u300d\u3067\u3059\u3057\u3001<code>Vue 2<\/code>\u306e\u65b9\u304c\u4f7f\u3044\u52dd\u624b\u3044\u3044\u304b\u3082\u3067\u3059\u306d\u3002\ud83d\ude02<\/p>\n<h1>\u30c7\u30e2\u3092\u7528\u610f\u3057\u307e\u3057\u305f<\/h1>\n<p>\u3067\u306f\u5b9f\u969b\u306e\u30c6\u30b9\u30c8\u3067\u3059\u304c\u3001\u89e6\u3063\u3066\u3082\u3089\u3063\u305f\u65b9\u304c\u65e9\u3044\u3068\u601d\u3046\u306e\u3067\u30c7\u30e2\u30da\u30fc\u30b8\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u203b \u305f\u3060\u3057\u3001\u3042\u307e\u308a\u306b\u3082\u5168\u99c5\u30c7\u30fc\u30bf\u3067\u306f\u591a\u3059\u304e\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u99c5\u3060\u3051\u3057\u304b\u691c\u7d22\u3067\u304d\u307e\u305b\u3093\u306e\u3067\u3054\u6ce8\u610f\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li><strong>\u6771\u4eac<\/strong><\/li>\n<li><strong>\u6e0b\u8c37<\/strong><\/li>\n<li><strong>\u539f\u5bbf<\/strong><\/li>\n<li><strong>\u65b0\u5bbf<\/strong><\/li>\n<li><strong>\u65b0\u6a4b<\/strong><\/li>\n<\/ul>\n<p>\u305c\u3072\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\ud83d\udcdd \u30c7\u30e2\u30da\u30fc\u30b8\uff1a<\/strong> <a href=\"https:\/\/demo-laravel8x.capilano-fw.com\/station\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089<\/a><\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u73fe\u5728\u3001Google\u30de\u30c3\u30d7\u306e\u5229\u7528\u306f\u6709\u6599\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u300c<strong>Google\u30de\u30c3\u30d7\u307b\u3069\u9ad8\u6a5f\u80fd\u3067\u306a\u304f\u3066\u3082\u3044\u3044<\/strong>\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u3057\u305f\u3089\u3001\u4eca\u56de\u306e\u300c<strong>\u691c\u7d22\u6a5f\u80fd\u4ed8\u304d\u306e\u30de\u30c3\u30d7<\/strong>\u300d\u3067<strong>\u30e9\u30f3\u30cb\u30f3\u30b0\u30fb\u30b3\u30b9\u30c8\u3092\u30ab\u30c3\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/strong>\uff08\u5b8c\u5168\u7121\u6599\u3067\u4f7f\u3048\u307e\u3059\uff09<\/p>\n<p>\u307e\u305f\u3001\u4eca\u56de\u306f\u99c5\u30c7\u30fc\u30bf\u3092\u4f7f\u3044\u307e\u3057\u305f\u304c\u3001\u7def\u5ea6\u7d4c\u5ea6\u30c7\u30fc\u30bf\u3055\u3048\u3042\u308c\u3070\u3001<strong>\u652f\u793e\u3001\u652f\u5e97\u3001\u55b6\u696d\u6240\u540d\u3001\u307e\u305f\u306f\u914d\u9001\u5148\u3084\u304a\u5ba2\u69d8\u306e\u81ea\u5b85\u306e\u691c\u7d22\u3082\u53ef\u80fd<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u305c\u3072\u3053\u3046\u3044\u3063\u305f\u6a5f\u80fd\u3092\u3054\u5e0c\u671b\u3067\u3057\u305f\u3089\u3001\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u3088\u308a\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002<br \/>\n\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002m(_ _)m<\/p>\n<p>\u203b \u306a\u304a\u3001\u4eca\u56de\u306e\u99c5\u30c7\u30fc\u30bf\u3082\u542b\u3081\u307e\u3057\u3066\u7def\u5ea6\u30fb\u7d4c\u5ea6\u30c7\u30fc\u30bf\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u30fb\u30da\u30fc\u30b8\u3092\u307e\u3068\u3081\u307e\u3057\u305f\u3002\u305c\u3072\u3053\u3061\u3089\u3082\u3054\u53c2\u8003\u306b\u306a\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/ekidata.jp\/\" target=\"_blank\" rel=\"noopener\">\u99c5\u30c7\u30fc\u30bf.jp<\/a><\/li>\n<li><a href=\"https:\/\/geolonia.github.io\/japanese-addresses\/\" target=\"_blank\" rel=\"noopener\">Geolonia \u4f4f\u6240\u30c7\u30fc\u30bf<\/a><\/li>\n<li><a href=\"https:\/\/amano-tec.com\/data\/index.html\" target=\"_blank\" rel=\"noopener\">\u30a2\u30de\u30ce\u6280\u7814\u30fb\u5730\u7406\u7a7a\u9593\u30c7\u30fc\u30bf\u4e00\u89a7<\/a><\/li>\n<\/ul>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u4eca\u56de\u306f<code>Laravel<\/code> + <code>Leaflet<\/code>+<code>leaflet-search<\/code>\u3067\u300c<strong>\u99c5\u540d\u691c\u7d22\u3067\u304d\u308b\u30de\u30c3\u30d7<\/strong>\u300d\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u500b\u4eba\u7684\u306b\u306f\u3001\u99c5\u30c7\u30fc\u30bf\u3060\u3051\u3067\u306a\u304f\u3044\u308d\u3093\u306a\u300c<strong>\u73cd\u30b9\u30dd\u30c3\u30c8<\/strong>\u300dand\u300c<strong>B\u7d1a\u30b9\u30dd\u30c3\u30c8<\/strong>\u300d\u306e\u7def\u5ea6\u7d4c\u5ea6\u30c7\u30fc\u30bf\u304c\u307b\u3057\u3044\u3068\u3053\u308d\u306a\u306e\u3067\u3001\u307e\u305f\u8abf\u67fb\u3057\u3066\u307f\u3088\u3046\u3068\u8003\u3048\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305c\u3072\u7686\u3055\u3093\u3082\u9762\u767d\u305d\u3046\u306a\u4f7f\u3044\u65b9\u3092\u8003\u3048\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9439 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/07\/no_30.png\" alt=\"\" width=\"224\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/07\/no_30.png 224w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/07\/no_30-210x300.png 210w\" sizes=\"auto, (max-width: 224px) 100vw, 224px\" \/>\u300c\u3088\u3057\u3001\u6b21\u306f\u3053\u3053\u3078\u884c\u3053\u3046\u2757\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u3053\u306e\u9593\u300c\u591c\u666f\u30de\u30c3\u30d7\u3092\u4f5c\u3063\u3066\u307f\u308b\u300d\u3067leaflet.js\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u3053\u308c\u3059\u3054\u304f\u4fbf\u5229\u3067\u3059\u3088\u306d\u3002 \u3082\u3061\u308d\u3093\u6a5f\u80fd\u3067\u306f\u304b\u306a\u308f\u306a\u3044\u3067\u3059\u304c Google\u30de\u30c3 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=9724\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Laravel + Leaflet \u5730\u56f3\u3067\u99c5\u540d\u691c\u7d22\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":9732,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[20],"class_list":["post-9724","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","tag-20"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9724"}],"version-history":[{"count":10,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9724\/revisions"}],"predecessor-version":[{"id":9740,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9724\/revisions\/9740"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/9732"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}