|
|
@ -52,9 +52,14 @@ function Map(props) { |
|
|
|
map.on('complete', () => { |
|
|
|
setTimeout(() => { |
|
|
|
setDelay(false) |
|
|
|
map && renderMarkers() |
|
|
|
map && renderAlarms() |
|
|
|
|
|
|
|
}, 1500); |
|
|
|
map && renderMarkers() |
|
|
|
map && renderAlarms() |
|
|
|
setTimeout(() => { |
|
|
|
renderLayer() |
|
|
|
createText() |
|
|
|
}, 1000); |
|
|
|
}); |
|
|
|
|
|
|
|
map.on('click', (e) => { |
|
|
@ -361,6 +366,158 @@ function Map(props) { |
|
|
|
</div> |
|
|
|
} |
|
|
|
|
|
|
|
const createText = () => { |
|
|
|
var text = new AMap.Text({ |
|
|
|
text: '南昌县', |
|
|
|
anchor: 'center', // 设置文本标记锚点
|
|
|
|
draggable: false, |
|
|
|
// cursor: 'pointer',
|
|
|
|
zooms: [3, 11], |
|
|
|
style: { |
|
|
|
'padding': '.75rem 1.25rem', |
|
|
|
'margin-bottom': '1rem', |
|
|
|
'border-radius': '.25rem', |
|
|
|
'background-color': 'rgba(238,77,90,0.001)', |
|
|
|
'width': '8rem', |
|
|
|
'border-width': 0, |
|
|
|
//'box-shadow': '0 2px 6px 0 rgba(255, 255, 255, .1)',
|
|
|
|
'text-align': 'center', |
|
|
|
'font-size': '14px', |
|
|
|
'color': '#AFEFFF', |
|
|
|
'opacity': 1, |
|
|
|
// 'font-weight': 'bold'
|
|
|
|
}, |
|
|
|
position: [115.934664, 28.538966] |
|
|
|
}); |
|
|
|
text.setMap(map); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const renderLayer = () => { |
|
|
|
if (!loca) return; |
|
|
|
const dataSource = trendData; |
|
|
|
|
|
|
|
if (gridLayer && loca) loca.remove(gridLayer) |
|
|
|
|
|
|
|
let data = [] |
|
|
|
dataSource.map(x => { |
|
|
|
data.push({ |
|
|
|
"type": "Feature", "properties": { "time": 1534296083, x }, |
|
|
|
"geometry": { "coordinates": [x.lng, x.lat], "type": "Point", x } |
|
|
|
}) |
|
|
|
}) |
|
|
|
var geo = new Loca.GeoJSONSource({ |
|
|
|
data: { |
|
|
|
"features": data, "type": "FeatureCollection" |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
gridLayer = new Loca.GridLayer({ |
|
|
|
// loca,
|
|
|
|
zIndex: 10, |
|
|
|
opacity: 1, |
|
|
|
visible: true, |
|
|
|
zooms: [2, 22], |
|
|
|
acceptLight: true, |
|
|
|
// shinniness: 0,
|
|
|
|
// cullface: 'none',
|
|
|
|
// depth: true,
|
|
|
|
// hasSide: true,
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var colors = ['#FAE200', '#D27E37', '#C53634', '#C12B6E', '#A92E9A', '#67238A', '#211A50', '#18244E'].reverse(); |
|
|
|
var heights = [100, 200, 400, 600, 800, 1400, 1800, 4000]; |
|
|
|
gridLayer.setSource(geo); |
|
|
|
gridLayer.setStyle({ |
|
|
|
unit: 'meter', |
|
|
|
radius: 600, |
|
|
|
gap: 0, |
|
|
|
altitude: 100, |
|
|
|
// height: function (index, feature) {
|
|
|
|
// return 6000
|
|
|
|
|
|
|
|
// },
|
|
|
|
// topColor: function (index, feature) {
|
|
|
|
// console.log(feature)
|
|
|
|
// return 'red'
|
|
|
|
// },
|
|
|
|
// sideColor: function (index, feature) {
|
|
|
|
// return 'red'
|
|
|
|
// }
|
|
|
|
height: function (index, feature) { |
|
|
|
const baseHeigh = 1400 |
|
|
|
return feature.coordinates[0].properties.x.waterLevel > 30 ? baseHeigh * 14 : |
|
|
|
feature.coordinates[0].properties.x.waterLevel > 25 ? baseHeigh * 13 : |
|
|
|
feature.coordinates[0].properties.x.waterLevel > 20 ? baseHeigh * 12 : |
|
|
|
feature.coordinates[0].properties.x.waterLevel > 15 ? baseHeigh * 11 : |
|
|
|
feature.coordinates[0].properties.x.waterLevel > 10 ? baseHeigh * 10 : |
|
|
|
feature.coordinates[0].properties.x.waterLevel > 0 ? baseHeigh * 9 : 0 |
|
|
|
|
|
|
|
}, |
|
|
|
topColor: function (index, feature) { |
|
|
|
return feature.coordinates[0].properties.x.waterLevel > Number(feature.coordinates[0].properties.x.alert) ? 'rgba(255,136,140,1)' : 'rgba(117,154,206,1)' |
|
|
|
}, |
|
|
|
sideColor: function (index, feature) { |
|
|
|
return feature.coordinates[0].properties.x.waterLevel > Number(feature.coordinates[0].properties.x.alert) ? 'rgba(255,136,140,1)' : 'rgba(117,154,206,1)' |
|
|
|
}, |
|
|
|
sideTopColor: function (index, feature) { |
|
|
|
return feature.coordinates[0].properties.x.waterLevel > Number(feature.coordinates[0].properties.x.alert) ? 'rgba(255,136,140,1)' : 'rgba(117,154,206,1)' |
|
|
|
}, |
|
|
|
sideBottomColor: function (index, feature) { |
|
|
|
return feature.coordinates[0].properties.x.waterLevel > Number(feature.coordinates[0].properties.x.alert) ? 'rgba(255,136,140,0.5)' : 'rgba(117,154,206,0.5)' |
|
|
|
}, |
|
|
|
}); |
|
|
|
gridLayer = gridLayer |
|
|
|
loca.add(gridLayer); |
|
|
|
|
|
|
|
dataSource.map(s => { |
|
|
|
// 创建纯文本标记
|
|
|
|
var text = new AMap.Text({ |
|
|
|
text: '纯文本标记', |
|
|
|
anchor: 'center', // 设置文本标记锚点
|
|
|
|
// draggable: true,
|
|
|
|
cursor: 'pointer', |
|
|
|
angle: 0, |
|
|
|
// visible: false,
|
|
|
|
offset: [0, -s.waterLevel], |
|
|
|
style: { |
|
|
|
'padding': '2px 4px', |
|
|
|
'margin-bottom': '1rem', |
|
|
|
'border-radius': '.25rem', |
|
|
|
'background-color': '#143857', |
|
|
|
// 'width': '12rem',
|
|
|
|
'border-width': 0, |
|
|
|
'box-shadow': '0 2px 6px 0 rgba(255, 255, 255, .3)', |
|
|
|
'text-align': 'center', |
|
|
|
'font-size': '14px', |
|
|
|
'color': '#DCF2FD', |
|
|
|
}, |
|
|
|
}); |
|
|
|
text.setMap(map); |
|
|
|
text.show(); |
|
|
|
text.setText(`${s.waterLevel || '--'}m`) |
|
|
|
text.setPosition(new AMap.LngLat(s.lng, s.lat)); |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// // 拾取
|
|
|
|
// map.on('mousemove', (e) => {
|
|
|
|
// text.setMap(map);
|
|
|
|
// var feat = gridLayer.queryFeature(e.pixel.toArray());
|
|
|
|
|
|
|
|
// if (feat) {
|
|
|
|
// text.show();
|
|
|
|
// text.setText(feat.coordinates[0].properties.x.waterLevel + 'm');
|
|
|
|
// text.setPosition(e.lnglat);
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
// text.hide();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const tabs = tab == 'overview' ? [ |
|
|
|
{ name: '实时监测', tab: 'overview' }, |
|
|
|
{ name: '应急抢险', tab: 'emergency' } |
|
|
|