【发布时间】:2020-01-29 09:39:21
【问题描述】:
我正在尝试通过 Blix 移动模板在我的网站联系页面上运行 Google 地图 API,但我相信由于联系页面加载在主页上或由于根本不会调用具有 MAP API 源的自定义脚本。 我知道我想运行的代码没有问题,但是我的脚本最终没有在我的模板中被调用,而且我不知道该尝试什么,因为我是一个初学者。
您可以找到here 网站本身。我遇到的问题是联系页面。
#map{
height: 80%;
width: 80%;
}
html,body{
height: 100%;
margin: 0;
padding:0;
}
<div id="map">
<script>
console.log("test 1");
var map;
function initMap() {
map = new google.maps.Map(
document.getElementById('map'),
{center: new google.maps.LatLng(40, 20), zoom: 16});
console.log("test 2");
var iconBase =
'https://developers.google.com/maps/documentation/javascript/examples/full/images/';
console.log("test 3");
var icons = {
info: {
icon: iconBase + 'info-i_maps.png'
}
};
console.log("test 4");
var features = [
{
position: new google.maps.LatLng(40, 20),
type: 'info'
}
];
console.log("test 5");
// Create markers.
for (var i = 0; i < features.length; i++) {
var marker = new google.maps.Marker({
position: features[i].position,
icon: icons[features[i].type].icon,
map: map
});
};
console.log("test 6");
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCg9sodxDOjqPW1H5Xkmqu1ed1TPDVt1E0&callback=initMap"></script>
【问题讨论】:
标签: javascript html css google-apps