我试图在Windows Phone应用程序上使用Bing地图控件,但当我启动地图控件所在的页面时,我收到以下错误:
Failed to create a 'System.Device.Location.GeoCoordinate' from the text '0,0'. [Line: 32 Position: 58]以下是我的XAML,尽管这里没有什么特别之处:
<my:Map Height="224"
HorizontalAlignment="Left"
Margin="7,4,0,0"
Name="map1"
VerticalAlignment="Top"
Width="443"
Loaded="map1_Loaded"
ViewChangeStart="map1_ViewChangeStart">
<my:MapLayer Name="lMain">
<Ellipse Fill="Red" Width="20" Height="20"
my:MapLayer.Position="0,0"
Name="ppLocation"
Visibility="Collapsed" />
</my:MapLayer>
</my:Map>我尝试使用以下代码添加坐标:
GeoCoordinate ld = (Application.Current as App).curentLocation;
Location ppLoc = new Location();
GeoCoordinate g = new GeoCoordinate();
ppLoc.Latitude = ld.Latitude;
ppLoc.Longitude = ld.Longitude;
ppLoc.Altitude = ld.Altitude;
map1.SetView(ppLoc, 10);
//update pushpin location and show
MapLayer.SetPosition(ppLocation, ppLoc);
ppLocation.Visibility = System.Windows.Visibility.Visible;但它在map1.SetView(ppLoc,10)上抛出"NullReferenceExcpetion“;
发布于 2011-09-18 17:55:06
问题出在您为Ellipse设置my:MapLayer.Position="0,0"时。要么根本不应该设置它,要么应该将它设置为有效的坐标。
此外,当您尝试设置map1.SetView(ppLoc, 10);时,您的NullReferenceExcpetion是因为map1为null。
https://stackoverflow.com/questions/7458297
复制相似问题