Google Mapでマーカー付きの地図を表示する際に試した方法です
1.「地名」で指定する場合
https://maps.google.co.jp/maps?q=東京駅
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinkeJIU-vgAVGwtnD6NNN89YWmliaIGtUGaPO2KqLJjUz8JtEYc5fyrTunx21Xlesn1kjb-CAjY6DFAVdb9NXJxCz6_l3X64lNUG5P0Pr4fmPRAlEwXzxTnFhtGvRK-c3gbCkUJ080Nqs/s400/download-1.png)
2.「緯度・経度」で指定する場合
https://www.google.co.jp/maps/place/35.68123620000001, 139.7671248
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-ACyT37e4wVT1qvPFMF83yQGbOGftxEJPOWhFM4CFuA77E4Jywdih7es3QbYQggBJ6t_9p-GlAU2SUOitLanZTaBZdkBoxvDPmN4PN0zkCI7TOu2UOHccYCggXZBQSuvBHxvYeDBIcXM/s400/download-2.png)
「地名」を渡して地図のURLをログに出す
コード.gs
function createMaker() { var place = "東京駅"; var marker = "https://maps.google.co.jp/maps?q=" + place; Logger.log(marker); } |
「緯度・経度」を渡して地図のURLをログに出す
コード2.gsfunction getMarker() { var geocode = Maps.newGeocoder() .setLanguage("ja") .geocode("東京駅"); var geo = geocode.results[0]; var addresstext = geo.formatted_address; var geodata = geo.geometry; var latitude = geodata.location.lat; var longitude = geodata.location.lng; var data = { "address": addresstext, "latitude": latitude, "longitude": longitude } var base_url = 'https://www.google.co.jp/maps/place/'; var url = base_url + latitude + ", " + longitude; Logger.log(url); } |