initMap() {
chinaScene = new Scene({
id: "mapChina",
map: new Map({
style: "dark",
center: [103.99130938786305, 33.982243853450086],
zoom: 3.4,
pitch: 20,
}),
logoVisible: false,
});
chinaScene.setMapStatus({
dragEnable: false, // 是否允许地图拖拽
keyboardEnable: false, // 是否允许形键盘事件
doubleClickZoom: false, // 双击放大
zoomEnable: false, // 滚动缩放
rotateEnable: false // 旋转
})
chinaScene.on("loaded", () => {
let lineDown, lineUp, textLayer;
fetch(
'https://gw.alipayobjects.com/os/bmw-prod/ecd1aaac-44c0-4232-b66c-c0ced76d5c7d.json'
)
.then((res) => res.json())
.then((data) => {
});
const texts = [];
// data.features.map((option) => {
this.chinaJson.features.map((option) => {
const { name, center } = option.properties;
const [lng, lat] = center;
texts.push({ name, lng, lat });
return "";
});
textLayer = new PointLayer({ zIndex: 9999 })
.source(texts, {
parser: {
type: "json",
x: "lng",
y: "lat",
},
})
.shape("name", "text")
.size(18)
.color("#fff")
.style({
textAnchor: "center", // 文本相对锚点的位置 center|left|right|top|bottom|top-left
spacing: 2, // 字符间距
padding: [1, 1], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
stroke: "#0ff", // 描边颜色
strokeWidth: 0.2, // 描边宽度
raisingHeight: 100000,
textAllowOverlap: true,
opacity: 1,
});
chinaScene.addLayer(textLayer);
lineUp = new LineLayer({ zIndex: 10 })
.source(this.chinaJson)
.shape("line")
.color("#6ce8fb")
.size(1.2)
.style({
raisingHeight: 106500,
});
chinaScene.addLayer(lineUp);
09-22
659
659
10-09
250
250

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



