Reverse Geocoding using Bing Map in Windows 8 JavaScript (WinJS) Example

Here is an example of using Bing Map Api to reverse geocode a longitude and latitude to get an address.  I used this while building a Windows 8 JavaScript app. I started off using Google map api but I could not get pass the undefined ‘google’ issue so this a nice work around. It made more sense to go this route since I was already using the Bing Map API.

First step is to add the Bing Maps to your app. To sum up the stepsYou just have to download and add it to your solution then reference it from your default.html.

Reverse Geocode

function getLocation(lat, lng) {
                var location = '';
                var query =  lat + "," +  lng;
                var searchRequest =
                    '' + query + '?o=json&key=' +'Your Bing Key';
                var promise = WinJS.xhr({ url: searchRequest });
                 // Complete function
                 function (response) {
                     var json = JSON.parse(response.responseText);
                     location = json.resourceSets[0].resources[0].name; // address is stored here
                     return location;
                 // Error function
                 function (response) {
                     // handle error here...
                     return location;

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on
Fabulou wholesale Petr Mrazek jersey is back. Best choice to get the wholesale Petr Mrazek jersey is suitable for all style of people.