Professional Documents
Culture Documents
mapbasic表操作3
mapbasic表操作3
def"
Include "icons.def"
Include "menu.def"
Sub Main
Note "声明:"+CHR$(10)+"这只是一个演示程序,实现地图交互查
询!"+CHR$(10)+"程序中会有细节性误差,请见谅!"
onerror goto sub_err
Create MENU "文件" AS
"新建" Calling M_FILE_NEW,
"打开……" Calling open,
"关闭" Calling M_FILE_CLOSE ,
"保存" Calling M_FILE_SAVE,
"另存……" Calling M_FILE_SAVE_COPY_AS ,
"(-",
"页面设置" Calling M_FILE_PAGE_SETUP,
"打印……" Calling M_FILE_PRINT,
"(-",
"退出" Calling M_FILE_EXIT
Create MENU "按比例尺查询" AS
"1 比 1 百万" Calling billion1,
"1 比 50 万" Calling semi_billion1
Create MENU "输入查询" AS
"输入 1 比 1 百万图幅号" Calling input_billion,
"输入 1 比 50 万图幅号" Calling input_semibillion
ToolButton
Icon MI_ICON_ZOOM_IN
Calling M_TOOLS_EXPAND
HelpMsg "工具按钮\n 放大"
ToolButton
Icon MI_ICON_ZOOM_OUT
Calling M_TOOLS_SHRINK
HelpMsg "工具按钮\n 缩小"
ToolButton
Icon MI_ICON_ZOOM_QUESTION
HelpMsg "工具按钮\n 问题"
ToolButton
Icon MI_ICON_GRABBER
Calling M_TOOLS_RECENTER
HelpMsg "工具按钮\n 平移"
ToolButton
Icon MI_ICON_INFO
Calling M_TOOLS_PNT_QUERY
HelpMsg "工具按钮\n 信息"
PushButton
Icon MI_ICON_MISC_31
Calling Ye_Button1
HelpMsg "用户开关按钮\n 百万查询"
PushButton
Icon MI_ICON_MAPSYMB_15
Calling Ye_Button2
HelpMsg "用户触发式按钮\n 50 万查询"
Show
sub_err:
note Error$()
exit sub
End Sub
' *************************
' 文件菜单
' *************************
Sub Open
Dim s_filename As String
s_filename = FileOpenDlg(".\1200114","","TAB","Open Table")
If s_filename<>"" Then
Run Menu Command 104
Open Table s_filename As 选择表
Map From 选择表
Else
Note "没有文件被选择"
End If
End Sub
'**********************************
'按钮盒
'**********************************
SUB Ye_buttonpad
CREATE BUTTONPAD "用户按钮" AS
ToolButton
Icon MI_ICON_ARROW_3
Cursor MI_CURSOR_CROSSHAIR
Calling Button_Test
id 1001
HelpMsg "工具按钮\n 工具按钮"
PUSHBUTTON
Icon MI_ICON_HELP
Calling Button_Test
id 1002
HelpMsg "触发式按钮\n 触发式按钮"
ToggleButton
Icon MI_ICON_MAPSYMB_16
Calling Button_Test
id 1003
HelpMsg "开关式按钮\n 开关式按钮"
SHOW
FIXED
End Sub
'' ***************************
'' 按钮盒测试
'' ***************************
SUB Button_Test
onerror goto sub_err
Do Case Int(CommandInfo(CMD_INFO_TOOLBTN))
Case 1001
if numwindows()=0 then
NOTE "工具型按钮盒"+CHR$(10)+"请在地图窗口中使用"
exit sub
ElseIf WindowInfo(FrontWindow(),WIN_INFO_TYPE)<>WIN_MAPPER
then
NOTE "工具型按钮盒"+CHR$(10)+"请在地图窗口中使用"
exit sub
else
note "当前光标位置"+CHR$(10)+"x:"+str$
(CommandInfo(CMD_INFO_X))+
Chr$(10)+"y:"+str$(CommandInfo(CMD_INFO_Y))
end if
Case 1002
Note "触发型按钮盒"
Case 1003
Note "按压型按钮盒"
End Case
exit sub
sub_err:
note Error$()
exit sub
End Sub
Sub Ye_Button1
dim cntrl_val as integer
dialog
title "choosing the way of querying"
position 100,100
width 300
height 150
'Control GroupBox
'Position 10 , 5
'Width 90
'Height 90
'Title "choose the way of querying"
Control radiogroup
title "querying according to the clicking position;
querying according to the longitude and the latitude;querying
according to the province name;querying of inputing the number of map
"
value 1
into cntrl_val
ID 2
position 15,20
'Control ListBox
'Position 15 , 50
'Height 80
'Title From Variable var
'Value 1
'into character
'id 1
'Calling listbox_handler
Control OkButton
Title "OK"
Calling okhandlerb
Control CancelButton
Title "Cancel"
End Sub
Sub okhandlerb
If ReadControlValue(2) = 1 Then
Dialog Remove
Call billion1
'''''''''''' act on user's choice.
End If
If ReadControlValue(2) = 2 Then
Dialog Remove
Call Ye_longitude
End If
If ReadControlValue(2) =3 Then
Dialog Remove
Call Ye_dialog
End If
If ReadControlValue(2) =4 Then
Dialog Remove
Call input_billion
End If
End Sub
'Note "按压型按钮盒"
Sub Ye_Button2
dialog
title "choosing the way of querying"
position 100,100
width 300
height 150
Control radiogroup
title "querying according to the clicking position;
querying according to the longitude and the latitude;querying
according to the province name;querying of inputing the number of map
"
value 1
'into cntrl_val
ID 2
position 15,20
'Control ListBox
'Position 15 , 50
'Height 80
'Title From Variable var
'Value 1
'into character
'id 1
'Calling listbox_handler
Control OkButton
Title "OK"
Calling okhandlerb1
Control CancelButton
Title "Cancel"
end sub
Sub okhandlerb1
If ReadControlValue(2) = 1 Then
Dialog Remove
Call semi_billion1
'''''''''''' act on user's choice.
End If
If ReadControlValue(2) = 2 Then
Dialog Remove
Call Ye_longitude
End If
If ReadControlValue(2) =3 Then
Dialog Remove
Call Ye_dialog
End If
If ReadControlValue(2) =4 Then
Dialog Remove
Call input_semibillion
End If
End Sub
'*********************************
'查询菜单
'*********************************
Sub billion1
Set Map
Layer province
Selectable On
Display Off
call billion
Run Menu Command 1707
end sub
Sub billion
Set Map
Layer customers1
Display Off
'Layer ttt
'Display Off
'Layer sss
'Display Off
Layer customers
Editable On
Selectable On
Display Graphic
dim i,j,x,i1,j1 as Integer
i = 66
j = 16
x = 1
Do While j<53 and x < 200
Do While i<138
create region
1
5(i,j)(i+6,j)(i+6,j+4)(i,j+4)(i,j)
pen makepen(2,2,black)
brush makebrush(1,white,white)
Center ( i+3, j+2 )
i1 = i + 6
j1 = j + 4
dim no, out as string, mid_no as Integer
no = "E31A001001"
mid_no = Mid$(no, 2, 2)
dim m,n,a as Integer
m = i / 6
n = m + mid_no
out = Mid$(no, 1, 1) + n + Mid$(no, 4, 7)
a = m - 10
End Sub
Sub semi_billion1
Set Map
Layer province
Selectable On
Display Off
'Visibility Off
call semi_billion
Run Menu Command 1707
end sub
End Sub
Sub input_billion
dim str_val as string
Dialog Title "input billion dialog" ''' "输入查询对话框"
Control StaticText
Title "Input map NO.:"
Position 5,25
Control EditText
Position 65,25
'Width 15
'Height 5
Value "E42A001001"
Into str_val
position 65,25
Control OkButton
Title "OK"
Control CancelButton
Title "Cancel"
If CommandInfo(CMD_INFO_DLG_OK) Then
Call billion
Select MapNO From customers
Where MapNO = str_val into new
'Open table "new1"
'Open table "china"
'Map From new, china
Map From new
'Add map auto layer china
'Position (0,0)
Width 120 Units "mm" Height 110 Units "mm"
Add map auto layer china
'Set Window FrontWindow() Max ScrollBars Off
Autoscroll On
'Set Map
'CoordSys Earth Projection 1,0
Sub input_semibillion
dim str_val as string
Sub Ye_dialog
Run menu command 1701
Set Map
Layer province
'Selectable On
Display Graphic
'open table "province"
dim cntrl_val as integer
dim var as string
'dim character as object
var = "北京市;天津市;河北省;山西省;内蒙古自治区;辽宁省;吉林省;黑龙江
省;上海市;江苏省;浙江省;安徽省;福建省;江西省;山东省;河南省;湖北省;湖
南省;广东省;广西壮族自治区;海南省;四川省;贵州省;云南省;西藏自治区;陕
西省;甘肃省;青海省;宁夏回族自治区;新疆维吾尔自治区;台湾地区;香港;澳
门"
dialog
title "choosing character_name to query"
position 10,10
width 150
height 150
Control radiogroup
title "1:100,0000;1:50,0000"
value 1
into cntrl_val
ID 2
position 15,20
Control ListBox
Position 15 , 50
Height 40
Title From Variable var
Value 1
'into character
id 1
Calling listbox_handler
Control OkButton
Title "OK"
Calling okhandler
Control CancelButton
Title "Cancel"
End sub
Sub listbox_handler
If CommandInfo(CMD_INFO_DLG_DBL) = TRUE AND ReadControlValue(2) = 1
Then
Dialog Remove
Call go_to_view
'''''''''''' act on user's choice.
Call okhandler
End If
If CommandInfo(CMD_INFO_DLG_DBL) = TRUE AND ReadControlValue(2) = 2
Then
Dialog Remove
Call go_to_view
Call okhandler1
End If
End Sub
End sub
Sub okhandler
call go_to_view
call billion
Select * From customers, province
Where customers.obj Intersects province.obj And
province.Character_Name = character
into ttt
Map From ttt
Width 170 Units "mm" Height 150 Units "mm"
Set Map
Layer ttt
Selectable On
Display Graphic
Label Line None Position Center Font("宋体",1,16,BLACK)
Pen(1,2,0)
With MapNO
Parallel On Auto On Overlap On Duplicates On Offset 2
Visibility On
Layer customers
Display Off
Layer customers1
Display Off
End sub
Sub okhandler1
call go_to_view
call semi_billion
Select * From customers1, province
Where customers1.obj Intersects province.obj And
province.Character_Name = character
into sss
Map From sss
Width 170 Units "mm" Height 150 Units "mm"
sub Ye_about
note "介绍:"+CHR$(10)+"这是一个小的查询程序,在有些细节上仍存在一些
问题,望见谅!"+CHR$(10)+"程序中的图幅编号均为新的图幅编
号。"+CHR$(10)+" 作者:陈婷 "
end sub
SUB Ye_longitude
'dim str_val, str_val1 as string
dim cntrl_val as integer
dialog
title "Input longitude and latitude to query"
position 100,100
width 200
height 150
Control GroupBox
Position 10 , 5 Width 90 Height 50
Title "choose the scale of map"
'Hide
Control radiogroup
Position 15,20
title "1:100,0000;1:50,0000"
value 1
into cntrl_val
ID 2
Control StaticText
Title "Input longitude:"
Position 5,60
Control EditText
Position 5,70
Value "66.00"
Into str_val
Control StaticText
Title "Input latitude:"
Position 90,60
Control EditText
Position 90,70
Value "16.00"
Into str_vala
Control OkButton
Title "OK"
Position 25,95
'Calling okhandler
Control CancelButton
Title "Cancel"
Position 110,95
If CommandInfo(CMD_INFO_DLG_OK) and cntrl_val = 1 Then
call billionl
elseIf CommandInfo(CMD_INFO_DLG_OK) and cntrl_val = 2 Then
call semi_billionl
end if
end sub
SUB billionl
dim long,lat as integer
'dim calu as string
long = str_val \ 1
lat = str_vala \ 1
call billion
Set Map
Layer yyy
Selectable On
Display Graphic
Label Line None Position Center Font("宋体",1,16,BLACK)
Pen(1,2,0)
With MapNO
Parallel On Auto On Overlap On Duplicates On Offset 2
Visibility On
Layer customers
Display Off
Layer customers1
Display Off
end sub
sub semi_billionl
Set Map
Layer aaa
Selectable On
Display Graphic
Label Line None Position Center Font("宋体",1,16,BLACK)
Pen(1,2,0)
With MapNO
Parallel On Auto On Overlap On Duplicates On Offset 2
Visibility On
Layer customers
Display Off
Layer customers1
Display Off
end sub