Search code examples
c#winrt-xamlwindows-rtcomponentone

ComponentOne WinRT finding route on map


I would like to ask how to show routes on my map using WinRT ComponentOne map. I am no able to show map and connect the points together by lines but lines are not following the routes.

enter image description here

It shows only a straight line between points. Does anybody have an idea how to solve this issue? Or if there is any other option how to solve this in Windows 8.1 app, I would appreciate it.

Thanks


Solution

  • Since Component One use Bing maps it would be easier for you use their REST API.

    First you need to get Bing maps key here: https://www.bingmapsportal.com On reference page https://msdn.microsoft.com/en-us/library/ff701717.aspx get corresponding query URL to your problem. On this page are also details to other optional parameters. And then simply use WebRequest to call this URL and in reply you will get response from Bing maps api.

    WebRequest wc = HttpWebRequest.Create(uri);
    try {
       using (HttpWebResponse response = await wc.GetResponseAsync() as HttpWebResponse){
          DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(BingMapsRESTService.Common.JSON.Response));
          return ser.ReadObject(response.GetResponseStream()) as BingMapsRESTService.Common.JSON.Response;
       }
    }
    catch(Exception ex){
       return null;
    }
    

    For more information about this responce see https://msdn.microsoft.com/en-us/library/mt270292.aspx.