Inquiridor
Bússola para Windows Phone com Mapa..

Pergunta
-
Boa tarde!
Estou enfrentando um problema sério!
Eu desenvolvi uma bússola, o emulador abriu normalmente. Mas, depois, que implementei com mais um Mapa, o emulador não abre. Por quê?!
Aqui estão umas mensagens de erro:
Tem esse erro também:
Aqui está o código-fonte:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using SOrientApp.Resources; using System.Windows.Threading; namespace SOrientApp { public partial class MainPage : PhoneApplicationPage { private Windows.Devices.Sensors.Compass bussola; // Constructor public MainPage() { InitializeComponent(); this.Loaded += MainPage_Loaded; } private void MainPage_Loaded(object sender, RoutedEventArgs e) { IniciarBussola(); } private void IniciarBussola() { try { bussola = Windows.Devices.Sensors.Compass.GetDefault(); if (bussola != null) { bussola.ReportInterval = 20; DispatcherTimer bussolaTimer = new DispatcherTimer(); bussolaTimer.Interval = TimeSpan.FromMilliseconds(20); bussolaTimer.Tick += bussolaTimer_Tick; bussolaTimer.Start(); } } catch (Exception ex) { MessageBox.Show("Ocorreu um erro! Por favor, reiniciar a bússola" + ex.Message); } } void bussolaTimer_Tick(object sender, EventArgs e) { Dispatcher.BeginInvoke(() => { var reading = bussola.GetCurrentReading(); imageAngle.Angle = reading.HeadingMagneticNorth * 1; txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º"; if (imageAngle.Angle == 0 && imageAngle.Angle < 45) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Norte"; } else if (imageAngle.Angle == 45 && imageAngle.Angle < 90) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Nordeste"; } else if (imageAngle.Angle == 90 && imageAngle.Angle < 135) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Leste"; } else if (imageAngle.Angle == 135 && imageAngle.Angle < 180) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Sudeste"; } else if (imageAngle.Angle == 180 && imageAngle.Angle < 225) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Sul"; } else if (imageAngle.Angle == 225 && imageAngle.Angle < 270) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Sudoeste"; } else if (imageAngle.Angle == 270 && imageAngle.Angle < 315) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Oeste"; } else if (imageAngle.Angle > 315 && imageAngle.Angle < 360) { txtBussola.Text = Convert.ToString(imageAngle.Angle) + "º" + " " + "Posição Noroeste"; } }); } private void btMapa_Click(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Uri("/Mapa.xaml", UriKind.Relative)); } } }
Aqui é o código-fonte da tela do Mapa:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Navigation; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using System.Device.Location; namespace SOrientApp { public partial class Mapa : PhoneApplicationPage { public Mapa() { InitializeComponent(); GeoCoordinateWatcher wacther = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); wacther.PositionChanged += wacther_PositionChanged; wacther.Start(); } private void wacther_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { if (!e.Position.Location.IsUnknown) { } else { bingMap.Center = e.Position.Location; bingMap.ZoomLevel = 15; } } } }Estou no aguardo de uma solução.
Boa tarde, e muito obrigado.
Todas as Respostas
-
Boa tarde,
O problema persiste?
Atenciosamente,
Robson William Silva
Esse conteúdo é fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as postagens que resolveram o seu problema. Essa é uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.
-
-