📄 openlayer.mb
字号:
Include "menu.def"
Include "icons.def"
include "mapbasic.def"
Declare Sub openlayer
Sub openlayer
Dim wnd_id As Integer
Dim datapath As string
dim i as integer
dim bflag, m, n, k, l, r, y, x as logical
bflag = true
m = false
n = false
k = false
l = false
r = false
x = false
y = false
onerror goto error_trap
datapath = ApplicationDirectory$()+"\data\"
do case int(CommandInfo(CMD_INFO_MENUITEM)) '根据不同的id打开不同的图层'
case 2000
If NumWindows() = 0 Then
If m = false Then
open table datapath &"BaseMap.TAB" as 底图 Interactive
m = true
End If
Map From 底图
set map window frontwindow() zoom entire
Set window Frontwindow() max
End If
for i = 0 to MapperInfo(Frontwindow(),MAPPER_INFO_LAYERS) '此函数作用返回地图窗口的坐标和距离信息'
if LayerInfo(Frontwindow(),i,LAYER_INFO_NAME) = "底图" then '返回地图窗口中图层的信息'
bflag = false
end if
next
if bflag then
open table datapath & "BaseMap.TAB" as 底图 Interactive
Map From 底图
set map window frontwindow() zoom entire
Set window Frontwindow() max
end if
bflag = true
case 2001
If NumWindows() = 0 Then
'If n = false Then
open table datapath & "B11.tab" as 现状面 Interactive
'n = true
'End If
Map From 现状面
set map window frontwindow() zoom entire
Set window Frontwindow() max
Add Map
Window Frontwindow()
Auto
Layer 现状面
End If
for i = 0 to MapperInfo(Frontwindow(),MAPPER_INFO_LAYERS)
if LayerInfo(Frontwindow(),i,LAYER_INFO_NAME) = "现状面" then
bflag = false
end if
next
if bflag then
Open Table datapath & "B11.tab" as 现状面 Interactive
Add map auto layer 现状面
end if
set map layer 现状面 editable
bflag = true
case 2002
If NumWindows() = 0 Then
' If r = false Then
Open Table datapath & "B12.tab" as 现状线 Interactive
' r = true
' End If
Map From 现状线
set map window frontwindow() zoom entire
Set window Frontwindow() max
Add Map
Window Frontwindow()
Auto
Layer 现状线
End If
for i = 0 to MapperInfo(Frontwindow(),MAPPER_INFO_LAYERS)
if LayerInfo(Frontwindow(),i,LAYER_INFO_NAME) = "现状线" then
bflag = false
end if
next
if bflag then
Open Table datapath & "B12.tab" as 现状线 Interactive
Add map auto layer 现状线
end if
set map layer 现状线 editable
bflag = true
case 2011
If NumWindows() = 0 Then
If k = false Then
open table datapath & "C11.tab" as 权属面 Interactive
k = true
End If
Map From 权属面
set map window frontwindow() zoom entire
Set window Frontwindow() max
Add Map
Window Frontwindow()
Auto
Layer 权属面
End If
for i = 0 to MapperInfo(Frontwindow(),MAPPER_INFO_LAYERS)
if LayerInfo(Frontwindow(),i,LAYER_INFO_NAME) = "权属面" then
bflag = false
end if
next
if bflag then
Open Table datapath & "C11.tab" as 权属面 Interactive
Add map auto layer 权属面
end if
set map layer 权属面 editable
bflag = true
case 2012
If NumWindows() = 0 Then
If l = false Then
open table datapath & "C12.tab" as 权属线 Interactive
l = true
End If
Map From 权属线
set map window frontwindow() zoom entire
Set window Frontwindow() max
Add Map
Window Frontwindow()
Auto
Layer 权属线
End If
for i = 0 to MapperInfo(Frontwindow(),MAPPER_INFO_LAYERS)
if LayerInfo(Frontwindow(),i,LAYER_INFO_NAME) = "权属线" then
bflag = false
end if
next
if bflag then
Open Table datapath & "C12.tab" as 权属线 Interactive
Add map auto layer 权属线
end if
set map layer 权属线 editable
bflag = true
case 2003
If NumWindows() = 0 Then
If x = false Then
open table datapath & "D10.tab" as 注记 Interactive
x = true
End If
Map From 注记
set map window frontwindow() zoom entire
Set window Frontwindow() max
Add Map
Window Frontwindow()
Auto
Layer 注记
End If
for i = 0 to MapperInfo(Frontwindow(),MAPPER_INFO_LAYERS)
if LayerInfo(Frontwindow(),i,LAYER_INFO_NAME) = "注记" then
bflag = false
end if
next
if bflag then
Open Table datapath & "D10.tab" as 注记 Interactive
Add map auto layer 注记
end if
set map layer 注记 editable
bflag = true
case 2031
If NumWindows() = 0 Then
If y = false Then
open table datapath & "D21.tab" as 规划图 Interactive
y = true
End If
Map From 规划图
set map window frontwindow() zoom entire
Set window Frontwindow() max
Add Map
Window Frontwindow()
Auto
Layer 规划图
End If
for i = 0 to MapperInfo(Frontwindow(),MAPPER_INFO_LAYERS)
if LayerInfo(Frontwindow(),i,LAYER_INFO_NAME) = "规划图" then
bflag = false
end if
next
if bflag then
Open Table datapath & "D21.tab" as 规划图 Interactive
Add map auto layer 规划图
end if
set map layer 规划图 editable
bflag = true
end case
done:
exit sub
error_trap:
note error$()
resume done
end sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -