Gecko for windows forms and geolocation. How to ac

2019-08-05 19:40发布

问题:

My main purpose is get my current geolocation. I've tried to do it with standart control "WebBrowser" but geolocation is not supported by it. So now I'm trying to implement Gecko wrapper https://code.google.com/p/geckofx/ and xulrunner-3.6.28.en-US.win32.sdk (or xulrunner-1.9.2.19.en-US.win32) to windows forms. It perfectly navigate to any url in windows forms. But I've problems to get current geolocation in it. It doesn't give me a window to accept "share my location" as any other browser does. How to do it? in wrapper using GeckoWebBrowser i've not seen any method or property to allow share location. So I think it should be made using xulrunner library. How I can do that? Or if it's very complicated with gecko, what another browser I can use in windows forms to be able to get my current geolocation?

回答1:

You will need to use a newer Geckofx

Also you need to ensure you exactly match the geckofx version with the correct xulrunner/firefox version.

GeoLocation doesn't yet have nice C# wrapper classes around it in geckofx, but you can access it using the xpcom C# interops.

var instance = Xpcom.CreateInstance<nsIGeolocationProvider>("@mozilla.org/geolocation/provider;1");

then look at the api