Add Silverlight Bing Maps Control to Windows Phone 7 application
I know the bits just came out today, but one of the first things I want to do with the newly released Windows Phone 7 SDK is put a map up on the screen and mess around.
I've downloaded the latest version of the Silverlight Maps Control and added the references to my application. As a matter of fact, the VS 2010 design view of the MainPage.xaml shows the map control after adding the namespace and placing the control.
I'm using the provided VS 2010 Express version that comes with the Win Phone 7 SDK and have just used the New Project -> Windows Phone Application template.
When I try to build I get two warnings related to the Microsoft.Maps.MapControl dll's.
Warning 1 The primary reference "Microsoft.Maps.MapControl, Version=1.0.1.0, Culture=neutral, PublicKeyToken=498d0d22d7936b73, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Windows.Browser, Version=2.0.5.0, Culture=neutra开发者_运维百科l, PublicKeyToken=7cec85d7bea7798e" which could not be resolved in the currently targeted framework. "Silverlight,Version=v4.0,Profile=WindowsPhone". To resolve this problem, either remove the reference "Microsoft.Maps.MapControl, Version=1.0.1.0, Culture=neutral, PublicKeyToken=498d0d22d7936b73, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Windows.Browser, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e".
Warning 2 The primary reference "Microsoft.Maps.MapControl.Common, Version=1.0.1.0, Culture=neutral, PublicKeyToken=498d0d22d7936b73, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Windows.Browser, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" which could not be resolved in the currently targeted framework. "Silverlight,Version=v4.0,Profile=WindowsPhone". To resolve this problem, either remove the reference "Microsoft.Maps.MapControl.Common, Version=1.0.1.0, Culture=neutral, PublicKeyToken=498d0d22d7936b73, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Windows.Browser, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e".
I'm leaning towards some way of adding the System.Windows.Browser to the targeted framework version. But I'm not even sure if that is possible.
To be more specific; I'm looking for a way to get the Silverlight Maps Control up on a Windows Phone 7 series application. If possible.
Thanks.
Bing maps control for desktop silverlight is not supported in Windows Phone. You may want to use the BingMapsTask instead.
You're seeing the error because there is no System.Windows.Browser.dll reference for windows phone. If you check the "Add Reference" in Visual Studio 2010 Express, there is no available reference to System.Windows.Browser.dll.
If you add a reference to System.Windows.Browser.dll, usually located in one of the version directories in "C:\Program Files\Microsoft Silverlight" (mine was in C:\Program Files\Microsoft Silverlight\3.0.50106.0), the application will build and you will be able to see the map in the emulator when you run.
The map will move around fine, but the little navigation orb seems to be offset from the corner. Not sure what is going on with that.
There is also a nice write up of getting the map to work at Silverlight Hack
EDIT
As mentioned in other comments. This is probably not going to work on real hardware. But since the real hardware isn't going to be coming out for another 6 months, I figure being able to get something up in the emulator is better than nothing.
You can also look at http://4square.codeplex.com/. It uses the Bing Maps API to pull down map images etc directly, and then work with them in WP7.
精彩评论