Public Sub DemoMappoint_BeregnogVisRute( _
ByVal Adresse1 As String, ByVal Adresse2 As String)
' Render
Dim renderService As New RenderServiceSoap
renderService.Credentials = _
DemoMappoint_FindAdresseFindCredentials()
renderService.PreAuthenticate = True
' Route
Dim routeService As New mappoint.RouteServiceSoap
routeService.Credentials = _
DemoMappoint_FindAdresseFindCredentials()
routeService.PreAuthenticate = True
'Route between two locations
Dim startLocation As New Location
Dim endLocation As New Location
startLocation.LatLong = DemoMappoint_FindAdresse(Adresse1). _
FoundLocation.LatLong
endLocation.LatLong = DemoMappoint_FindAdresse(Adresse2). _
FoundLocation.LatLong
Dim routeSegmentsSpec(1) As SegmentSpecification
routeSegmentsSpec(0) = New SegmentSpecification
routeSegmentsSpec(0).Waypoint = New Waypoint
routeSegmentsSpec(0).Waypoint.Name = "Start"
routeSegmentsSpec(0).Waypoint.Location = startLocation
routeSegmentsSpec(1) = New SegmentSpecification
routeSegmentsSpec(1).Waypoint = New Waypoint
routeSegmentsSpec(1).Waypoint.Name = "End"
routeSegmentsSpec(1).Waypoint.Location = endLocation
Dim routeSpec As New RouteSpecification
routeSpec.DataSourceName = "MapPoint.EU"
routeSpec.Segments = routeSegmentsSpec
Dim myRoute As Route = _
routeService.CalculateRoute(routeSpec)
routeSpec = myRoute.Specification
MsgBox("Rute beregnet - km " & _
myRoute.Itinerary.Segments(0).Distance)
MsgBox("Forventet tid " & _
myRoute.Itinerary.Segments(0).DrivingTime \ 60 & " minutter")
' Find kort
Dim myRouteView(0) As ViewByHeightWidth
myRouteView(0) = myRoute.Itinerary.View.ByHeightWidth
Dim mapSpec As New MapSpecification
mapSpec.DataSourceName = "MapPoint.EU"
mapSpec.Route = myRoute
mapSpec.Views = myRouteView
Dim myMaps() As MapImage
myMaps = renderService.GetMap(mapSpec)
' Vis kort
PictureBox1.Image = _
New Bitmap(New System.IO.MemoryStream( _
myMaps(0).MimeData.Bits))
End Sub
Public Sub DemoMappoint_VisKort(ByVal FindAdresse As String)
' Find adresse
Dim Resultat As FindResult = _
DemoMappoint_FindAdresse(FindAdresse)
' Render
Dim renderService As New RenderServiceSoap
renderService.Credentials = _
DemoMappoint_FindAdresseFindCredentials()
renderService.PreAuthenticate = True
' MapView og spec
Dim myViews(0) As ViewByHeightWidth
myViews(0) = _
Resultat.FoundLocation.BestMapView.ByHeightWidth
Dim mapSpec As New MapSpecification
mapSpec.DataSourceName = "MapPoint.EU"
mapSpec.Views = myViews
' Hent kort
Dim mapImages() As MapImage
mapImages = renderService.GetMap(mapSpec)
' Vis kort
PictureBox1.Image = _
New Bitmap(New System.IO.MemoryStream( _
mapImages(0).MimeData.Bits))
End Sub
Public Function DemoMappoint_FindAdresse( _
ByVal FindAdresse As String) As FindResult
' Opret Find-objekt
Dim findService As New FindServiceSoap
findService.Credentials = _
DemoMappoint_FindAdresseFindCredentials()
findService.PreAuthenticate = True
' Find en konkret adresse i EU
Dim Adresse As Address
Adresse = findService.ParseAddress(FindAdresse, "Denmark")
Dim FindAddresseSpec As New FindAddressSpecification
FindAddresseSpec.InputAddress = Adresse
FindAddresseSpec.DataSourceName = "MapPoint.EU"
Dim Resultater As FindResults
Resultater = findService.FindAddress(FindAddresseSpec)
Return Resultater.Results(0)
End Function
Public Function DemoMappoint_FindAdresseFindCredentials() _
As Net.NetworkCredential
Return New System.Net.NetworkCredential("brugernavn", "password")
End Function