|
@@ -28,7 +28,12 @@ export default {
|
|
|
map:null,
|
|
|
lngLat:[106.628201,26.646694],
|
|
|
zoom:9,
|
|
|
- adcode:'0851',
|
|
|
+ adcode:'520000',
|
|
|
+ mapLevel:'province',
|
|
|
+ province:'',
|
|
|
+ cityList:[],//市
|
|
|
+ districtList:[],//区县
|
|
|
+ streetList:[],//街道,乡
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -57,9 +62,13 @@ export default {
|
|
|
layers: [new AMap.TileLayer.Satellite(), new AMap.TileLayer.RoadNet()],
|
|
|
// mapStyle: 'amap://styles/db9efe6a1745ac24b7269b862f359536'
|
|
|
});
|
|
|
- this.$nextTick(()=>{
|
|
|
- this.getMap(AMap);
|
|
|
- })
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.getMap(AMap);
|
|
|
+ })
|
|
|
+ // this.map.on('complete', () => {
|
|
|
+ // console.log('map complete');
|
|
|
+ // this.getMap(AMap);
|
|
|
+ // })
|
|
|
}).catch(e=>{
|
|
|
console.log(e);
|
|
|
})
|
|
@@ -68,19 +77,29 @@ export default {
|
|
|
let that = this;
|
|
|
// console.log('AMap',AMap);
|
|
|
AMap.plugin(['AMap.DistrictSearch'], function () {
|
|
|
- console.log('1111');
|
|
|
+ // console.log('1111');
|
|
|
// 创建行政区查询对象
|
|
|
var district = new AMap.DistrictSearch({
|
|
|
// 返回行政区边界坐标等具体信息
|
|
|
extensions: 'all',
|
|
|
// 设置查询行政区级别为 区 (district)
|
|
|
- level: 'province',
|
|
|
+ level: that.mapLevel,
|
|
|
// 显示下级行政区级数,1表示返回下一级行政区
|
|
|
subdistrict: 1
|
|
|
})
|
|
|
|
|
|
district.search(that.adcode, function(status, result) {
|
|
|
- // console.log('result',result);
|
|
|
+ console.log('result',result);
|
|
|
+ let districtList = result.districtList[0].districtList;
|
|
|
+ switch (that.mapLevel) {
|
|
|
+ case 'province':
|
|
|
+ console.log('province districtList',districtList);
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
// console.log('result.districtList',result.districtList);
|
|
|
if(!result.districtList){
|
|
|
return
|
|
@@ -103,34 +122,31 @@ export default {
|
|
|
// console.log('polygon',polygon);
|
|
|
polygons.push(polygon)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- // //object3Dlayer可以看做一个容器,用来放多个3d对象
|
|
|
- // let object3Dlayer = new AMap.Object3DLayer();
|
|
|
- // //把object3Dlayer添加到map对象中
|
|
|
- // that.map.add(object3Dlayer);
|
|
|
- // var wall = new AMap.Object3D.Wall({
|
|
|
- // //版块边界线
|
|
|
- // path: bounds,
|
|
|
- // //墙的高度
|
|
|
- // height: 80000,
|
|
|
- // //墙的颜色
|
|
|
- // color: "#0dcdd1",
|
|
|
- // });
|
|
|
- // //wall 有两个面,该属性表示哪个面可见,可选值:back ,front ,both表示两面 默认为front
|
|
|
- // wall.backOrFront = 'both';
|
|
|
- // // 是否允许使用透明颜色
|
|
|
- // wall.transparent = true;
|
|
|
- // //将wall放到object3Dlayer中
|
|
|
- // object3Dlayer.add(wall);
|
|
|
- // console.log('object3Dlayer');
|
|
|
|
|
|
-
|
|
|
// 地图自适应
|
|
|
that.map.setFitView()
|
|
|
- console.log('AMap.Object3DLayer',AMap.Object3DLayer);
|
|
|
+ // console.log('AMap.Object3DLayer',AMap.Object3DLayer);
|
|
|
AMap.plugin(['AMap.Object3DLayer','AMap.Object3D'], function () {
|
|
|
- console.log('2222');
|
|
|
+ // console.log('2222');
|
|
|
+ //object3Dlayer可以看做一个容器,用来放多个3d对象
|
|
|
+ let object3Dlayer = new AMap.Object3DLayer();
|
|
|
+ //把object3Dlayer添加到map对象中
|
|
|
+ that.map.add(object3Dlayer);
|
|
|
+ var wall = new AMap.Object3D.Wall({
|
|
|
+ //版块边界线
|
|
|
+ path: bounds,
|
|
|
+ //墙的高度
|
|
|
+ height: 80000,
|
|
|
+ //墙的颜色
|
|
|
+ color: "#0dcdd1",
|
|
|
+ });
|
|
|
+ //wall 有两个面,该属性表示哪个面可见,可选值:back ,front ,both表示两面 默认为front
|
|
|
+ wall.backOrFront = 'both';
|
|
|
+ // 是否允许使用透明颜色
|
|
|
+ wall.transparent = true;
|
|
|
+ //将wall放到object3Dlayer中
|
|
|
+ object3Dlayer.add(wall);
|
|
|
+ console.log('object3Dlayer');
|
|
|
})
|
|
|
|
|
|
}
|