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
408aa379
authored
Mar 13, 2020
by
hanjixin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
map
parent
45852df0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
23 deletions
+17
-23
map/index.html
+2
-2
map/js/Map3D.js
+15
-21
No files found.
map/index.html
View file @
408aa379
...
...
@@ -72,8 +72,8 @@
import
{
Map3D
}
from
'./js/Map3D.js'
;
import
{
GetParams
}
from
'./js/tools.js'
;
var
urlParams
=
GetParams
()
//成都 重庆 天津 北京 上海 大连 三沙
window
.
map3d
=
new
Map3D
(
'成都'
,
'container'
,
urlParams
,(
_map3d
)
=>
{
//成都 重庆 天津 北京 上海 大连 三沙
湖北 中国
window
.
map3d
=
new
Map3D
(
urlParams
.
adcode
||
'成都'
,
'container'
,
urlParams
,(
_map3d
)
=>
{
window
.
addPoiByApi
(
'./led.json'
)
});
window
.
review
=
function
(
params
)
{
...
...
map/js/Map3D.js
View file @
408aa379
import
{
bounds2Path
,
MaskLayer
}
from
"./tools.js"
var
_renderClusterMarker
=
function
(
context
,
count
)
{
// var count = context.markers.length
var
factor
=
Math
.
pow
(
context
.
count
/
count
,
1
/
18
);
var
div
=
document
.
createElement
(
'div'
);
var
Hue
=
180
-
factor
*
180
;
...
...
@@ -61,8 +60,6 @@ class Map3D {
this
.
map
.
remove
(
pois
)
}
addPoisSingle
(
pois
)
{
//https://lbs.amap.com/api/javascript-api/guide/overlays/massmarker/
//https://lbs.amap.com/api/javascript-api/example/marker/markerclusterer
let
markers
=
[]
pois
.
map
(
item
=>
{
markers
.
push
(
this
.
setPersonalPoint
(
item
))
...
...
@@ -70,8 +67,6 @@ class Map3D {
return
markers
}
addPoisMarkerClusterer
(
pois
)
{
//https://lbs.amap.com/api/javascript-api/guide/overlays/massmarker/
//https://lbs.amap.com/api/javascript-api/example/marker/markerclusterer
let
markers
=
[]
pois
.
map
(
item
=>
{
markers
.
push
(
this
.
setPersonalPoint
(
item
))
...
...
@@ -118,12 +113,6 @@ class Map3D {
// // 将海量点添加至地图实例
// massMarks.setMap(map);
if
(
this
.
cluster
)
{
this
.
cluster
.
addMarkers
(
markers
)
}
else
{
this
.
cluster
=
new
AMap
.
MarkerClusterer
(
this
.
map
,
markers
,
{
gridSize
:
80
});
}
return
markers
}
setPersonalPoint
(
item
)
{
...
...
@@ -151,7 +140,7 @@ class Map3D {
async
init
(
cityCode
,
domId
)
{
this
.
cityDistrict
=
await
this
.
getDistrictBycode
(
cityCode
)
//level : province city district street
if
(
!
this
.
cityDistrict
)
{
alert
(
'找不到城市'
)
return
false
...
...
@@ -165,11 +154,12 @@ class Map3D {
mask
:
this
.
cityBounds
.
mask
,
mapStyle
:
'amap://styles/'
+
this
.
styleId
,
viewMode
:
'3D'
,
// showLabel: false,
labelzIndex
:
130
,
pitch
:
45
,
zooms
:
[
1
,
13
],
});
this
.
map
.
add
(
this
.
Satellite
);
//高亮mask 卫星图
this
.
map
.
add
(
this
.
maskLayer
);
// 半黑遮罩层
this
.
map
.
add
(
this
.
SatelliteDown
);
//底图 卫星图
...
...
@@ -183,11 +173,6 @@ class Map3D {
await
this
.
addSubArea
(
this
.
cityDistrict
);
// 查找子行政区
AMap
.
event
.
addListener
(
this
.
map
,
"click"
,
function
(
e
)
{
console
.
log
(
e
);
// new AMap.Marker({
// position: e.lnglat,
// map: map
// });
});
return
1
}
...
...
@@ -219,6 +204,7 @@ class Map3D {
);
this
.
areas
.
push
(
area
)
return
1
// area.on('mouseover', function (e) {
// area.setOptions({ fillOpacity: 0.5 });
// });
...
...
@@ -236,7 +222,7 @@ class Map3D {
var
SubDistricts
=
await
this
.
getSubDistrictByCityDistrict
(
cityDistrict
);
for
(
let
index
=
0
;
index
<
SubDistricts
.
length
;
index
++
)
{
const
element
=
SubDistricts
[
index
];
this
.
renderArea
(
element
);
await
this
.
renderArea
(
element
);
}
return
1
;
}
...
...
@@ -284,10 +270,12 @@ class Map3D {
addWall
(
bounds
)
{
//添加高度面
var
W
=
Number
(
this
.
cityBounds
.
maxlng
)
-
Number
(
this
.
cityBounds
.
minlng
)
var
H
=
Number
(
this
.
cityBounds
.
maxlat
)
-
Number
(
this
.
cityBounds
.
minlat
)
var
params
=
this
.
params
var
object3Dlayer
=
new
AMap
.
Object3DLayer
({
zIndex
:
9
});
this
.
map
.
add
(
object3Dlayer
);
var
height
=
params
.
wallHeight
||
-
32000
;
var
height
=
(
params
.
wallHeight
||
-
32000
)
*
Math
.
sqrt
(
W
*
W
+
H
*
H
)
/
2.94
;
var
color
=
params
.
wallColor
?
(
'#'
+
params
.
wallColor
)
:
'#25a1ff77'
;
var
wall
=
new
AMap
.
Object3D
.
Wall
({
path
:
bounds
,
...
...
@@ -312,9 +300,14 @@ class Map3D {
}
async
getSubDistrictByCityDistrict
(
cityDistrict
)
{
//中国特卡 优化参考
//https://lbs.amap.com/api/amap-ui/demos/amap-ui-districtexplorer/index/?_=1584050281829
console
.
log
(
cityDistrict
.
districtList
[
0
]);
//level :country province city district street
var
cityDistricts
=
cityDistrict
.
districtList
[
0
].
districtList
if
(
cityDistrict
.
districtList
[
0
].
level
===
"city"
)
{
var
cityDistricts
=
cityDistrict
.
districtList
[
0
].
districtList
}
else
if
(
cityDistrict
.
districtList
[
0
].
level
===
"province"
)
{
}
else
if
(
cityDistrict
.
districtList
[
0
].
level
===
"province"
&&
cityDistrict
.
districtList
[
0
].
adcode
==
500000
)
{
var
cityDistricts
=
[]
var
provinceDistrict
=
cityDistrict
.
districtList
[
0
].
districtList
for
(
let
index
=
0
;
index
<
provinceDistrict
.
length
;
index
++
)
{
...
...
@@ -322,6 +315,7 @@ class Map3D {
cityDistricts
=
cityDistricts
.
concat
(
element
.
districtList
)
}
}
// var cityDistricts = cityDistrict.districtList[0].districtList
var
PromiseArr
=
[]
for
(
let
index
=
0
;
index
<
cityDistricts
.
length
;
index
++
)
{
const
element
=
cityDistricts
[
index
];
...
...
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