public override void ViewDidLoad() {
            base.ViewDidLoad();
            
            _MainSection = new Section() {
                new ActivityElement()
            };
            Root = new RootElement("Markers") {
                _MainSection
            };

            // Simple demo of a progress HUD. Doesn't actually do anything useful.
            // Added after question from audience.
            MTMBProgressHUD progress = new MTMBProgressHUD() {
                DimBackground = true,
                LabelText = "Doing something.",
            };
            View.Add(progress);
            progress.Show(animated: true);
            Task.Factory.StartNew(() => {
                Thread.Sleep(2000);
                InvokeOnMainThread(() => {
                    progress.Hide(animated: true);
                });
            });

            mapController = new MapViewController();
            mapController.NewMarkerCreated += (object sender, MarkerAddedEventArgs e) => {
                InvokeOnMainThread(() => {
                    _Database.SaveMarker(e.MarkerInfo);
                    RefreshMarkers();
                });
            };
            RefreshMarkers();
        }
    async void AdRGButton_TouchUpInside(object sender, EventArgs e)
    {
        //Get current view controller
        var window = UIApplication.SharedApplication.KeyWindow;
        var vc     = window.RootViewController;

        while (vc.PresentedViewController != null)
        {
            vc = vc.PresentedViewController;
        }


        if (Reachability.IsHostReachable(Settings._baseDomain))
        {
            SpecResponse specResponse = new SpecResponse();

            var specification = await specResponse.GetSpecBySpecIDDesignationIDAsync(ad.SpecId, ad.DesignationId);

            if (specification.SpecId != 0)
            {
                MapViewController mapViewController = (MapViewController)vc.Storyboard.InstantiateViewController("MapViewController");

                mapViewController.SpecFieldList = specification.SpecFieldDictionary[SpecTableViewSource._rangeSection];
                vc.ShowDetailViewController(mapViewController, this);
            }
        }

        else
        {
            HelperMethods.SendBasicAlert("Connect to a Network", Settings._networkProblemMessage);
        }
    }
        public MapViewModel()
        {
            // the map controller is used to avoid using/passing the map control as a property to the MapViewModel
            Controller      = new MapViewController();
            Editor          = new MeasureEditor();
            PortalItem      = ArcGISPortalViewer.ViewModel.AppViewModel.CurrentAppViewModel.SelectedPortalItem;
            IsSidePaneOpen  = false;
            LocationDisplay = new LocationDisplay();
            if (IsInDesignMode)
            {
                IsLoadingWebMap = false;
                IsSidePaneOpen  = true;
                IsAppBarOpen    = true;
            }

            OnBasemapPickedCommand        = new RelayCommand <object>(OnBasemapPicked);
            OnQuerySubmittedCommand       = new RelayCommand <object>(OnQuerySubmitted);
            OnCollapsibleTabOpenedCommand = new RelayCommand <object>(OnCollapsibleTabOpened);
            OnMapTappedCommand            = new RelayCommand <object>(OnMapTapped);

            #region Identify

            OnPopupTappedCommand  = new RelayCommand <object>(OnPopupTapped);
            OnSetViewCommand      = new RelayCommand <object>(OnSetView);
            OnSelectedItemCommand = new RelayCommand <object>(OnSelectedItem);
            OnBackClickCommand    = new RelayCommand <object>(OnBackClick);

            #endregion Identify
        }
Esempio n. 4
0
        public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            var mapViewController = new MapViewController((CLLocationCoordinate2D)DataContext)
            {
                Title = Caption
            };

            dvc.ActivateController(mapViewController, dvc);
        }
Esempio n. 5
0
        public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            var mapViewController = new MapViewController(Value)
            {
                Title = Caption
            };

            dvc.ActivateController(mapViewController, dvc);
        }
        public void SetSelectedDevice()
        {
            RestService restService = new RestService(new HttpClient(fakeDevicesHandler), mockTokenAcquisition,
                                                      mockConfiguration);
            MapViewController mapViewController = new MapViewController(restService);

            ViewResult   result        = (ViewResult)mapViewController.Device("device1").Result;
            MapViewModel resultWrapper = (MapViewModel)result.Model;

            Assert.Equal(2, resultWrapper.LifeCycleManagers.Count(l => l.ConnectionState.Equals("Connected")));
            Assert.Equal("device1", resultWrapper.SelectedDevice.DeviceId);
        }
        public void RetrieveDevicesFromBackend()
        {
            RestService restService = new RestService(new HttpClient(fakeDevicesHandler), mockTokenAcquisition,
                                                      mockConfiguration);
            MapViewController mapViewController = new MapViewController(restService);

            ViewResult   result        = (ViewResult)mapViewController.Index().Result;
            MapViewModel resultWrapper = (MapViewModel)result.Model;

            Assert.Equal(2, resultWrapper.LifeCycleManagers.Count(l => l.ConnectionState.Equals("Connected")));
            Assert.Single(resultWrapper.LifeCycleManagers.Where(l => l.ConnectionState.Equals("Disconnected")));
        }
        public void Selected(DialogViewController controller, UITableView tableView, object item, NSIndexPath path)
        {
            var list = DataContext.Value as IEnumerable <CLLocationCoordinate2D>;

            if (list == null)
            {
                list = new List <CLLocationCoordinate2D>()
                {
                    (CLLocationCoordinate2D)DataContext.Value
                };
            }
            var mapViewController = new MapViewController(list)
            {
                Title = Caption
            };

            controller.ActivateController(mapViewController, controller);
        }
        public void ExceptionWithoutConnection()
        {
            FakeResponseHandler noConnectionHandler = new FakeResponseHandler();

            noConnectionHandler.AddFakeException(
                new Uri($"{ApplicationURLS.Backend}/api/devices"),
                new AggregateException());

            RestService restService = new RestService(new HttpClient(noConnectionHandler), mockTokenAcquisition,
                                                      mockConfiguration);

            MapViewController mapViewController = new MapViewController(restService)
            {
                ControllerContext = new ControllerContext {
                    HttpContext = new DefaultHttpContext()
                }
            };

            Assert.ThrowsAsync <AggregateException>(() => mapViewController.Index());
        }
        public static async Task<IDictionary<Layer, IEnumerable<IdentifyFeature>>> Identify(MapViewController controller, Point tapPoint, MapPoint mapPoint, IEnumerable<Layer> layers = null, double toleranceInPixels = 5)
        {

            if (controller == null)
                throw new ArgumentNullException("controller");
            if (layers == null)
                throw new ArgumentNullException("layers");

            var identifyLayers = LayerCollection.EnumerateLeaves(layers);
            var results = await Task.WhenAll((from l in identifyLayers where l.IsVisible select IdentifyLayer(controller, l, tapPoint, mapPoint)).Where((l => l != null)).ToArray()).ConfigureAwait(false);

            IDictionary<Layer, IEnumerable<IdentifyFeature>> taskResults = null;
            foreach (var result in results)
            {
                if (taskResults == null)
                    taskResults = new Dictionary<Layer, IEnumerable<IdentifyFeature>>();
                if (!taskResults.ContainsKey(result.Key))
                    taskResults.Add(result);
            }

            return taskResults;
        }
Esempio n. 11
0
		public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			var mapViewController = new MapViewController((CLLocationCoordinate2D)DataContext) { Title = Caption };
			dvc.ActivateController(mapViewController, dvc);
		}
Esempio n. 12
0
		public void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
		{
			var mapViewController = new MapViewController(Value) { Title = Caption };
			dvc.ActivateController(mapViewController, dvc);
		}
Esempio n. 13
0
 public void SetCurrentView(MapViewController NewView)
 {
     CurrentView = NewView;
 }
        public MapViewModel()
        {
            // the map controller is used to avoid using/passing the map control as a property to the MapViewModel
            Controller = new MapViewController();
			Editor = new MeasureEditor();
            PortalItem = ArcGISPortalViewer.ViewModel.AppViewModel.CurrentAppViewModel.SelectedPortalItem;
            IsSidePaneOpen = false;
            LocationDisplay = new LocationDisplay();
            if (IsInDesignMode)
            {
                IsLoadingWebMap = false;
                IsSidePaneOpen = true;
                IsAppBarOpen = true;
            }

            OnBasemapPickedCommand = new RelayCommand<object>(OnBasemapPicked);
            OnQuerySubmittedCommand = new RelayCommand<object>(OnQuerySubmitted);
            OnCollapsibleTabOpenedCommand = new RelayCommand<object>(OnCollapsibleTabOpened);
            OnMapTappedCommand = new RelayCommand<object>(OnMapTapped);

            #region Identify

            OnPopupTappedCommand = new RelayCommand<object>(OnPopupTapped);
            OnSetViewCommand = new RelayCommand<object>(OnSetView);
            OnSelectedItemCommand = new RelayCommand<object>(OnSelectedItem);
            OnBackClickCommand = new RelayCommand<object>(OnBackClick);

            #endregion Identify
        }
        private static async Task<KeyValuePair<Layer,IEnumerable<IdentifyFeature>>> IdentifyLayer(MapViewController controller, Layer layer, Point tapPoint, MapPoint mapPoint)
        {
            if (layer is ArcGISDynamicMapServiceLayer)
            {
                var dynamicLayer = ((ArcGISDynamicMapServiceLayer)layer);
                
                if (!dynamicLayer.ServiceInfo.Capabilities.Contains("Query"))                
                    return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, null);
                
                var identifyTask = new IdentifyTask(new Uri(dynamicLayer.ServiceUri, UriKind.Absolute));

				var resolution = controller.UnitsPerPixel;
				var center = controller.Extent.GetCenter();
				var extent = new Envelope(center.X - resolution * c_defaultTolerance, center.Y - resolution * c_defaultTolerance,
					center.X + resolution * c_defaultTolerance, center.Y + resolution * c_defaultTolerance, controller.SpatialReference);
                var identifyParameter = new IdentifyParameters(mapPoint, extent, c_defaultTolerance, c_defaultTolerance,
                    c_defaultTolerance, DisplayInformation.GetForCurrentView().LogicalDpi)
				{
                    LayerOption = LayerOption.Visible,
                    LayerTimeOptions = dynamicLayer.LayerTimeOptions,
                    LayerIDs = dynamicLayer.VisibleLayers,
                    DynamicLayerInfos = dynamicLayer.DynamicLayerInfos,
                    GeodatabaseVersion = dynamicLayer.GeodatabaseVersion,
                    TimeExtent = controller.TimeExtent,
                };
                var identifyItems = (await identifyTask.ExecuteAsync(identifyParameter)).Results;
                var identifyFeatures = new List<IdentifyFeature>();

                try
                {
                    var dict = new Dictionary<int, IReadOnlyList<FieldInfo>>();
                    foreach (var identifyItem in identifyItems)
                    {
                        IReadOnlyList<FieldInfo> fields;
                        if(dict.ContainsKey(identifyItem.LayerID))
                            fields = dict[identifyItem.LayerID];
                        else
                        {
                            fields = await GetFieldInfo(dynamicLayer, identifyItem);                            
                            dict[identifyItem.LayerID] = fields;
                        }                        
                        var identifyFeature = ReplaceAliasWithFieldName(identifyItem, fields);                        
                        identifyFeatures.Add(identifyFeature);
                    }

                }
                catch (Exception ex)
                {
                    
                    throw;
                }
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, identifyFeatures);
            }
            if (layer is ArcGISTiledMapServiceLayer)
            {
                var tiledlayer = ((ArcGISTiledMapServiceLayer) layer);
                if (!tiledlayer.ServiceInfo.Capabilities.Contains("Query"))
                    return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, null);

                var identifyTask = new IdentifyTask(new Uri(tiledlayer.ServiceUri, UriKind.Absolute));
				var resolution = controller.UnitsPerPixel;
				var center = controller.Extent.GetCenter();
				var extent = new Envelope(center.X - resolution * c_defaultTolerance, center.Y - resolution * c_defaultTolerance,
					center.X + resolution * c_defaultTolerance, center.Y + resolution * c_defaultTolerance, controller.SpatialReference);
                var identifyParameter = new IdentifyParameters(mapPoint, extent, c_defaultTolerance, c_defaultTolerance,
                    c_defaultTolerance, DisplayInformation.GetForCurrentView().LogicalDpi)
                {
                    LayerOption = LayerOption.Visible,                    
                    TimeExtent = controller.TimeExtent,
                };

                var identifyItems = (await identifyTask.ExecuteAsync(identifyParameter)).Results;
                
                var identifyFeatures = new List<IdentifyFeature>();
                var dict = new Dictionary<int, IReadOnlyList<FieldInfo>>();
                foreach (var identifyItem in identifyItems)
                {
                    IReadOnlyList<FieldInfo> fields;
                    if (dict.ContainsKey(identifyItem.LayerID))
                        fields = dict[identifyItem.LayerID];
                    else
                    {
                        fields = await GetFieldInfo(tiledlayer, identifyItem);
                        dict[identifyItem.LayerID] = fields;
                    }
                    var identifyFeature = ReplaceAliasWithFieldName(identifyItem, fields);
                    identifyFeatures.Add(identifyFeature);
                }                                           
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, identifyFeatures);
            }
            if (layer is FeatureLayer)
            {
                var featureLayer = ((FeatureLayer)layer);
                var featureIds = await controller.FeatureLayerHitTestAsync(featureLayer, tapPoint, 1000);
                IEnumerable<Feature> features = new List<Feature>();
                if (featureIds != null && featureIds.Any())
                    features = await featureLayer.FeatureTable.QueryAsync(featureIds);

                var schema = featureLayer.FeatureTable.Schema;
                IList<IdentifyFeature> displayFeatures = new List<IdentifyFeature>();
                foreach (var f in features)
                {
                    var objectIDFieldName = schema.Fields.FirstOrDefault(x => x.Type == FieldType.Oid).Name;
                    var objectIDFieldValue = f.Attributes[objectIDFieldName].ToString();
                    IdentifyItem identifyItem = new IdentifyItem(-1, featureLayer.DisplayName, objectIDFieldName, objectIDFieldValue, f);
                    IdentifyFeature identifyFeature = new IdentifyFeature(identifyItem, schema.Fields);
                    displayFeatures.Add(identifyFeature);
                }
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, displayFeatures);
            }
            if (layer is GraphicsLayer)
            {
                var graphicsLayer = ((GraphicsLayer) layer);
                var graphics = await controller.GraphicsLayerHitTestAsync(graphicsLayer, tapPoint, 1000);                
                return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer, graphics.Select(f => new IdentifyFeature(new IdentifyItem(
                    -1, 
                    layer.DisplayName,
                    "",
                    "",
                    f
                    ))));
            }

            // Not supported or not implemented yet
            return new KeyValuePair<Layer, IEnumerable<IdentifyFeature>>(layer,null);
        }