Commit 6b2c313b by hanjixin

Merge branch 'master' of gitlab.maxrocky.com:hanjixin/MeteorologicalBureau

parents 4a859a99 97319ad1
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<meta
name="viewport"
content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0"
/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>区域掩模</title>
<style>
body,
html,
#container {
margin: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<<<<<<< HEAD
<head>
<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>区域掩模</title>
<style>
body,
html,
#container {
margin: 0;
width: 100%;
height: 100%;
}
</style>
</head>
=======
<body> <body>
<div id="container"></div> <div id="container"></div>
<script src="https://cache.amap.com/lbs/static/es5.min.js"></script> <script src="https://cache.amap.com/lbs/static/es5.min.js"></script>
...@@ -28,33 +27,120 @@ ...@@ -28,33 +27,120 @@
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script> --> <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script> -->
<script language="javascript"> <script language="javascript">
// open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/ff/git/ // open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/ff/git/
>>>>>>> 73f9107f9fd6bd3de2c2bad02c1d402c7b5bf882
var styleId = '14732285e0b3c284fa6efdb25627d3f6'; <body>
var opts = { <div id="container"></div>
subdistrict: 3, <script
extensions: 'all', src="https://webapi.amap.com/maps?v=1.4.15&key=ee7327615de4d673c4e455a772da45fd&plugin=Map3D,AMap.DistrictSearch"></script>
level: 'district' <script src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
}; <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script> -->
var bounds; <script language="javascript">
var boundsPath = []; // open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/ff/git/
var road = new AMap.TileLayer({
getTileUrl: var styleId = '14732285e0b3c284fa6efdb25627d3f6';
'https://wprd02.is.autonavi.com/appmaptile?x=[x]&y=[y]&z=[z]&lang=zh_cn&size=1&scl=1&style=8&ltype=12' var opts = {
}); subdistrict: 3,
function GetParams() { extensions: 'all',
var url = location.search; //获取url中"?"符后的字串 level: 'district'
var theRequest = new Object(); };
if (url.indexOf('?') != -1) { var bounds;
var str = url.substr(1); var boundsPath = [];
strs = str.split('&'); var road = new AMap.TileLayer({
for (var i = 0; i < strs.length; i++) { getTileUrl:
theRequest[strs[i].split('=')[0]] = decodeURI( 'https://wprd02.is.autonavi.com/appmaptile?x=[x]&y=[y]&z=[z]&lang=zh_cn&size=1&scl=1&style=8&ltype=12'
strs[i].split('=')[1] });
); function GetParams() {
} var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf('?') != -1) {
var str = url.substr(1);
strs = str.split('&');
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split('=')[0]] = decodeURI(
strs[i].split('=')[1]
);
} }
return theRequest;
} }
<<<<<<< HEAD
return theRequest;
}
var params = GetParams();
//ltype 2 路网 12 poi
var Satellite = new AMap.TileLayer.Satellite({
// rejectMapMask: true,
zIndex: 10
});
var SatelliteDowm = new AMap.TileLayer.Satellite({
rejectMapMask: true,
zIndex: 0
});
var RoadNet = new AMap.TileLayer.RoadNet({
rejectMapMask: true,
mapStyle: 'amap://styles/' + styleId
});
//利用行政区查询获取边界构建mask路径
//也可以直接通过经纬度构建mask路径
var district = new AMap.DistrictSearch(opts);
var map;
var init = function () {
district.search(params.city ? params.city : '成都市', function (status, result) {
console.log(result);
bounds = result.districtList[0].boundaries;
boundsPath = bounds2Path(bounds);
var mask = []
for (var i = 0; i < bounds.length; i += 1) {
mask.push([bounds[i]])
}
map = new AMap.Map('container', {
mask: mask,
center: [result.districtList[0].center.lng, result.districtList[0].center.lat],
// mapStyle: 'amap://styles/' + styleId,
disableSocket: true,
viewMode: '3D',
showLabel: false,
labelzIndex: 130,
pitch: 40,
zoom: 9
// layers: [RoadNet,Satellite ]//Satellite,
// layers: [road, ]//Satellite,
});
map.add(Satellite);
map.add(SatelliteDowm);
findsubarea(result);
// map.getLayers()[0].setOpacity(0.5)
// var maskerIn = new AMap.Marker({
// position: [116.501415, 39.926055],
// map: map
// })
// var maskerOut = new AMap.Marker({//区域外的不会显示
// position: [117.001415, 39.926055],
// map: map
// })
//添加高度面
var object3Dlayer = new AMap.Object3DLayer({ zIndex: 9 });
map.add(object3Dlayer);
var height = -59800;
var color = '#ffffffcc'; //rgba
var wall = new AMap.Object3D.Wall({
path: bounds,
height: height,
color: color
});
wall.transparent = true;
object3Dlayer.add(wall);
//添加描边
for (var i = 0; i < bounds.length; i += 1) {
new AMap.Polyline({
path: bounds[i],
strokeColor: '#99ffff',
strokeWeight: 8,
map: map
});
}
AMapUI.loadUI(['geo/DistrictExplorer'], function (DistrictExplorer) {
initMask(DistrictExplorer);
=======
var params = GetParams(); var params = GetParams();
//ltype 2 路网 12 poi //ltype 2 路网 12 poi
var Satellite = new AMap.TileLayer.Satellite({ var Satellite = new AMap.TileLayer.Satellite({
...@@ -139,59 +225,110 @@ ...@@ -139,59 +225,110 @@
setPersonalPoint(item); setPersonalPoint(item);
}); });
}); });
>>>>>>> 73f9107f9fd6bd3de2c2bad02c1d402c7b5bf882
}); });
}; });
init(); };
init();
function initMask(DistrictExplorer) {
//创建一个实例
var districtExplorer = new DistrictExplorer({
map: map
});
console.log(map.getLayers());
var countryCode = 100000; //全国
districtExplorer.loadMultiAreaNodes([countryCode], function (
error,
areaNodes
) {
//.concat(areaCodes)
var cityNode = areaNodes[0],
areaNodes = areaNodes.slice(1);
function initMask(DistrictExplorer) { var path = [];
//创建一个实例
var districtExplorer = new DistrictExplorer({ //首先放置背景区域,这里是大陆的边界
map: map path.push(getLongestRing(cityNode.getParentFeature()));
path.push.apply(path, boundsPath);
var polygon = new AMap.Polygon({
bubble: true,
lineJoin: 'round',
strokeColor: '#99ffff', //线颜色
strokeOpacity: 1, //线透明度
strokeWeight: 5, //线宽
fillColor: 'black', //填充色
fillOpacity: 0.65, //填充透明度
map: map,
path: path
}); });
console.log(map.getLayers()); });
var countryCode = 100000; //全国 }
function getAllRings(feature) {
var coords = feature.geometry.coordinates,
rings = [];
districtExplorer.loadMultiAreaNodes([countryCode], function( for (var i = 0, len = coords.length; i < len; i++) {
error, rings.push(coords[i][0]);
areaNodes }
) {
//.concat(areaCodes)
var cityNode = areaNodes[0], return rings;
areaNodes = areaNodes.slice(1); }
var path = []; function getLongestRing(feature) {
var rings = getAllRings(feature);
rings.sort(function (a, b) {
return b.length - a.length;
});
//首先放置背景区域,这里是大陆的边界 return rings[0];
path.push(getLongestRing(cityNode.getParentFeature())); }
path.push.apply(path, boundsPath); function bounds2Path(bounds) {
var polygon = new AMap.Polygon({ var path = [];
for (var i = 0; i < bounds.length; i += 1) {
var subPath = []
for (let index = 0; index < bounds[i].length; index++) {
let element = bounds[i][index];
subPath.push([element.lng, element.lat]);
}
path.push(subPath)
}
return path;
}
function findsubarea(res) {
let childrensDistrictList = res.districtList[0].districtList
for (
let index = 0;
index < childrensDistrictList.length;
index++
) {
let adcode =
childrensDistrictList[index].adcode
district.search(adcode, function (status, result) {
// path.push.apply(path, )
var polygon2 = new AMap.Polygon({
bubble: true, bubble: true,
lineJoin: 'round', lineJoin: 'round',
strokeColor: '#99ffff', //线颜色 strokeColor: '#99ffff', //线颜色
strokeOpacity: 1, //线透明度 strokeOpacity: 1, //线透明度
strokeWeight: 5, //线宽 strokeWeight: 2, //线宽
fillColor: 'black', //填充色 fillColor: 'black', //填充色
fillOpacity: 0.65, //填充透明度 fillOpacity: 0, //填充透明度
map: map, map: map,
path: path path: bounds2Path(result.districtList[0].boundaries)
}); });
}); });
} }
function getAllRings(feature) { }
var coords = feature.geometry.coordinates, </script>
rings = []; </body>
for (var i = 0, len = coords.length; i < len; i++) {
rings.push(coords[i][0]);
}
return rings;
}
function getLongestRing(feature) {
var rings = getAllRings(feature);
<<<<<<< HEAD
</html>
=======
rings.sort(function(a, b) { rings.sort(function(a, b) {
return b.length - a.length; return b.length - a.length;
}); });
...@@ -262,3 +399,4 @@ ...@@ -262,3 +399,4 @@
</script> </script>
</body> </body>
</html> </html>
>>>>>>> 73f9107f9fd6bd3de2c2bad02c1d402c7b5bf882
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment