이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

Windows Phone 8에 대한 주행 또는 보행 방향을 요청하는 방법

2013-03-11

적용 대상: Windows Phone 8 전용입니다.

 

이 항목에서는 휴대폰에 설치된 다른 앱에서 지정된 대상에 대한 주행 및 보행 방향을 요청하는 앱을 작성하는 방법에 대해 설명합니다. ms-drive-to 또는 ms-walk-to Uri 체계를 사용하여 방향을 요청합니다.

Uri를 사용하여 다른 앱을 실행하는 것에 대한 자세한 내용은 Windows Phone 8의 파일 및 URI 연결을 사용하여 앱 자동 실행을 참조하세요. 방향 요청에 응답하는 앱을 작성하는 방법에 대한 자세한 내용은 Windows Phone 8의 방향 요청에 대해 응답하는 방법을 참조하세요.

다음 스크린샷에서는 사용자가 선택된 대상에 대한 주행 방향을 요청하도록 하는 기본 제공 앱을 보여 줍니다.

An app that uses the ms-drive-to protocol

이 항목에는 다음 단원이 포함되어 있습니다.

 
형식

방향에 대한 요청을 실행할 URI의 형식은 다음과 같습니다.

ms-drive-to:?destination.latitude=<latitude>&destination.longitude=<longitude>&destination.name=<name>

ms-walk-to:?destination.latitude=<latitude>&destination.longitude<longitude>&destination.name=<name>

요청에서 시작 지점은 지정하지 않습니다. 시작 지점은 현재 위치로 가정합니다.

URI나 name 값을 인코딩할 필요는 없습니다.

예제

다음 예제에서는 미국, Washington, Redmond 시에 대한 방향을 요청할 URI를 보여 줍니다.

ms-drive-to:?destination.latitude=47.6451413797194&destination.longitude=-122.141964733601&destination.name=Redmond, WA

ms-walk-to:?destination.latitude=47.6451413797194&destination.longitude=-122.141964733601&destination.name=Redmond, WA

다음 코드 샘플은 휴대폰에 설치된 다른 앱에서 지정된 대상에 대한 주행 방향을 요청하는 방법을 보여 줍니다. 이 예제가 필요한 매개 변수 값을 가져온 후 URI에 어셈블한 다음, LaunchUriAsync 메서드를 통해 URI를 호출합니다.

방향을 요청하려면

  1. Visual Studio 에서 빈 새 Windows Phone 프로젝트를 만듭니다.

  2. 기본 페이지용 코드 숨김 파일에서 다음 메서드를 붙여넣습니다.

            async void RequestDirections()
            {
                // Get the values required to specify the destination.
                string latitude = "47.6451413797194";
                string longitude = "-122.141964733601";
                string name = "Redmond, WA";
    
                // Assemble the Uri to launch.
                Uri uri = new Uri("ms-drive-to:?destination.latitude=" + latitude + 
                    "&destination.longitude=" + longitude + "&destination.name=" + name);
                // The resulting Uri is: "ms-drive-to:?destination.latitude=47.6451413797194
                //  &destination.longitude=-122.141964733601&destination.name=Redmond, WA")
    
                // Launch the Uri.
                var success = await Windows.System.Launcher.LaunchUriAsync(uri);
    
                if (success)
                {
                    // Uri launched.
                }
                else
                {
                    // Uri failed to launch.
                }
            }
    
    
  3. 클래스의 생성자에서, 호출을 RequestDirections 메서드에 추가합니다.

  4. 앱을 실행합니다.

    • 에뮬레이터나 휴대폰에 방향을 제공하는 앱이 없으면, Windows Phone 스토어 에서 앱을 찾으라는 메시지가 표시됩니다.

    • 에뮬레이터나 휴대폰에 방향을 제공하는 앱이 하나만 있으면 이 앱이 자동으로 시작됩니다.

    • 에뮬레이터나 휴대폰에 방향을 제공하는 앱이 여러 개 있으면, 목록에서 앱 하나를 선택하라는 메시지가 표시됩니다.

이 메서드를 테스트하려면

이 정보가 도움이 되었습니까?
(1500자 남음)
© 2013 Microsoft. All rights reserved.