ElemeFE / ElemeFE/react-amap

DistrictLayer

Open
#224 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1k
Forks
148
PR merge metrics
No merged PRs in 30d

Description

请给一个DistrictLayer的例子
我再mapEvents 中加载Province
this.mapEvents = {
created(map) {
_this.map = map;

_this.province && _this.province.setMap(null);
map.plugin('AMap.DistrictLayer', () => {
_this.province = new AMap.DistrictLayer.Province({
zIndex: 12,
adcode: 130000,
depth: 2,
styles: {
'fill': function(properties) {
// properties为可用于做样式映射的字段,包含
// NAME_CHN:中文名称
// adcode_pro
// adcode_cit
// adcode
var adcode = 130000;
return () => {
var colors = {}
if (!colors[adcode]) {
var gb = Math.random() * 155 + 50;
colors[adcode] = 'rgb(' + gb + ',' + gb + ',255)';
}

return colors[adcode];
};
},
'province-stroke': 'cornflowerblue',
'city-stroke': 'white', // 中国地级市边界
'county-stroke': 'rgba(255,255,255,0.5)', // 中国区县边界
},
});
console.log('_this.province', _this.province,_this.map.getContainer());

_this.province.setMap(_this.map);
});

},
但是使用.province.setMap方法并没有起作用

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.