高德地图在HTML中的调用DEMO
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>智慧超市</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<style type="text/css">
#container {
width: 100%;
height: 200px;
}
#window {
font-size: 16px;
font-weight: bold;
line-height: 1.5em;
background: #fff;
padding: 5px 15px;
}
</style>
</head>
<body>
<div id="container"></div>
</body>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=自己的key"></script>
<script>
window.onload = function(){
let map = new AMap.Map("container", {
resizeEnable: true,
center: [109.6593421700, 36.6783664100],
zoom: 18,
});
let infoWindow = new AMap.InfoWindow({
isCustom: true, //使用自定义窗体
content: '<div id="window">1345646578946</div>',
offset: new AMap.Pixel(110, 3)
});
addMarker();
//添加marker标记
function addMarker() {
map.clearMap();
let marker = new AMap.Marker({
map: map,
position: [109.658943, 36.678317]
});
//鼠标点击marker弹出自定义的信息窗体
AMap.event.addListener(marker, 'click', function () {
infoWindow.open(map, marker.getPosition());
});
function show(){
infoWindow.open(map, marker.getPosition());
}
show();
}
}
</script>
</html>