|
@@ -13,6 +13,7 @@ export default {
|
|
|
AMap: null,
|
|
|
map: null,
|
|
|
lngLat: [106.628201, 26.646694],
|
|
|
+ adName: '',
|
|
|
zoom: 8,
|
|
|
adcode: '贵州省',
|
|
|
mapLevel: 'province',
|
|
@@ -23,6 +24,7 @@ export default {
|
|
|
currentAreaNode: null
|
|
|
};
|
|
|
},
|
|
|
+
|
|
|
mounted() {
|
|
|
// this.initMAp();
|
|
|
this.initAMap();
|
|
@@ -48,10 +50,15 @@ export default {
|
|
|
_this.map = new AMap.Map('container', {
|
|
|
//设置地图容器id
|
|
|
viewMode: '3D', //是否为3D地图模式
|
|
|
+ terrain: true,
|
|
|
zoom: _this.zoom, //初始化地图级别
|
|
|
center: _this.lngLat, //初始化地图中心点位置
|
|
|
pitch: 30,
|
|
|
- layers: [new AMap.TileLayer.Satellite(), new AMap.TileLayer.RoadNet()]
|
|
|
+ layers: [
|
|
|
+ new AMap.TileLayer.Satellite(),
|
|
|
+ new AMap.TileLayer.RoadNet()
|
|
|
+ ],
|
|
|
+ features: ['road', 'bg', 'building'] //地图要素
|
|
|
});
|
|
|
AMapUI.load(
|
|
|
['ui/geo/DistrictExplorer', 'lib/$'],
|
|
@@ -59,12 +66,12 @@ export default {
|
|
|
_this.loadMapData(DistrictExplorer, $);
|
|
|
}
|
|
|
);
|
|
|
- this.$nextTick(() => {
|
|
|
- // this.getDistrict()
|
|
|
- });
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // // this.getDistrict()
|
|
|
+ // });
|
|
|
});
|
|
|
},
|
|
|
- getDistrict(adName,mapLevel) {
|
|
|
+ getDistrict(adName, mapLevel) {
|
|
|
let that = this;
|
|
|
AMap.plugin(['AMap.DistrictSearch'], function () {
|
|
|
var district = new AMap.DistrictSearch({
|
|
@@ -76,7 +83,6 @@ export default {
|
|
|
subdistrict: 1
|
|
|
});
|
|
|
district.search(adName, function (status, result) {
|
|
|
- console.log(result);
|
|
|
var outer = [
|
|
|
new AMap.LngLat(-360, 90, true),
|
|
|
new AMap.LngLat(-360, -90, true),
|
|
@@ -145,20 +151,25 @@ export default {
|
|
|
);
|
|
|
}
|
|
|
);
|
|
|
+ //监听鼠标在feature上滑动
|
|
|
+ this.districtExplorer.on('featureMousemove', (e) => {
|
|
|
+ //更新提示位置
|
|
|
+ this.tipMarker.setPosition(e.originalEvent.lnglat);
|
|
|
+ });
|
|
|
var adName = that.adcode; //贵州省
|
|
|
var mapLevel = that.mapLevel;
|
|
|
- var adcode = '520000'
|
|
|
+ var adcode = '520000';
|
|
|
//feature被点击
|
|
|
this.districtExplorer.on('featureClick', (e, feature) => {
|
|
|
that.map.clearMap();
|
|
|
const props = feature.properties;
|
|
|
this.switch2AreaNode(props.adcode);
|
|
|
- mapLevel = props.level
|
|
|
- adName = props.name
|
|
|
- that.getDistrict(adName,mapLevel)
|
|
|
+ mapLevel = props.level;
|
|
|
+ adName = props.name;
|
|
|
+ that.getDistrict(adName, mapLevel);
|
|
|
});
|
|
|
this.switch2AreaNode(adcode);
|
|
|
- that.getDistrict(adName,mapLevel)
|
|
|
+ that.getDistrict(adName, mapLevel);
|
|
|
},
|
|
|
//根据Hover状态设置相关样式
|
|
|
toggleHoverFeature(feature, isHover, position) {
|
|
@@ -274,4 +285,45 @@ export default {
|
|
|
z-index: auto;
|
|
|
}
|
|
|
}
|
|
|
+/deep/ .amap-marker-content {
|
|
|
+ .tipMarker {
|
|
|
+ color: #555;
|
|
|
+ background-color: rgba(255, 254, 239, 0.8);
|
|
|
+ border: 1px solid #7e7e7e;
|
|
|
+ padding: 2px 6px;
|
|
|
+ font-size: 12px;
|
|
|
+ white-space: nowrap;
|
|
|
+ display: inline-block;
|
|
|
+ &:before,
|
|
|
+ &:after {
|
|
|
+ content: '';
|
|
|
+ display: block;
|
|
|
+ position: absolute;
|
|
|
+ margin: auto;
|
|
|
+ width: 0;
|
|
|
+ height: 0;
|
|
|
+ border: solid transparent;
|
|
|
+ border-width: 5px 5px;
|
|
|
+ }
|
|
|
+ &.top {
|
|
|
+ transform: translate(-50%, -110%);
|
|
|
+ &:before,
|
|
|
+ &:after {
|
|
|
+ bottom: -9px;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ border-top-color: rgba(255, 254, 239, 0.8);
|
|
|
+ }
|
|
|
+ &:before {
|
|
|
+ bottom: -10px;
|
|
|
+ border-top-color: #7e7e7e;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+/deep/ .amap-logo,
|
|
|
+.amap-copyright {
|
|
|
+ display: block !important;
|
|
|
+ visibility: inherit !important;
|
|
|
+}
|
|
|
</style>
|