Commit 278d1591 by fengfan

map

parent 71f18484
<!DOCTYPE html>
<html>
<head>
<meta
name="viewport"
content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0"
/>
<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>
......@@ -16,11 +14,12 @@
height: 100%;
}
</style>
</head>
</head>
<body>
<body>
<div id="container"></div>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=ee7327615de4d673c4e455a772da45fd&plugin=Map3D,AMap.DistrictSearch"></script>
<script
src="https://webapi.amap.com/maps?v=1.4.15&key=ee7327615de4d673c4e455a772da45fd&plugin=Map3D,AMap.DistrictSearch"></script>
<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> -->
<script language="javascript">
......@@ -55,9 +54,13 @@
var params = GetParams();
//ltype 2 路网 12 poi
var Satellite = new AMap.TileLayer.Satellite({
rejectMapMask: true,
// 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
......@@ -66,13 +69,17 @@
//也可以直接通过经纬度构建mask路径
var district = new AMap.DistrictSearch(opts);
var map;
var init = function() {
district.search(params.city ? params.city : '成都市', function(status, result) {
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,
mask: mask,
center: [result.districtList[0].center.lng, result.districtList[0].center.lat],
// mapStyle: 'amap://styles/' + styleId,
disableSocket: true,
......@@ -85,6 +92,7 @@
// layers: [road, ]//Satellite,
});
map.add(Satellite);
map.add(SatelliteDowm);
findsubarea(result);
// map.getLayers()[0].setOpacity(0.5)
// var maskerIn = new AMap.Marker({
......@@ -96,7 +104,7 @@
// map: map
// })
//添加高度面
var object3Dlayer = new AMap.Object3DLayer({ zIndex: 1000 });
var object3Dlayer = new AMap.Object3DLayer({ zIndex: 9 });
map.add(object3Dlayer);
var height = -59800;
var color = '#ffffffcc'; //rgba
......@@ -116,7 +124,7 @@
map: map
});
}
AMapUI.loadUI(['geo/DistrictExplorer'], function(DistrictExplorer) {
AMapUI.loadUI(['geo/DistrictExplorer'], function (DistrictExplorer) {
initMask(DistrictExplorer);
});
});
......@@ -131,7 +139,7 @@
console.log(map.getLayers());
var countryCode = 100000; //全国
districtExplorer.loadMultiAreaNodes([countryCode], function(
districtExplorer.loadMultiAreaNodes([countryCode], function (
error,
areaNodes
) {
......@@ -172,7 +180,7 @@
function getLongestRing(feature) {
var rings = getAllRings(feature);
rings.sort(function(a, b) {
rings.sort(function (a, b) {
return b.length - a.length;
});
......@@ -199,7 +207,7 @@
) {
let adcode =
childrensDistrictList[index].adcode
district.search(adcode, function(status, result) {
district.search(adcode, function (status, result) {
// path.push.apply(path, )
var polygon2 = new AMap.Polygon({
bubble: true,
......@@ -216,5 +224,6 @@
}
}
</script>
</body>
</body>
</html>
\ No newline at end of file
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