style: code style change

This commit is contained in:
2912401452 2021-05-31 10:37:14 +08:00
parent 5378d17f7b
commit 6f06a381ec
5 changed files with 25 additions and 26 deletions

View File

@ -31,7 +31,7 @@ scene.on('loaded', () => {
}) })
.shape('icon', 'text') .shape('icon', 'text')
.size(20) .size(20)
.color('w', ['#f0f9e8','#bae4bc','#7bccc4','#43a2ca','#0868ac']) .color('w', [ '#f0f9e8', '#bae4bc', '#7bccc4', '#43a2ca', '#0868ac' ])
.style({ .style({
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [ 40, 0 ], // 文本相对锚点的偏移量 [水平, 垂直] textOffset: [ 40, 0 ], // 文本相对锚点的偏移量 [水平, 垂直]
@ -39,7 +39,7 @@ scene.on('loaded', () => {
stroke: '#ffffff', // 描边颜色 stroke: '#ffffff', // 描边颜色
fontFamily, fontFamily,
iconfont: true, iconfont: true,
textAllowOverlap: true, textAllowOverlap: true
}); });
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
}); });

View File

@ -24,7 +24,7 @@ const originData = [
}, },
{ {
lng: 119.2, lng: 119.2,
lat: 30., lat: 30.0,
iconType: 'smallRain', iconType: 'smallRain',
iconColor: '#6EA0FF', iconColor: '#6EA0FF',
backgoundColor: '#4678AA', backgoundColor: '#4678AA',

View File

@ -10,8 +10,8 @@ const scene = new Scene({
zoom: 12.5 zoom: 12.5
}) })
}); });
let fontFamily = 'iconfont'; const fontFamily = 'iconfont';
let fontPath = const fontPath =
'//at.alicdn.com/t/font_2534097_bl34aphh10n.woff2?t=1622180820063'; '//at.alicdn.com/t/font_2534097_bl34aphh10n.woff2?t=1622180820063';
scene.addIconFont('up', ''); scene.addIconFont('up', '');
scene.addIconFont('down', ''); scene.addIconFont('down', '');
@ -20,63 +20,63 @@ scene.addFontFace(fontFamily, fontPath);
scene.on('loaded', () => { scene.on('loaded', () => {
fetch( fetch(
'https://gw.alipayobjects.com/os/bmw-prod/41802695-0f7e-4a81-ab16-539c4e39df0d.json', 'https://gw.alipayobjects.com/os/bmw-prod/41802695-0f7e-4a81-ab16-539c4e39df0d.json'
) )
.then((res) => res.json()) .then(res => res.json())
.then((data) => { .then(data => {
const filllayer = new PolygonLayer({ const filllayer = new PolygonLayer({
name: 'fill', name: 'fill',
zIndex: 3, zIndex: 3
}) })
.source(data) .source(data)
.shape('fill') .shape('fill')
.color('count', ['rgb(194, 143, 133)', 'rgb(148, 167, 192)']) .color('count', [ 'rgb(194, 143, 133)', 'rgb(148, 167, 192)' ])
.style({ .style({
opacity: 0.5, opacity: 0.5
}); });
scene.addLayer(filllayer); scene.addLayer(filllayer);
const linelayer = new LineLayer({ const linelayer = new LineLayer({
zIndex: 5, zIndex: 5,
name: 'line2', name: 'line2'
}) })
.source(data) .source(data)
.shape('line') .shape('line')
.size(1) .size(1)
.color('#fff') .color('#fff')
.style({ .style({
opacity: 0.3, opacity: 0.3
}); });
scene.addLayer(linelayer); scene.addLayer(linelayer);
const pointLayer = new PointLayer({ const pointLayer = new PointLayer({
zIndex: 10, zIndex: 10
}) })
.source(data) .source(data)
.shape('icon', 'text') .shape('icon', 'text')
.size(15) .size(15)
.color('count', n => n>0?'#0f0':"#f00") .color('count', n => (n > 0 ? '#0f0' : '#f00'))
.style({ .style({
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [30, 5], textOffset: [ 30, 5 ],
padding: [2, 2], padding: [ 2, 2 ],
fontFamily, fontFamily,
iconfont: true, iconfont: true
// textAllowOverlap: true // textAllowOverlap: true
}); });
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
const textLayer = new PointLayer({ const textLayer = new PointLayer({
zIndex: 10, zIndex: 10
}) })
.source(data) .source(data)
.shape('count', 'text') .shape('count', 'text')
.size(12) .size(12)
.color('count', n => n>0?'#0f0':"#f00") .color('count', n => (n > 0 ? '#0f0' : '#f00'))
.style({ .style({
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [40, 10], textOffset: [ 40, 10 ],
padding: [1, 1], padding: [ 1, 1 ]
}); });
scene.addLayer(textLayer); scene.addLayer(textLayer);
}); });

View File

@ -71,9 +71,8 @@ export default class Amap2demo_arcLineTex extends React.Component {
// lineTexture: true, // 开启线的贴图功能 // lineTexture: true, // 开启线的贴图功能
// iconStep: 100, // 设置贴图纹理的间距 // iconStep: 100, // 设置贴图纹理的间距
}) })
.animate(true) .animate(true);
scene.addLayer(layer); scene.addLayer(layer);
}); });
} }

View File

@ -66,7 +66,7 @@ export default class Amap2demo_mesh2 extends React.Component {
.source(data) .source(data)
.shape('icon', 'text') .shape('icon', 'text')
.size(15) .size(15)
.color('count', n => n>0?'#0f0':"#f00") .color('count', (n) => (n > 0 ? '#0f0' : '#f00'))
.style({ .style({
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [30, 5], textOffset: [30, 5],
@ -83,7 +83,7 @@ export default class Amap2demo_mesh2 extends React.Component {
.source(data) .source(data)
.shape('count', 'text') .shape('count', 'text')
.size(12) .size(12)
.color('count', n => n>0?'#0f0':"#f00") .color('count', (n) => (n > 0 ? '#0f0' : '#f00'))
.style({ .style({
textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
textOffset: [40, 10], textOffset: [40, 10],