init
This commit is contained in:
130
ruoyi-ui/public/baidu/area.html
Normal file
130
ruoyi-ui/public/baidu/area.html
Normal file
@@ -0,0 +1,130 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
// 这里一定要配置ak 否则无法使用
|
||||
window.BMAP_AUTHENTIC_KEY = "t6k6UC2IZR40Un8kkqM4RXlaQb4FulyM"
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const result = new URLSearchParams(window.location.search)
|
||||
const params = {}
|
||||
for (const [key, value] of result) {
|
||||
params[key] = value
|
||||
}
|
||||
if(params.NODE_ENV === 'production'){
|
||||
document.write('<link rel="stylesheet" type="text/css" href="./script/bmap.pro.css" />')
|
||||
document.write('<script type="text/javascript" src="./script/getscript.pro.js?type=webgl&v=1.0&services=&t=20230529114224"><\/script>')
|
||||
}else if(params.NODE_ENV === 'pre'){
|
||||
document.write('<link rel="stylesheet" type="text/css" href="./script/bmap.pre.css" />')
|
||||
document.write('<script type="text/javascript" src="./script/getscript.pre.js?type=webgl&v=1.0&services=&t=20230529114224"><\/script>')
|
||||
}else{
|
||||
document.write('<link rel="stylesheet" type="text/css" href="./script/bmap.css" />')
|
||||
document.write('<script type="text/javascript" src="./script/getscript.js?type=webgl&v=1.0&services=&t=20230529114224"><\/script>')
|
||||
}
|
||||
</script>
|
||||
<!-- <script type="text/javascript" src="./script/getscript.js?type=webgl&v=1.0&services=&t=20230529114224"></script> -->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script>
|
||||
window.parent['mapProps']('MAP_LOADING');
|
||||
var map = new BMapGL.Map('container', {
|
||||
backgroundColor: [192, 214, 213, 100]
|
||||
});
|
||||
const localCity = new BMapGL.LocalCity();
|
||||
localCity.get(result => {
|
||||
map.centerAndZoom(result.center, 12);
|
||||
map.setCenter(result.name);
|
||||
map.enableScrollWheelZoom(true);
|
||||
})
|
||||
window.parent['mapProps']('MAP_LOADING_FINISH');
|
||||
|
||||
|
||||
function addPolygon(regionMapVOList) {
|
||||
window.parent['mapProps']('MAP_LOADING');
|
||||
map.clearOverlays();
|
||||
var allPoints = []
|
||||
regionMapVOList.forEach(regionMapVO=>{
|
||||
var regionPoints = []
|
||||
regionMapVO['polygonList'].forEach(polygon => {
|
||||
polygon.forEach(points => {
|
||||
var areaPoints = []
|
||||
points.forEach(point => {
|
||||
var point = new BMapGL.Point(parseFloat(point['x']), parseFloat(point['y']));
|
||||
areaPoints.push(point);
|
||||
allPoints.push(point)
|
||||
})
|
||||
regionPoints.push(areaPoints)
|
||||
});
|
||||
})
|
||||
var polygon = new BMapGL.Polygon(regionPoints, {
|
||||
strokeColor:'#2094ff',
|
||||
strokeWeight: 3,
|
||||
strokeOpacity: 0.8,
|
||||
fillColor: '#2094ff',
|
||||
fillOpacity:0.4,
|
||||
code:regionMapVO.code,
|
||||
});
|
||||
// polygon.addEventListener("mouseout", function () {
|
||||
// polygon.setStrokeWeight(3);
|
||||
// polygon.setFillOpacity(0);
|
||||
// });
|
||||
// polygon.addEventListener("mouseover", function () {
|
||||
// polygon.setStrokeWeight(5);
|
||||
// polygon.setFillOpacity(0.8);
|
||||
// });
|
||||
polygon.addEventListener("click", function (e) {
|
||||
// console.log(e)
|
||||
setAllFillColor(e?.target?._config?.code);
|
||||
window.parent['mapProps']('SHOW_DETAIL:' + regionMapVO['code']);
|
||||
});
|
||||
map.addOverlay(polygon);
|
||||
|
||||
})
|
||||
map.setViewport(allPoints)
|
||||
window.parent['mapProps']('MAP_LOADING_FINISH');
|
||||
}
|
||||
|
||||
|
||||
function setAllFillColor(code) {
|
||||
const overlays = map.getOverlays();
|
||||
// console.log(overlays)
|
||||
overlays.map((overlay) => {
|
||||
if(overlay?._config?.code == code){
|
||||
overlay.setFillColor('#FFEA00');
|
||||
overlay.setStrokeColor('#FFEA00');
|
||||
overlay.setFillOpacity(0.8);
|
||||
overlay.setStrokeWeight(5);
|
||||
}else{
|
||||
overlay.setFillColor('#2094ff');
|
||||
overlay.setStrokeColor('#2094ff');
|
||||
overlay.setFillOpacity(0.4);
|
||||
overlay.setStrokeWeight(3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user