Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
my-map
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭铭瑶
my-map
Commits
0cee4abd
Commit
0cee4abd
authored
Aug 17, 2021
by
郭铭瑶
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addBoundary(测绘院专属)
parent
66f7f325
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
16 deletions
+85
-16
index.html
index.html
+1
-0
Plugins.min.js
public/shanghaiwuye_gis_map_api_3.2.210421/Plugins.min.js
+2
-0
main.vue
src/components/main.vue
+24
-15
index.ts
src/my-map/ai-map/index.ts
+6
-0
map.d.ts
src/my-map/map.d.ts
+4
-1
my-map.ts
src/my-map/my-map.ts
+8
-0
index.ts
src/my-map/s-map/index.ts
+23
-0
types.ts
src/my-map/types.ts
+17
-0
No files found.
index.html
View file @
0cee4abd
...
...
@@ -11,6 +11,7 @@
<body>
<div
id=
"app"
></div>
<script
src=
"/shanghaiwuye_gis_map_api_3.2.210421/SMap.min.js"
></script>
<script
src=
"/shanghaiwuye_gis_map_api_3.2.210421/Plugins.min.js"
></script>
<link
rel=
'stylesheet'
href=
'https://location-dev.newayz.com/aimap-gl-js/v1.3.10/aimap-gl.css'
/>
<script
src=
"https://location-dev.newayz.com/aimap-gl-js/v1.3.10/aimap-gl.js"
></script>
<script
type=
"module"
src=
"/src/main.ts"
></script>
...
...
public/shanghaiwuye_gis_map_api_3.2.210421/Plugins.min.js
0 → 100644
View file @
0cee4abd
This diff is collapsed.
Click to expand it.
src/components/main.vue
View file @
0cee4abd
...
...
@@ -9,6 +9,7 @@
<div
@
click=
"addLines"
>
Line
</div>
<div
@
click=
"addPolygon"
>
Polygon
</div>
<div
@
click=
"removeLayers"
>
Remove
</div>
<div
@
click=
"addBounday"
>
Boundary
</div>
</div>
</div>
</
template
>
...
...
@@ -22,28 +23,29 @@ let map: MyMap
let
pointsLayer
:
any
let
linesLayer
:
any
let
polygonLayer
:
any
let
boundary
:
any
onMounted
(
async
()
=>
{
await
nextTick
()
// map = MyMap.useMap('SMap').with({
// el: 'container',
// center: [0, 0],
// zoom: 5,
// style: 'smap://styles/dark',
// appKey: 'ACF69EDK17LON63GHPF081',
// netType: 'internet',
// })
map
=
MyMap
.
useMap
(
'AIMap'
).
with
({
map
=
MyMap
.
useMap
(
'SMap'
).
with
({
el
:
'container'
,
center
:
[
121.612846
,
31.205494
],
zoom
:
13
,
style
:
'
aimap://styles/aimap/darkblue-v4
'
,
appKey
:
'
gt8XidVe5upHf7cirkJwwXTCWj20zfu3
'
,
baseApiUrl
:
'https://location-dev.newayz.com
'
,
center
:
[
0
,
0
],
zoom
:
5
,
style
:
'
smap://styles/dark
'
,
appKey
:
'
ACF69EDK17LON63GHPF081
'
,
netType
:
'internet
'
,
})
// map = MyMap.useMap('AIMap').with({
// el: 'container',
// center: [121.612846, 31.205494],
// zoom: 13,
// style: 'aimap://styles/aimap/darkblue-v4',
// appKey: 'gt8XidVe5upHf7cirkJwwXTCWj20zfu3',
// baseApiUrl: 'https://location-dev.newayz.com',
// })
map
.
on
(
'load'
,
addControls
)
.
on
(
'click'
,
(
a
,
b
)
=>
console
.
log
(
a
,
b
))
...
...
@@ -130,10 +132,17 @@ function addPolygon() {
},
})
}
function
addBounday
()
{
boundary
=
map
.
addBoundary
({
name
:
'新江湾'
,
})
}
function
removeLayers
()
{
map
.
remove
(
pointsLayer
)
map
.
remove
(
linesLayer
)
map
.
remove
(
polygonLayer
)
boundary
.
remove
()
}
</
script
>
...
...
src/my-map/ai-map/index.ts
View file @
0cee4abd
...
...
@@ -15,6 +15,7 @@ import {
}
from
'../types'
import
{
toLines
,
toPoints
,
toPolygons
}
from
'./util'
/** 维智地图 */
export
default
class
AI_Map
extends
MyMap
{
private
_clickCb
:
ClickCallBack
|
null
=
null
constructor
(
config
:
MapConfig
<
AIMapConfig
>
)
{
...
...
@@ -163,4 +164,9 @@ export default class AI_Map extends MyMap {
remove
(
layer
:
any
)
{
layer
&&
layer
.
remove
()
}
addBoundary
()
{
console
.
error
(
'此地图不存在 addBoundary 方法'
)
return
{
remove
:
()
=>
null
}
}
}
src/my-map/map.d.ts
View file @
0cee4abd
...
...
@@ -23,7 +23,10 @@ declare const SMap: {
LngLat
:
any
}
declare
const
Plugins
:
{
MaskBoundary
:
any
MaskBoundary
:
new
(
view
:
any
)
=>
{
add
:
(
options
:
any
)
=>
void
remove
:
()
=>
void
}
}
declare
const
aimap
:
{
Map
:
any
...
...
src/my-map/my-map.ts
View file @
0cee4abd
...
...
@@ -8,6 +8,7 @@ import {
Location
,
Layers
,
LayerOption
,
BoundaryOption
,
}
from
'./types'
const
defaultListeners
=
{
...
...
@@ -86,6 +87,7 @@ const defaultLayers = {
point
:
()
=>
console
.
error
(
'add:此地图不存在 point 覆盖物!'
),
line
:
()
=>
console
.
error
(
'add:此地图不存在 line 覆盖物!'
),
polygon
:
()
=>
console
.
error
(
'add:此地图不存在 polygon 覆盖物!'
),
boundary
:
()
=>
console
.
error
(
'add:此地图不存在 boundary 覆盖物!'
),
}
export
default
abstract
class
MyMap
{
...
...
@@ -165,4 +167,10 @@ export default abstract class MyMap {
* @param layer 覆盖物
*/
abstract
remove
(
layer
:
unknown
):
void
/**
* 添加边界
* @param option 配置项
*/
abstract
addBoundary
(
option
:
BoundaryOption
):
{
remove
:
()
=>
void
}
}
src/my-map/s-map/index.ts
View file @
0cee4abd
...
...
@@ -11,9 +11,11 @@ import {
Layers
,
LayerOption
,
ClickCallBack
,
BoundaryOption
,
}
from
'../types'
import
{
toLines
,
toPoints
,
toPolygons
}
from
'./util'
/** 测绘院地图 */
export
default
class
S_Map
extends
MyMap
{
constructor
(
config
:
MapConfig
<
SMapConfig
>
)
{
if
(
!
config
.
netType
)
{
...
...
@@ -181,4 +183,25 @@ export default class S_Map extends MyMap {
remove
(
layer
:
unknown
)
{
layer
&&
this
.
map
.
remove
(
layer
)
}
/** 添加边界 */
addBoundary
({
name
=
''
,
type
=
'jd_boundary'
,
weight
=
10
,
count
=
10
,
color
=
'rgba(51,145,255,.6)'
,
maskColor
=
[
0
,
17
,
33
,
0.9
],
}:
BoundaryOption
)
{
const
boundary
=
new
Plugins
.
MaskBoundary
(
this
.
map
.
view
)
boundary
.
add
({
boundaryType
:
type
,
boundaryDefinition
:
`name like '%
${
name
}
%'`
,
boundarydistance
:
weight
,
bounarycount
:
count
,
boundaryColor
:
color
,
maskColor
:
maskColor
,
})
return
boundary
}
}
src/my-map/types.ts
View file @
0cee4abd
...
...
@@ -227,3 +227,20 @@ export interface LayerOption {
lineJoin
?:
'bevel'
|
'round'
|
'miter'
lineWidth
?:
number
}
/** 边界选项 */
export
interface
BoundaryOption
{
/** 根据type模糊匹配名称 */
name
:
string
/**
* 边界类型
*
* 'jd_boundary' : 街道
*
* 'jwh_boundary' : 南东工作站
*/
type
?:
string
weight
?:
number
count
?:
number
color
?:
string
maskColor
?:
number
[]
}
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