How To Display The Searched Place In Bing Maps Windows Store App JavaScript SDK In Windows Store App

Following are the steps
lets first create a new project and add the Bing maps for javascript reference.

Step 1:
Add the following in the default.html

  
            

Search

            
            Search
            clear
            
    

Step 2:   lets add a new Js file in the Js folder of the project and add the refence in the default.html.
Now  we will add the following code snipet in the Route.js file

var map, placeSearchManager , mapdirectionsManager;
 
                 function Clearprev() {
                           map.entities.clear();
                           if (mapdirectionsManager) {   
                        mapdirectionsManager.resetDirections();  
                       }              
         }
 
 
function Coordinates() {
    Clearprev();
    if (placeSearchManager ) {
        var request = {
            where: document.getElementById('searchId').value,
            count: 1,
            callback: CoordinatesCallback,
            errorCallback: CoordinatesError
        };
        placeSearchManager .Coordinates(request);
    } else {
        //Loading the Search module
        Microsoft.Maps.loadModule('Microsoft.Maps.Search', {
            callback: function ()
    {   
     placeSearchManager = new Microsoft.Maps.Search.SearchManager(map);
                Coordinates();
            }
        });
    }
}
  function CoordinatesCallback(response, data)
 {
    if (response && response.results && response.results.length > 0)
     {
        var loc= response.results[0];
        var locInMap = new Microsoft.Maps.Location( loc.location.latitude, loc.location.longitude);  
       var locPin = new Microsoft.Maps.Pushpin(locInMap );
        map.entities.push(locPin );
        map.setView({ center: locInMap , zoom: 15 });
    }
     else
        {    
          ShowMessage("Co-ordinate responses", "Not results found.");
    }
}
            function CoordinatesError(request) {
    ShowMessage(" Error", "Unable to get the Co-ordinates");
}
 
 
function ShowMessage(title, msg)
{
     var messages = new Windows.UI.Popups.MessageDialog(title, msg);  messages.showAsync();
 }
 
function LoadMap()
 {  
   var mapObject=  {  credentials: "Bing Map Key", mapTypeId: Microsoft.Maps.MapTypeId.road, zoom: 2
    };   
  map = new Microsoft.Maps.Map(document.getElementById("mapViewDiv"), mapObject);
}
(function ()
 {
     function initialize()
 {   
      Microsoft.Maps.loadModule('Microsoft.Maps.Map', { callback: LoadMap });  
     }
    document.addEventListener("DOMContentLoaded", initialize, false); })();

 
In this way we van display the searched place in the map view.

150 150 Burnignorance | Where Minds Meet And Sparks Fly!