我試圖解決兩個問題。我可以單獨解決每個問題,但不能同時解決問題。設置谷歌地圖位置並擺脫框
我想 1.要對我的網站谷歌地圖是已加載頁面加載時,又名紅色箭頭的東西是有 2.在左上角擺脫灰色框的具體位置手角
獲取位置很容易。你只需使用一個iframe。我這樣做:
<div style="border-radius: 250px; width: 500px; overflow: hidden; margin-top: 90px; margin-bottom: 90px;">
<iframe id="map" width="500" height="500" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJm04kiUOHj4AR8NnaLQ2OCXw&key=MYAPIKEY" allowfullscreen></iframe>
</div>
但是,iframe的左上角有一個小框。我不想要那個,我需要它消失。
所以我嘗試使用Google Maps API。使用JavaScript,我可以像這樣刪除框:
<div id="map_container" >
<div id="map"></div>
</div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: {lat: -33, lng: 151},
disableDefaultUI: true
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&callback=initMap">
</script>
這工作正常,除非我似乎沒有相同的紅色箭頭設置。這是一個企業的網站,所以我不能只設置lat和lng。我需要直接在業務上的紅色箭頭。我似乎無法找到堆棧溢出這兩個問題的答案。幫幫我!
[添加Google Maps JavaScript API中的標記,看起來與添加到maps.google.com中的標記完全相同](https://stackoverflow.com/questions/42165971/add-marker-with-google- maps-javascript-api-look-exactly-as-marker-that-were-a) – geocodezip