iT邦幫忙

0

Google Map重整問題

  • 分享至 

  • xImage

我的前端有個地圖的小圖示,點了之後會連結後端資料庫抓取精緯度,會開啟新的頁面啟動地圖顯示座標,可是跳到新的頁面時,都要按f5重整後地圖才會跳出來
https://ithelp.ithome.com.tw/upload/images/20191220/20120965ZheUhJokA0.png
https://ithelp.ithome.com.tw/upload/images/20191220/20120965maVEnivF0d.png
https://ithelp.ithome.com.tw/upload/images/20191220/20120965p3o3lSrYRm.png
要按重新整理才會跳出地圖
https://ithelp.ithome.com.tw/upload/images/20191220/20120965KT7hNX8fJK.png

dragonH iT邦超人 5 級 ‧ 2019-12-20 15:51:37 檢舉
你是怎麼去 call initMap() 的
tina888 iT邦新手 5 級 ‧ 2019-12-20 16:42:57 檢舉
我是在<head>那裡寫callback :
<script async defer src="https://maps.googleapis.com/maps/api/js?key=我的API&callback=initMap"></script>
YC iT邦研究生 2 級 ‧ 2019-12-23 17:19:08 檢舉
把你的<script async defer src="https://maps.googleapis.com/maps/api/js?key=我的API&callback=initMap"></script>放到body看看
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
咖咖拉
iT邦好手 1 級 ‧ 2019-12-20 17:30:39

你的情況可能是跳頁時
JS 載入出現的錯誤

我一般都是用iframe

JS

const txt = "經,緯"
const map = document.querySelector('#map iframe');
map.src = 'https://www.google.com/maps/embed/v1/search?key=你的金鑰&q=1&zoom=14&center='+txt;

HTML

<section id="map" class="map">
<iframe frameborder="0" style="border:0" src="" allowfullscreen></iframe>
</section>

我要發表回答

立即登入回答