C# windows phone应用程序webview不响应地理位置

C# windows phone应用程序webview不响应地理位置,c#,webview,windows-phone-8.1,geolocation,microsoft-appstudio,C#,Webview,Windows Phone 8.1,Geolocation,Microsoft Appstudio,my mainpage.xaml.cs代码 我已在appstudio.windows.com上为windows phone 8.1创建了此web view应用程序,并尝试在visual studio 2015中编辑代码。我希望地理位置应该在webview中集成的网页上工作。手机显示位置图标,但无法检索地理坐标。我已在清单中打开位置功能。谁能告诉我哪里出了问题 任何帮助都能救我。提前谢谢 using System; using Windows.ApplicationModel.Da

my mainpage.xaml.cs代码

我已在appstudio.windows.com上为windows phone 8.1创建了此web view应用程序,并尝试在visual studio 2015中编辑代码。我希望地理位置应该在webview中集成的网页上工作。手机显示位置图标,但无法检索地理坐标。我已在清单中打开位置功能。谁能告诉我哪里出了问题

任何帮助都能救我。提前谢谢

    using System;
    using Windows.ApplicationModel.DataTransfer;
    using Windows.Phone.UI.Input;
    using Windows.UI.ViewManagement;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Navigation;
    using CFORCABSOfficial.ViewModels;
    using CFORCABSOfficial.Wat;
    using Windows.Devices.Geolocation;

   namespace CFORCABSOfficial.Views
   {

    public sealed partial class MainPage : Page
    {
        private MainViewModel _mainViewModel = null;
        private DataTransferManager _transferManager = null;
        private Uri _currentUri = null;

        public MainPage()
        {
            this.InitializeComponent();
            this.NavigationCacheMode = NavigationCacheMode.Required;

            _mainViewModel = _mainViewModel ?? new MainViewModel();
            DataContext = this;
            ApplicationView.GetForCurrentView().
            SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);


            var splash = App.CurrentSplashScreen;
            if (splash != null)
            {
                // Optional: Add a progress ring to your splash screen to show users that content is loading
                PositionRing();
            }

            WatConfig.LoadConfigAsync(this.MainWebView, this.BottomCommandBar);
            this.MainWebView.NavigationCompleted += OnFirstLoadNavigationCompleted;
            HardwareButtons.BackPressed += OnBackPressed;
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            _transferManager = _transferManager ?? DataTransferManager.GetForCurrentView();
            _transferManager.DataRequested += OnDataRequested;
        }

        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            _transferManager.DataRequested -= OnDataRequested;
        }

        private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
        {
            _mainViewModel.GetDataShare(args.Request, _currentUri);
        }

        /// <summary>
        /// Handles back button press.  If app is at the root page of app, don't go back and the
        /// system will suspend the app.
        /// </summary>
        /// <param name="sender">The source of the BackPressed event.</param>
        /// <param name="e">Details for the BackPressed event.</param>
        private void OnBackPressed(object sender, BackPressedEventArgs e)
        {
            var RootFrame = Window.Current.Content as Frame;
            if (RootFrame == null)
            {
                return;
            }
            if (RootFrame.CanGoBack)
            {
                RootFrame.GoBack();
                e.Handled = true;
            }

            if (this.MainWebView.CanGoBack)
            {
                string url = MainWebView.Source.ToString();

                String url2 = "http://windows.xyz.com/member-index.php";
                String url3 = "http://windows.xyz.com/index2.php";
                if ( url != url2) 
                { 
                MainWebView.Navigate(new Uri("http://windows.xyz.com/member-index.php"));
                    e.Handled = true;
               }
if (url == url3)
                { App.Current.Exit(); }
if (url == url2)
                { App.Current.Exit(); }
            }
        }

        #region "ExtendSplashScreen"
        void PositionRing()
        {
            splashProgressRing.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width / 2.2);
            splashProgressRing.SetValue(Canvas.TopProperty, Window.Current.Bounds.Height / 5);
        }
        #endregion

        public MainViewModel MainViewModel
        {
            get { return _mainViewModel; }
        }

        private void OnFirstLoadNavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            this.MainWebView.Visibility = Visibility.Visible;
            this.loadingCanvas.Visibility = Visibility.Collapsed;
            this.BottomAppBar.Visibility = Visibility.Visible;

            this.MainWebView.NavigationCompleted -= OnFirstLoadNavigationCompleted;
            this._currentUri = args.Uri;

            this.MainWebView.NavigationStarting += OnNavigationStarting;
            this.MainWebView.NavigationCompleted += OnNavigationCompleted;

            _transferManager.DataRequested += OnDataRequested;

        }

        private async void OnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
        {
            var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
            await statusBar.ProgressIndicator.ShowAsync();
            Geolocator myGeolocator = new Geolocator();
            {
                Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
                Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
            }
  }


        private async void OnNavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
        {
            this._currentUri = args.Uri;
            var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
            await statusBar.ProgressIndicator.HideAsync();
            // Carry out the operation.

        }
        }
        }
使用系统;
使用Windows.ApplicationModel.DataTransfer;
使用Windows.Phone.UI.Input;
使用Windows.UI.ViewManagement;
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls;
使用Windows.UI.Xaml.Navigation;
使用CForcAbsolutional.ViewModels;
使用CForcAbsolutional.Wat;
使用Windows.Devices.Geolocation;
命名空间CForcAbsolutional.Views
{
公共密封部分类主页面:第页
{
private MainViewModel _MainViewModel=null;
私有数据传输管理器_transferManager=null;
私有Uri _currentUri=null;
公共主页()
{
this.InitializeComponent();
this.NavigationCacheMode=NavigationCacheMode.Required;
_mainViewModel=_mainViewModel??新建mainViewModel();
DataContext=this;
ApplicationView.GetForCurrentView()。
SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
var splash=App.CurrentSplashScreen;
如果(飞溅!=null)
{
//可选:向初始屏幕添加进度环,向用户显示正在加载内容
定位环();
}
WatConfig.LoadConfigAsync(this.MainWebView、this.BottomCommandBar);
this.MainWebView.NavigationCompleted+=OnFirstLoadNavigationCompleted;
HardwareButtons.BackPressed+=ON BackPressed;
}
受保护的覆盖无效OnNavigatedTo(NavigationEventArgs e)
{
基地。导航到(e);
_transferManager=\u transferManager??DataTransferManager.GetForCurrentView();
_transferManager.DataRequested+=OnDataRequested;
}
受保护的覆盖无效OnNavigatedFrom(NavigationEventArgs e)
{
基于(e)的导航;
_transferManager.DataRequested-=OnDataRequested;
}
私有void OnDataRequested(DataTransferManager发送方,DataRequestedEventArgs参数)
{
_mainViewModel.GetDataShare(args.Request,_currentUri);
}
/// 
///处理后退按钮的按下。如果应用程序位于应用程序的根页面,则不要返回,并且
///系统将暂停应用程序。
/// 
///反压事件的源。
///后退事件的详细信息。
反压时的私有无效(对象发送器,反压目标)
{
var RootFrame=Window.Current.Content作为框架;
if(RootFrame==null)
{
返回;
}
if(根框架.CanGoBack)
{
RootFrame.GoBack();
e、 已处理=正确;
}
if(this.MainWebView.CanGoBack)
{
字符串url=MainWebView.Source.ToString();
字符串url2=”http://windows.xyz.com/member-index.php";
字符串url3=”http://windows.xyz.com/index2.php";
如果(url!=url2)
{ 
MainWebView.Navigate(新Uri(“http://windows.xyz.com/member-index.php"));
e、 已处理=正确;
}
如果(url==url3)
{App.Current.Exit();}
如果(url==url2)
{App.Current.Exit();}
}
}
#区域“扩展塑料屏幕”
空环()
{
splashProgressRing.SetValue(Canvas.LeftProperty、Window.Current.Bounds.Width/2.2);
splashProgressRing.SetValue(Canvas.TopProperty,Window.Current.Bounds.Height/5);
}
#端区
公共主视图模型主视图模型
{
获取{return\u mainViewModel;}
}
私有无效OnFirstLoadNavigationCompleted(WebView发件人、WebViewNavigationCompletedEventArgs args args)
{
this.MainWebView.Visibility=可见性.Visible;
this.loadingCanvas.Visibility=Visibility.Collapsed;
this.BottomAppBar.Visibility=Visibility.Visible;
this.MainWebView.NavigationCompleted-=OnFirstLoadNavigationCompleted;
这个。_currentUri=args.Uri;
this.MainWebView.NavigationStarting+=OnNavigationStarting;
this.MainWebView.NavigationCompleted+=OnNavigationCompleted;
_transferManager.DataRequested+=OnDataRequested;
}
私有异步void OnNavigationStarting(WebView发件人、WebViewNavigationStartingEventArgs args args)
{
var statusBar=Windows.UI.ViewManagement.statusBar.GetForCurrentView();
等待statusBar.ProgressIndicator.ShowAsync();
Geolocator myGeolocator=新的Geolocator();
{
Geoposition myGeoposition=等待myGeolocator.GetGeopositionAsync();
Geocoordinate myGeocoordinate=我的地理位置坐标;
}
}
私有异步void OnNavigationCompleted(WebView发件人、WebViewNavigationCompletedEventArgs args args)
{
这个。_currentUri=args.Uri;
var statusBar=Windows.UI.ViewManagement.statusBar.GetForCurrentView();
等待statusBar.ProgressIndicator.HideAsync();
//执行操作。
}
}
}

找到解决方案了吗?