function myInit() { /* 北緯38.891度, 東経139.824度, ズームレベル16 で地図表示 */ var mymap = L.map("csvmap").setView([38.891, 139.824], 16); L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }).addTo(mymap); L.control.scale().addTo(mymap); fetch("experience.csv").then((resp) => { return resp.text(); // HTTPレスポンスから文字列を抜き出して返す }).then((csvlines) => { // それを csvlines として受け取る /* ここに csvlines を複数のCSV行として処理するものを書く */ var line, x, lon, lat, desc; for (line of csvlines.split("\n")) { x = line.split(","); lon = x[0], lat = x[1], place = [2]; L.marker([lat, lon]).bindPopup(place).addTo(mymap); } }); } document.addEventListener("DOMContentLoaded", myInit, false);