Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
html
/
MeteorologicalBureau
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
71f18484
authored
Feb 26, 2020
by
fengfan
Browse files
Options
Browse Files
Download
Plain Diff
map
parents
82e1ce65
25e986ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
192 additions
and
173 deletions
+192
-173
map/.DS_Store
+0
-0
map/index.html
+192
-173
No files found.
map/.DS_Store
View file @
71f18484
No preview for this file type
map/index.html
View file @
71f18484
<!DOCTYPE
HTML
>
<!DOCTYPE
html
>
<html>
<html>
<head>
<head>
<meta
<meta
name=
"viewport"
content=
"width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0"
>
name=
"viewport"
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
content=
"width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0"
<title>
区域掩模
</title>
/>
<style>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
body
,
<title>
区域掩模
</title>
html
,
<style>
#container
{
body
,
margin
:
0
;
html
,
width
:
100%
;
#container
{
height
:
100%
margin
:
0
;
}
width
:
100%
;
</style>
height
:
100%
;
</head>
}
</style>
<body>
</head>
<div
id=
"container"
></div>
<script
<body>
src=
"https://webapi.amap.com/maps?v=1.4.15&key=ee7327615de4d673c4e455a772da45fd&plugin=Map3D,AMap.DistrictSearch"
></script>
<div
id=
"container"
></div>
<script
src=
"https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"
></script>
<script
src=
"https://webapi.amap.com/maps?v=1.4.15&key=ee7327615de4d673c4e455a772da45fd&plugin=Map3D,AMap.DistrictSearch"
></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script> -->
<script
src=
"https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"
></script>
<script
language=
"javascript"
>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script> -->
// open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/ff/git/
<script
language=
"javascript"
>
// open -n /Applications/Google\ Chrome.app/ --args --disable-web-security --user-data-dir=/Users/ff/git/
var
styleId
=
'14732285e0b3c284fa6efdb25627d3f6'
var
opts
=
{
var
styleId
=
'14732285e0b3c284fa6efdb25627d3f6'
;
subdistrict
:
3
,
var
opts
=
{
extensions
:
'all'
,
subdistrict
:
3
,
level
:
'district'
extensions
:
'all'
,
};
level
:
'district'
var
bounds
;
};
var
boundsPath
=
[];
var
bounds
;
var
road
=
new
AMap
.
TileLayer
({
var
boundsPath
=
[];
getTileUrl
:
"https://wprd02.is.autonavi.com/appmaptile?x=[x]&y=[y]&z=[z]&lang=zh_cn&size=1&scl=1&style=8<ype=12"
var
road
=
new
AMap
.
TileLayer
({
})
getTileUrl
:
//ltype 2 路网 12 poi
'https://wprd02.is.autonavi.com/appmaptile?x=[x]&y=[y]&z=[z]&lang=zh_cn&size=1&scl=1&style=8<ype=12'
var
Satellite
=
new
AMap
.
TileLayer
.
Satellite
({
});
rejectMapMask
:
true
,
function
GetParams
()
{
zIndex
:
1
var
url
=
location
.
search
;
//获取url中"?"符后的字串
})
var
theRequest
=
new
Object
();
var
RoadNet
=
new
AMap
.
TileLayer
.
RoadNet
({
if
(
url
.
indexOf
(
'?'
)
!=
-
1
)
{
rejectMapMask
:
true
,
var
str
=
url
.
substr
(
1
);
})
strs
=
str
.
split
(
'&'
);
//利用行政区查询获取边界构建mask路径
for
(
var
i
=
0
;
i
<
strs
.
length
;
i
++
)
{
//也可以直接通过经纬度构建mask路径
theRequest
[
strs
[
i
].
split
(
'='
)[
0
]]
=
decodeURI
(
var
district
=
new
AMap
.
DistrictSearch
(
opts
);
strs
[
i
].
split
(
'='
)[
1
]
var
map
);
var
init
=
function
()
{
}
district
.
search
(
'110000'
,
function
(
status
,
result
)
{
console
.
log
(
result
);
bounds
=
result
.
districtList
[
0
].
boundaries
;
boundsPath
=
bounds2Path
(
bounds
)
map
=
new
AMap
.
Map
(
'container'
,
{
// mask: mask,
center
:
[
116.472804
,
39.995725
],
// 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
);
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
:
1000
});
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
)
{
return
theRequest
;
initMask
(
DistrictExplorer
);
}
});
var
params
=
GetParams
();
//ltype 2 路网 12 poi
var
Satellite
=
new
AMap
.
TileLayer
.
Satellite
({
rejectMapMask
:
true
,
zIndex
:
10
});
});
}
var
RoadNet
=
new
AMap
.
TileLayer
.
RoadNet
({
init
()
rejectMapMask
:
true
,
mapStyle
:
'amap://styles/'
+
styleId
function
initMask
(
DistrictExplorer
)
{
//创建一个实例
var
districtExplorer
=
new
DistrictExplorer
({
map
:
map
});
});
console
.
log
(
map
.
getLayers
())
//利用行政区查询获取边界构建mask路径
var
countryCode
=
100000
//全国
//也可以直接通过经纬度构建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
);
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
);
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
:
1000
});
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
);
});
});
};
init
();
districtExplorer
.
loadMultiAreaNodes
([
countryCode
],
function
(
error
,
areaNodes
)
{
//.concat(areaCodes)
function
initMask
(
DistrictExplorer
)
{
//创建一个实例
var
districtExplorer
=
new
DistrictExplorer
({
map
:
map
});
console
.
log
(
map
.
getLayers
());
var
countryCode
=
100000
;
//全国
var
cityNode
=
areaNodes
[
0
],
districtExplorer
.
loadMultiAreaNodes
([
countryCode
],
function
(
areaNodes
=
areaNodes
.
slice
(
1
);
error
,
areaNodes
)
{
//.concat(areaCodes)
var
path
=
[];
var
cityNode
=
areaNodes
[
0
],
areaNodes
=
areaNodes
.
slice
(
1
);
//首先放置背景区域,这里是大陆的边界
var
path
=
[];
path
.
push
(
getLongestRing
(
cityNode
.
getParentFeature
()));
path
.
push
.
apply
(
path
,
[
boundsPath
])
//首先放置背景区域,这里是大陆的边界
var
polygon
=
new
AMap
.
Polygon
({
path
.
push
(
getLongestRing
(
cityNode
.
getParentFeature
()));
path
.
push
.
apply
(
path
,
boundsPath
);
var
polygon
=
new
AMap
.
Polygon
({
bubble
:
true
,
bubble
:
true
,
lineJoin
:
'round'
,
lineJoin
:
'round'
,
strokeColor
:
'#99ffff'
,
//线颜色
strokeColor
:
'#99ffff'
,
//线颜色
...
@@ -136,65 +156,65 @@
...
@@ -136,65 +156,65 @@
map
:
map
,
map
:
map
,
path
:
path
path
:
path
});
});
});
}
function
getAllRings
(
feature
)
{
})
var
coords
=
feature
.
geometry
.
coordinates
,
rings
=
[];
}
function
getAllRings
(
feature
)
{
var
coords
=
feature
.
geometry
.
coordinates
,
for
(
var
i
=
0
,
len
=
coords
.
length
;
i
<
len
;
i
++
)
{
rings
=
[];
rings
.
push
(
coords
[
i
][
0
]);
}
for
(
var
i
=
0
,
len
=
coords
.
length
;
i
<
len
;
i
++
)
{
return
rings
;
rings
.
push
(
coords
[
i
][
0
]);
}
}
return
rings
;
function
getLongestRing
(
feature
)
{
}
var
rings
=
getAllRings
(
feature
);
function
getLongestRing
(
feature
)
{
rings
.
sort
(
function
(
a
,
b
)
{
var
rings
=
getAllRings
(
feature
);
return
b
.
length
-
a
.
length
;
});
rings
.
sort
(
function
(
a
,
b
)
{
return
b
.
length
-
a
.
length
;
});
return
rings
[
0
];
return
rings
[
0
];
}
}
function
bounds2Path
(
bounds
)
{
function
bounds2Path
(
bounds
)
{
var
path
=
[]
var
path
=
[];
for
(
var
i
=
0
;
i
<
bounds
.
length
;
i
+=
1
)
{
for
(
var
i
=
0
;
i
<
bounds
.
length
;
i
+=
1
)
{
for
(
let
index
=
0
;
index
<
bounds
[
i
].
length
;
index
++
)
{
var
subPath
=
[]
let
element
=
bounds
[
i
][
index
];
for
(
let
index
=
0
;
index
<
bounds
[
i
].
length
;
index
++
)
{
path
.
push
([
element
.
lng
,
element
.
lat
])
let
element
=
bounds
[
i
][
index
];
subPath
.
push
([
element
.
lng
,
element
.
lat
]);
}
path
.
push
(
subPath
)
}
}
return
path
;
}
}
return
path
function
findsubarea
(
res
)
{
}
let
childrensDistrictList
=
res
.
districtList
[
0
].
districtList
function
findsubarea
(
res
)
{
for
(
for
(
let
index
=
0
;
index
<
res
.
districtList
[
0
].
districtList
[
0
].
districtList
.
length
;
index
++
)
{
let
index
=
0
;
let
adcode
=
res
.
districtList
[
0
].
districtList
[
0
].
districtList
[
index
].
adcode
;
index
<
childrensDistrictList
.
length
;
district
.
search
(
adcode
,
function
(
status
,
result
)
{
index
++
// path.push.apply(path, )
)
{
var
polygon2
=
new
AMap
.
Polygon
({
let
adcode
=
bubble
:
true
,
childrensDistrictList
[
index
].
adcode
lineJoin
:
'round'
,
district
.
search
(
adcode
,
function
(
status
,
result
)
{
strokeColor
:
'#99ffff'
,
//线颜色
// path.push.apply(path, )
strokeOpacity
:
1
,
//线透明度
var
polygon2
=
new
AMap
.
Polygon
({
strokeWeight
:
2
,
//线宽
bubble
:
true
,
fillColor
:
'black'
,
//填充色
lineJoin
:
'round'
,
fillOpacity
:
0
.,
//填充透明度
strokeColor
:
'#99ffff'
,
//线颜色
map
:
map
,
strokeOpacity
:
1
,
//线透明度
path
:
[
bounds2Path
(
result
.
districtList
[
0
].
boundaries
)]
strokeWeight
:
2
,
//线宽
})
fillColor
:
'black'
,
//填充色
})
fillOpacity
:
0
,
//填充透明度
map
:
map
,
path
:
bounds2Path
(
result
.
districtList
[
0
].
boundaries
)
});
});
}
}
}
</script>
</body>
}
</html>
</script>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment