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
8434be95
authored
Feb 27, 2020
by
hanjixin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改限制
parent
bee487e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
map/index.html
+13
-6
map/js/utils.js
+19
-4
No files found.
map/index.html
View file @
8434be95
...
...
@@ -12,7 +12,7 @@
html
,
#container
{
margin
:
0
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
}
</style>
...
...
@@ -75,7 +75,12 @@
)
{
console
.
log
(
result
);
bounds
=
result
.
districtList
[
0
].
boundaries
;
boundsPath
=
bounds2Path
(
bounds
);
var
_bounds
=
bounds2Path
(
bounds
);
boundsPath
=
_bounds
.
path
;
var
dragLimitBounds
=
new
AMap
.
Bounds
(
new
AMap
.
LngLat
(
Number
(
_bounds
.
minlng
),
Number
(
_bounds
.
minlat
)),
new
AMap
.
LngLat
(
Number
(
_bounds
.
maxlng
),
Number
(
_bounds
.
maxlat
))
);
let
mask
=
[];
for
(
var
i
=
0
;
i
<
bounds
.
length
;
i
+=
1
)
{
mask
.
push
([
bounds
[
i
]]);
...
...
@@ -131,13 +136,15 @@
map
:
map
});
}
// AMapUI.loadUI(['geo/DistrictExplorer'], function (DistrictExplorer) {
// initMask(DistrictExplorer);
// });
map
.
setFitView
();
dragLimit
(
dragLimitBounds
);
//拖动限制 限制地图显示范围
// 获取人员信息
$
.
getJSON
(
'./personal.json'
).
then
(
res
=>
{
console
.
log
(
JSON
.
parse
(
res
));
currentDetailList
=
JSON
.
parse
(
res
).
currentDetailList
.
slice
(
0
,
2000
);
currentDetailList
=
JSON
.
parse
(
res
).
currentDetailList
.
slice
(
0
,
2000
);
currentDetailList
.
map
(
item
=>
{
setPersonalPoint
(
item
);
});
...
...
map/js/utils.js
View file @
8434be95
...
...
@@ -56,16 +56,22 @@ function getLongestRing(feature) {
return
rings
[
0
];
}
function
bounds2Path
(
bounds
)
{
var
maxlng
,
minlng
,
maxlat
,
minlat
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
]);
if
(
!
maxlng
||
element
.
lng
>
maxlng
)
maxlng
=
element
.
lng
;
if
(
!
minlng
||
element
.
lng
<
minlng
)
minlng
=
element
.
lng
;
if
(
!
maxlat
||
element
.
lat
>
maxlat
)
maxlat
=
element
.
lat
;
if
(
!
minlat
||
element
.
lat
<
minlat
)
minlat
=
element
.
lat
;
// console.log(maxlat,minlat);
}
path
.
push
(
subPath
);
}
return
path
;
return
{
path
,
maxlng
,
minlng
,
maxlat
,
minlat
}
;
}
function
findsubarea
(
res
)
{
let
childrensDistrictList
=
res
.
districtList
[
0
].
districtList
;
...
...
@@ -86,7 +92,7 @@ function findsubarea(res) {
fillColor
:
'black'
,
//填充色
fillOpacity
:
0
,
//填充透明度
map
:
map
,
path
:
bounds2Path
(
result
.
districtList
[
0
].
boundaries
)
path
:
bounds2Path
(
result
.
districtList
[
0
].
boundaries
)
.
path
});
});
}
...
...
@@ -180,4 +186,13 @@ function setPersonalPoint(item) {
Markers
.
push
(
marker
)
// circleMarker.setMap(map)
}
\ No newline at end of file
}
function
dragLimit
(
bounds
)
{
//https://lbs.amap.com/api/javascript-api/example/map/limit-map-show-range/ map.clearLimitBounds(); bounds = map.getBounds(); map.setLimitBounds(bounds);
// var mapBounds = map.getBounds()
// // var mapBounds = new AMap.Bounds(southWest:LngLat, northEast:LngLat)
// console.log(mapBounds);
// var bounds = map.getBounds();
map
.
setLimitBounds
(
bounds
);
}
\ 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