static public void ProcessPositionEvent(IntPtr workItem) { Debug.WriteLine("Calling Geolocation ProcessPositionEvent, workItem is {0}", workItem); UILocationWorkItem wItem = new UILocationWorkItem(workItem); JSPosition position = new JSPosition(new IntPtr(0)); Debug.WriteLine("Calling UIWorkItem getPositionUpdate"); wItem.GetPositionUpdate(ref position.Data); ContentWindow window = mdr.Runtime.Instance.GlobalContext as ContentWindow; Debug.WriteLine("Position update: lat {0} long {1}", position.Data.latitude, position.Data.longitude); Geolocation geo = window.Navigator.Geolocation; if (geo != null) { geo.geoListeners.Dispatch(position); geo.geoWatches.Dispatch(position); if (GeoTrackingEnabled && geo.geoListeners.ListenerCount() == 0 && geo.geoWatches.ListenerCount() == 0) { //Disable Geotracking Debug.WriteLine("Disabling Geo Tracking"); HTMLRuntime.Instance.StopLocationTracking(); GeoTrackingEnabled = false; } } }
static public void ProcessPositionEvent(IntPtr workItem) { Debug.WriteLine("Calling Geolocation ProcessPositionEvent, workItem is {0}", workItem); UILocationWorkItem wItem = new UILocationWorkItem(workItem); JSPosition position = new JSPosition(new IntPtr(0)); Debug.WriteLine("Calling UIWorkItem getPositionUpdate"); wItem.GetPositionUpdate(ref position.Data); ContentWindow window = mdr.Runtime.Instance.GlobalContext as ContentWindow; Debug.WriteLine("Position update: lat {0} long {1}", position.Data.latitude, position.Data.longitude); Geolocation geo = window.Navigator.Geolocation; if (geo != null) { geo.geoListeners.Dispatch(position); geo.geoWatches.Dispatch(position); if (GeoTrackingEnabled && geo.geoListeners.ListenerCount() == 0 && geo.geoWatches.ListenerCount() == 0) { //Disable Geotracking Debug.WriteLine("Disabling Geo Tracking"); HTMLRuntime.Instance.StopLocationTracking(); GeoTrackingEnabled = false; } } }