Web Map Services


AspMap supports the OpenGIS Web Map Service (WMS) Specification and allows you to handle WMS requests from WMS clients, as well as display maps from online WMS servers.

Displaying maps from online WMS servers

The WmsLayer class allows you to add maps from external WMS servers to the Map control as map layers:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        ' add the UrbanArea layer of the TerraServer WMS service (http://terraserver-usa.com/OgcWms.aspx)
 Dim wms As WmsLayer = New WmsLayer("http://terraserver-usa.com/ogcmap6.ashx", New AspMap.Rectangle(-122.47, 37.87, -122.18, 37.73))

        wms.ImageFormat = ImageFormat.Jpeg

        ' add the WMS layer to the map
 Dim wmsLayer As AspMap.Layer = map.AddLayer(wms)

        ' set the coordinate system of the map to the coordinate system of the TerraServer layer
 map.CoordinateSystem = CoordSystem.WGS1984

        ' make the map image transparent to display background WMS layers
        map.ImageOpacity = 0
End Sub

See the WmsLayerApp sample for a full sample.

Handling WMS requests

The WmsService class lets you turn your ASP.NET mapping application into a WMS server, or create an ASP.NET HTTP handler to serve WMS requests from Web or desktop client applications. The following code demonstrates a simple WMS server implemented as an HTTP handler.


<%@ WebHandler Language="vb" Class="WmsServiceHandler" %>

Imports System
Imports System.Web
Imports System.Web.SessionState
Imports AspMap
Imports AspMap.Web

Public Class WmsServiceHandler Implements IHttpHandler, IRequiresSessionState
        Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
                ' create a WmsService object
                Dim wms As AspMap.Web.WmsService = New AspMap.Web.WmsService()

                ' if the current request is a WMS request, process it
                If wms.IsWmsRequest Then
                        ' create a Map object
                        Dim map As AspMap.Web.Map = New AspMap.Web.Map()

                        ' add a shapefile layer

                        ' process the WMS request using the Map object
                End If

        End Sub

        Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
                        Return False
                End Get
        End Property
End Class

See the WmsServiceApp sample and the WmsService.ashx HTTP handler file for a full sample.





© 2018 VDS Technologies
Converted from CHM to HTML with chm2web Standard 2.85 (unicode)