【发布时间】:2017-11-27 18:14:47
【问题描述】:
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: new google.maps.LatLng(18.511325, 73.820176),
mapTypeId: 'roadmap'
});
var iconBase = '';
var icons = {
info: {
icon: iconBase + 'map.png'
}
};
var features = [
{
position: new google.maps.LatLng(18.511325, 73.820176),
type: 'info'
}
];
// Create markers.
features.forEach(function(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
map: map
});
});
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDeuMlx32V1fYT3wRAa1wEjjtQuAI6wATM&callback=initMap">
</script>
<div class="container-fluid">
<div class="row">
<div id="map" style="width: 100%; height:100%"></div>
</div>
</div>
你好,我在我的网站中使用谷歌地图。我想添加我的 logo.png 而不是谷歌标记。我已经从谷歌页面生成了密钥并将其添加到脚本标签中。我已经按照谷歌页面上给出的所有步骤为它编写了下面的代码。但是当我使用下面的代码时,它什么也没显示。我想设计与图片相同的布局。
【问题讨论】:
-
你的控制台的输出是什么意思? Maps API 只能用于通过 HTTPS 提供的页面。
-
你的js在哪里?如果我将它放在 html 中的
-
在同一页面中
-
我也把代码放在了脚本标签中
-
高度为 0 像素
标签: javascript jquery twitter-bootstrap css google-maps-markers