第一步:引入地图api js ,地图容器id,初始化
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.3&key=bca3c8db7e16261dadc9b149bb686e71"></script>
<div id="add-notice-container" name="container" tabIndex="0"/>
第二步:
// 获取省市列表信息及当前城市地区代码
export const getMapDate = (_this, id, num) => { // id: 地图容器,num:表示省市区列表即 1:省,2:市,3:区,4:街道
// let provinceList = [];
// let cityCode = null;
_this.setState({
mapObj: new window.AMap.Map(id)
}, () => {
// 获取省区列表
_this.state.mapObj.plugin('AMap.DistrictSearch', () => {
var districtSearch = new window.AMap.DistrictSearch({
level: 'country',