Pages

Showing posts with label Bing. Show all posts
Showing posts with label Bing. Show all posts

Monday, 15 October 2012

Interacting with Windows 8 Maps app using WindowsMapsHelper library


Windows 8 is shipped with preinstalled Maps application. This app provides all basic mapping features such us showing current location, searching for place or local business and calculating driving directions. Even better, Maps app implements bingmaps protocol to allow 3rd party applications to activate these features. There is just one disadvantage of the protocol: it’s basically a URL string and all numerous parameters need to be properly formatted.

WindowsMapsHelper library aims to simplify communications with Maps app. It encapsulates maps protocol into a few strongly typed classes.

Read More
Source code at GitHub
NuGet Package Here

Saturday, 6 October 2012

Bing Maps SDKs for Windows Store Apps Now Available

Today we are announcing the availability of the Bing Maps SDKs for Windows Store apps. These SDKs will allow you to bring the power of Bing Maps to your Windows Store apps with support for C#, C++, Visual Basic and JavaScript based applications.

Please be aware that this release is the only version (1.1.20120927.0) of Bing Maps which will be supported for apps submitted to the Windows Store. If you are running any prior version (or BETA) you must upgrade and rebuild your app with this build to pass the Windows app Certification Kit (WACK) process. This process is required to submit all apps to the store and checks for the latest version of all dependencies to be approved. In most cases this should be as easy as downloading the latest version of the Bing Maps for Windows Store Apps API and recompiling your app.

Read More

Tuesday, 18 September 2012

How to draw driving route direction with Bing maps in C#/XAML Windows 8 app


How to draw driving route direction with Bing maps in C#/XAML Windows 8 app
In one of my app, I have to give feature of drawing route direction with Bing maps. I found an example in JavaScript, but I want the same in C#/XAML. So Richard Brundritt helped me by providing the Bing Maps REST Service helper class, with that I managed to do it. Here I am posting the code. All REST links URL Templates cam be found here. Thanks to Richard Brundritt :)

protected async override void OnNavigatedTo(NavigationEventArgs e)
{
    Uri geocodeRequest = new Uri("http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.0=28.608280181884766,77.200813293457031&wp.1=19.072799682617188,72.882598876953125&optmz=distance&rpo=Points&key=YOUR_BING_MAP_KEY_HERE"); //Route Ahmedabad to Mumbai

    //Make a request and get the response
    BingMapsRESTService.Response r = await GetResponse(geocodeRequest);

    MapPolyline routeLine = new MapPolyline();
    routeLine.Locations = new LocationCollection();
    routeLine.Color = Colors.Blue;
    routeLine.Width = 5.0;

    int bound = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates.GetUpperBound(0);
    for (int i = 0; i < bound; i++)
    {
        routeLine.Locations.Add(new Location
        {
            Latitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][0],
            Longitude = ((BingMapsRESTService.Route)(r.ResourceSets[0].Resources[0])).RoutePath.Line.Coordinates[i][1]
        });
    }
    MapShapeLayer shapeLayer = new MapShapeLayer();
    shapeLayer.Shapes.Add(routeLine);
    MyMap.ShapeLayers.Add(shapeLayer);
}


private async Task<Response> GetResponse(Uri uri)
{
    System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
    var response = await client.GetAsync(uri);
    using (var stream = await response.Content.ReadAsStreamAsync())
    {
        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Response));
        return ser.ReadObject(stream) as Response;
    }
}


Web Informer Button