一个在xtreme上添加新图层的坐标设置问题
ruixp 2005-07-12 02:44:13 我在xtreme3.0向导制作的helloworld的基础上修改
想在restorestate里面添加一个新的图层,这个图层的坐标从数据库中的数据换算得到,代码如下
现在遇到一个奇怪的问题,即
'设置坐标系
objMapX.NumericCoordSys.set 0,7,7,0,0,0,0,0,0,0,0,0,objMapX.Bounds
该语句如果没有objMapX.Bounds项,该语句变成
objMapX.NumericCoordSys.set 0,7,7,0,0,0,0,0,0,0,0,0
则坐标设置不起作用,在绘图时使用的是经纬度坐标
'for i=-0.065200847 to 0.065200847 step 0.0001
'pnts_shuiping.AddXY i,-i/10
'next
这个时候如果按照经纬度坐标添加新图层没有问题,坐标也能对上,但是我觉得0,7,7就是表示non earth坐标系,为什么非要加上objMapX.Bounds呢,财产生作用呢?
如果上述语句写全
objMapX.NumericCoordSys.set 0,7,7,0,0,0,0,0,0,0,0,0,objMapX.Bounds
则,可以用自己定义的笛卡尔坐标绘图
for i=-7250 to 7250 step 10
pnts_shuiping.AddXY i,-i/10,i+7250+1
next
但是不知道为什么第一次打开网页的时候不显示(或者好像是只显示中间的一个点),非要在网页上刷新一下,自己画的东西才能显示出来,点击图层控制的update按钮也不管用,
实在不知道是为什么,特此提问?盼高手解答
如果需要贴全部代码,请告知:)
Function RestoreState()
Dim bResult
Dim objMapX
On Error Resume Next
Set objMapX = GetMapEngine()
'设置坐标系
objMapX.NumericCoordSys.set 0,7,7,0,0,0,0,0,0,0,0,0,objMapX.Bounds
'设置距离单位
bResult = SetMapDistanceUnits(miUnitMeter)
dim i
dim zGaodi() '左高低
dim yGaodi() '右高低
dim zGuixiang() '左轨向
dim yGuixiang() '右轨向
dim Guiju() '轨距
dim Shuiping() '水平
dim Sanjiaokeng() '三角坑
dim Shuijia() '水加
dim Chuijia() '垂加
dim Licheng() '里程
'线名 行别 里程 左高低 右高低 左轨向 右轨向 轨距 水平 三角坑 水加 垂加 速度 检测日期
strSql="select 左高低,右高低,左轨向,右轨向,轨距,水平,三角坑,水加,垂加,里程 from GJC_WAVE_NJ2004 where 检测日期='20041115' and 里程 between 975 and 979 order by 里程"
set Rst=server.createobject("adodb.recordset")
Rst.activeconnection="DSN=gwsc;UID=gwsc;PWD=gwsc;"
Rst.source=strSql
Rst.CursorType = 1
Rst.CursorLocation = 3
Rst.LockType = 3
Rst.Open()
recNum=Rst.RecordCount
if recNum>1 then
redim zGaodi(recNum)
redim yGaodi(recNum)
redim zGuixiang(recNum)
redim yGuixiang(recNum)
redim Guiju(recNum)
redim Shuiping(recNum)
redim Sanjiaokeng(recNum)
redim Shuijia(recNum)
redim Chuijia(recNum)
redim Licheng(recNum)
for i=1 to recNum
zGaodi(i)=Rst.fields(0).value
yGaodi(i)=Rst.fields(1).value
zGuixiang(i)=Rst.fields(2).value
yGuixiang(i)=Rst.fields(3).value
Guiju(i)=Rst.fields(4).value
Shuiping(i)=Rst.fields(5).value
Sanjiaokeng(i)=Rst.fields(6).value
Shuijia(i)=Rst.fields(7).value
Chuijia(i)=Rst.fields(8).value
Licheng(i)=Rst.fields(9).value-975
Rst.movenext
next
end if
objMapX.Layers.Remove "水加"
'add a temp layer and add the circle feature to it
objMapX.Layers.CreateLayer "水加", , 1
dim pnts_shuiping
bRC = CreateMapPoints(pnts_shuiping)
for i=-7250 to 7250 step 10
pnts_shuiping.AddXY i,-i/10,i+7250+1
next
'for i=-0.065200847 to 0.065200847 step 0.0001
'pnts_shuiping.AddXY i,-i/10
'next
bRC=DrawPolyLine(pnts_shuiping,5,16711680,"水加")
set pnts_shuiping=nothing
If (StrComp(Request.ServerVariables(cRequestMethod), cPost, vbTextCompare) = 0) Then
Dim objMapXState
' Restore the user's current state
bResult = CreateMapXState()
Set objMapXState = GetMapXState()
objMapXState.Stream = GetHtmlFormField(cHwPreviousMapState)
objMapXState.Restore objMapX
bResult = DestroyMapXState()
Else
' Set the map to the default view
bResult = SetMapSize(GetMapWidth(), GetMapHeight())
bResult = SetMapCenterAndZoomTo(cHwDefaultCenterX, cHwDefaultCenterY, cHwDefaultZoom)
RestoreState = True
End Function
Function DrawPolyLine(pnts,l_width,l_color,layname)
Dim oCircle
Dim oLayer, oFeatures
Dim bRC
'On Error Resume Next
Dim objMapX
Set objMapX = GetMapEngine()
objMapX.Layers(layname).Editable=True
Set oCircle = objMapX.FeatureFactory.CreateLine(pnts)
oCircle.Style.LineWidth = l_width ' Thick border
oCircle.Style.LineColor = l_color ' color
objMapX.Layers(layname).AddFeature oCircle
objMapX.Layers(layname).Visible = true
objMapX.Layers(layname).Selectable = false
objMapX.Layers(layname).Autolabel = False
objMapX.Layers(layname).refresh
objMapX.Feature.Update
DrawPolyLine=true
End Function