console
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>to lww</title>
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<style>
.amap-traffic {
z-index: 111 !important;
}
</style>
</head>
<body>
<div id="container" class="container"></div>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=e692ff8624e7d5bb0beae36732ed2721"></script>
<script src="http://a.amap.com/Loca/static/mock/heatmapData.js"></script>
<script>
var map = new AMap.Map('container', {
mapStyle:"amap://styles/954b7e7e69b9361b21881ea934792e31",
resizeEnable: true,
center: [106.71, 26.57],
viewMode: '2D',
pitch: 50,
zoom: 6
});
map.on('mapload', function() {
map.getMap().plugin(['AMap.ControlBar'], function () {
var controlBar = new AMap.ControlBar();
map.getMap().addControl(controlBar);
});
});
AMap.plugin('AMap.DistrictSearch', () => {
var districtSearch = new AMap.DistrictSearch({
level: 'province',
subdistrict: 0,
extensions: 'all',
})
districtSearch.search('辽宁', (status, result) => {
handlePolygon(result)
})
handlePolygon= (result)=>{
let bounds = result.districtList[0].boundaries
if (bounds) {
for (let i = 0, l = bounds.length; i < l; i++) {
let polygon = new AMap.Polygon({
map: this.map,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.15,
fillColor: '#256edc',
strokeColor: '#256edc',
})
polygon.on('click', (e) => {
})
}
}
}
})
var trafficLayer = new AMap.TileLayer.Traffic({
zIndex: 15
});
trafficLayer.setMap(map);
</script>
</body>
</html>