mapxtreme3.0下的最簡單asp代碼

1)使用geoset
 <%
 Const cMapXCourier = "MapInfo.MapXCourier"
 Const cMapXState = "MapX.State.5"
 Const cMapXObject = "MapXObject"
 Const cMapXCourierObject = "MapXCourierObject"

 Set Session(cMapXCourierObject) = Server.CreateObject(cMapXCourier)
 Set Session(cMapXObject) = Session(cMapXCourierObject).GetMapXFromBroker("Anqing", 15000)

 'set session(cMapXObject) = Session(cMapXCourierObject).GetMapXFromNewServer("HelloWorld")
 Session(cMapXObject).ExportMap server.mappath(".")+"/output.gif", 2
 '注意要及時銷燬對象
 Set Session(cMapXObject) = Nothing
 Set Session(cMapXCourierObject) = Nothing
 %>
<img src='output.gif'>

2)不使用geoset,動態創建圖層,生成專題圖
 <%
 Const cMapXCourier = "MapInfo.MapXCourier"
 Const cMapXState = "MapX.State.5"
 Const cMapXObject = "MapXObject"
 Const cMapXCourierObject = "MapXCourierObject"

 Dim objDS
 Dim strDSName
 Dim objLyr

 'Get the map object
 Set Session(cMapXCourierObject) = Server.CreateObject(cMapXCourier)
 set Session(cMapXObject) = Session(cMapXCourierObject).GetMapXFromNewServer("")

 'Add the layer
 Set objLyr = Session(cMapXObject).Layers.Add("Road_Regular.tab")

 'Create the dataset
 strDSName = "Road_RegularDS"
 set objDS = Session(cMapXObject).datasets.add (miDatasetLayer,objLyr,strDSName)

 'add the theme
 objDS.themes.add

 'Center the map
 Session(cMapXObject).Bounds = Session(cMapXObject).Layers.Bounds
 Session(cMapXObject).Title.Visible = false

 'Export the current map to a JPEG which is type 3 and display on the page
 Session(cMapXObject).ExportMap server.mappath(".")+"/output.jpg", 3
 '注意要及時銷燬對象
 Set Session(cMapXObject) = Nothing
 Set Session(cMapXCourierObject) = Nothing
 %>
 <img src='output.jpg'>

 </HTML>

發佈了32 篇原創文章 · 獲贊 0 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章