0

I have one main page with one button that directs my application to another page. When I click the button, the directed page should have gone to the address that I want on the Bing map. But I only see the world map. Here is the code of the second page:

   public BingMapPage()
    {
        InitializeComponent();

        BingMap.Mode = new RoadMode();

        BingMapsTask bmt = new BingMapsTask();

        bmt.SearchTerm = "Paris";
        bmt.Show(); 
    }

The code above only show the world map. However, if I write the same code in the constructor of the main page, it works as it is supposed to. Moreover, I tried to create a method in the second page as below:

public void StartSearch()
    {
        BingMapsTask bmt = new BingMapsTask();

        bmt.SearchTerm = "Paris";
        bmt.Show();        
    }

And then created an instance of my second page in the main page and called this method. It worked again.

My question is that is there a way of get these codes

bmt.SearchTerm = "Paris";
        bmt.Show(); 

working outside of mainpage of an Windows Phone 7 application.

das_tnr
  • 151
  • 1
  • 2
  • 9
  • It looks like you're combining two controls that aren't the same. The Bing Map control (for displaying map content inside your own app) and the BingMapsTask (used for opening the Maps app of Windows Phone) – William Melani Aug 13 '12 at 18:57
  • @ William Melani What should I do ? – das_tnr Aug 13 '12 at 19:53

1 Answers1

0

You cannot set the Searchterm to Paris. Searchterms are general terms like shops, businesses, hospitals etc. You may try an alternative approach. Create a webBrowser control and run the following line of code:

webBrowser.Navigate(new Uri("maps:<your address>"));

This will open the native maps app on the WP7 phone pointing to <your address>. I hope this was what you were looking for.

Milan Aggarwal
  • 5,104
  • 3
  • 25
  • 54