| Re: Show lat lon point from text message
Here is some sample code. This will not work in itself but it can be used a reference. Look at MapPoint SDK examples. They are fairly comprehensive.
Public Sub ShowLocationFromGeoCode()
'Create a global object to initialize MapPoint .NET objects
'MapServerWS is the name space of out project. You will something different.
Dim global As MapServerWS.Global = Context.ApplicationInstance
'Create the Location object for the start point
Dim StartLocation As New Location
Dim StartGeoCode As New LatLong
StartGeoCode.Latitude = Request.QueryString("LAT")
StartGeoCode.Longitude = Request.QueryString("LON")
StartLocation.LatLong = StartGeoCode
'Set up the datasource to use
Dim myDataSourceName As String
Dim oUserInfo As New UserInfoRouteHeader
'You can get fancy when determiningthe data source. If your locations are in United States only then use MapPoint.NA
'If Request.QueryString("DS") Is Nothing Then
'myDataSourceName = GetDataSetFromCountry(Request.QueryString("COUNTRY"))
' Else
'myDataSourceName = GetDataSet(Request.QueryString("DS"))
'End If
myDataSourceName = "MapPoint.NA"
Try
'Now get the map
Dim myPushPins(0) As Pushpin
myPushPins(0) = New Pushpin
myPushPins(0).PinID = "DISPLOC"
If Request.QueryString("NAME") = "" Then
myPushPins(0).Label = "Dispatch Location"
Else
myPushPins(0).Label = Request.QueryString("NAME")
End If
myPushPins(0).IconName = "72"
myPushPins(0).IconDataSource = "MapPoint.Icons"
myPushPins(0).LatLong = StartGeoCode
'Set up the map options
Dim myMapOptions As New MapOptions
myMapOptions.ReturnType = MapReturnType.ReturnUrl
myMapOptions.Format = New ImageFormat
myMapOptions.Format.Height = Me.MapImage.Height.Value
myMapOptions.Format.Width = Me.MapImage.Height.Value
'Set up the specification object
Dim myMapViews(0) As ViewByScale
myMapViews(0) = New ViewByScale
myMapViews(0).CenterPoint = StartGeoCode
myMapViews(0).MapScale = 5000
Dim mapSpec As New MapSpecification
mapSpec.Views = myMapViews
mapSpec.Options = myMapOptions
mapSpec.DataSourceName = myDataSourceName
mapSpec.Pushpins = myPushPins
'Declare the map image array and get the map
'RenderServiceClass was initialized in Global.ASAX
'MapImage is app:Image control
Dim myMapImages() As MapImage
myMapImages = global.RenderServiceClass.GetMap(mapSpec)
If myMapImages(0) Is Nothing Then
Me.MapImage.Visible = False
Exit Sub
End If
'*** Cache the map image and then render the map
Cache(Session.SessionID & "_MapImage") = myMapImages(0)
'Set the MapImage url
Me.MapImage.ImageUrl = myMapImages(0).Url
Me.MapImage.Visible = True
'*** Set the driving directions in driving directions text box
Cache(Session.SessionID & "_PushPins") = myPushPins
Catch myException As SoapException
'Catch any errors in the CalculateSimpleRoute request
If myException.Message = cUnauthorized Then
Response.Write("Invalid username or password specified for MS MapPoint Web Service. Please contact your web adminstrator.")
ElseIf (myException.Detail("Type").InnerText = "MapPointUnroutableException") Then
Response.Write("Dispatch location could not be displayed because roads data is not available.")
Else
ErrorProc(Response, myException.Message, myException.StackTrace)
End If
Response.End()
Catch ex As Exception
If ex.Message = cUnauthorized Then
Response.Write("Invalid username or password specified for MS MapPoint Web Service. Please contact your web adminstrator.")
Else
ErrorProc(Response, ex.Message, ex.StackTrace)
End If
Response.End()
End Try
End Sub |