Open tiancheng91 opened 1 year ago
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>英文、中英文地图</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<style>
html,
body,
#container {
width: 100%;
height: 100%;
}
.amap-icon img{
width: 25px;
height: 34px;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="https://cache.amap.com/lbs/static/es5.min.js"></script>
<script src="https://webapi.amap.com/maps?v=2.0&key=您申请的key值"></script>
<script>
var center = [121.498586,31.239637];
var home = [121.559826,31.117771];
var trafficLayer = new AMap.TileLayer.Traffic({});
// 家
var marker = new AMap.Marker({
icon: "//a.amap.com/pc/static/img/search_house.png",
position: home,
});
//初始化地图
var map = new AMap.Map('container', {
zoom: 11,
resizeEnable: true,
center: center,
viewMode: '3D',
pitch: 45,
mapStyle: "amap://styles/grey",
layers: [
AMap.createDefaultLayer(), //高德默认标准图层
trafficLayer
],
});
marker.setMap(map);
// 控件
AMap.plugin([
'AMap.ToolBar',
], function(){
map.addControl(new AMap.ToolBar());
});
</script>
</body>
</html>
用于替代homeassistant地图页, 带交通路况信息