创建图形
//创建地图对象
this.map = new AMap.Map('map', {
center: [120.16,30.27],
resizeEnable: true,
zoom: 12,
})
//获取边界坐标点
AMap.plugin('AMap.DistrictSearch', () => {
var districtSearch = new AMap.DistrictSearch({
// 关键字对应的行政区级别,共有5种级别
level: 'province',
// 是否显示下级行政区级数,1表示返回下一级行政区
subdistrict: 0,
// 返回行政区边界坐标点
extensions: 'all',
})
// 搜索所有省/直辖市信息
districtSearch.search('杭州', (status, result) => {
// 查询成功时,result即为对应的行政区信息
this.drawPolygon(result)
})
})
绘制边界
drawPolygon(result) {
let bounds = result.districtList[0