/// <summary>Construct Get Image Samples sample control</summary> public GetSamples() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; _mapTip = MyMapView.Overlays.Items.First() as FrameworkElement; MyMapView.LayerLoaded += MyMapView_LayerLoaded; }
/// <summary>Construct Mensuration sample control</summary> public Mensuration() { InitializeComponent(); _pointSymbol = LayoutRoot.Resources["PointSymbol"] as Symbols.Symbol; _lineSymbol = LayoutRoot.Resources["LineSymbol"] as Symbols.Symbol; _polygonSymbol = LayoutRoot.Resources["PolygonSymbol"] as Symbols.Symbol; _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; comboLinearUnit.ItemsSource = typeof(LinearUnits).GetTypeInfo().DeclaredProperties .Select(p => p.GetValue(null, null)) .Except(new LinearUnit[] { LinearUnits.NauticalMiles } ).ToList(); comboLinearUnit.SelectedItem = LinearUnits.Meters; comboAngularUnit.ItemsSource = new AngularUnit[] { AngularUnits.Degrees, AngularUnits.Radians }; comboAngularUnit.SelectedItem = AngularUnits.Degrees; comboAreaUnit.ItemsSource = typeof(AreaUnits).GetTypeInfo().DeclaredProperties .Select(p => p.GetValue(null, null)).ToList(); comboAreaUnit.SelectedItem = AreaUnits.SquareMeters; var imageLayer = MyMapView.Map.Layers["ImageLayer"] as ArcGISTiledMapServiceLayer; _mensurationTask = new MensurationTask(new Uri(imageLayer.ServiceUri)); }
/// <summary>Construct Project sample control</summary> public ProjectCoordinate() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
public CreatePolylines() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.SpatialReferenceChanged += MyMapView_SpatialReferenceChanged; }
private async void LoadLocation() { Windows.Devices.Geolocation.Geoposition l = null; try { var loc = new Windows.Devices.Geolocation.Geolocator(); l = position = await loc.GetGeopositionAsync(); } catch { return; } foreach (var coll in new GraphicsOverlayCollection[] { sceneView.GraphicsOverlays , mapView.GraphicsOverlays }) { GraphicsOverlay overlay = new GraphicsOverlay(); coll.Add(overlay); Graphic g = new Graphic() { Symbol = new SimpleMarkerSymbol() { Color = Color.FromArgb(255, 0, 122, 194), Size = 20, Outline = new SimpleLineSymbol() { Width = 2, Color = Colors.White } }, }; g.Geometry = new MapPoint(l.Coordinate.Point.Position.Longitude, l.Coordinate.Point.Position.Latitude, SpatialReferences.Wgs84); overlay.Graphics.Add(g); break; } }
/// <summary>Construct compute class statistics sample control</summary> public ComputeClassStatistics() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.LayerLoaded += MyMapView_LayerLoaded; }
/// <summary>Construct Offline Geocoding sample control</summary> public OfflineGeocoding() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; SetupRendererSymbols(); }
private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) { Assembly currentAssembly = null; #if WINDOWS_UWP // Get current assembly that contains the image currentAssembly = GetType().GetTypeInfo().Assembly; #else // Get current assembly that contains the image currentAssembly = Assembly.GetExecutingAssembly(); #endif // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy var resourceStream = currentAssembly.GetManifestResourceStream( "ArcGISRuntimeXamarin.Resources.PictureMarkerSymbols.pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); // Create location for the pint MapPoint pinPoint = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic pinGraphic = new Graphic(pinPoint, pinSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(pinGraphic); }
/// <summary>Construct Project sample control</summary> public ProjectCoordinate() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.SpatialReferenceChanged += MyMapView_SpatialReferenceChanged; }
private void CreateOverlay() { // Create polygon builder and add polygon corners into it PolygonBuilder builder = new PolygonBuilder(SpatialReferences.WebMercator); builder.AddPoint(new MapPoint(-20e5, 20e5)); builder.AddPoint(new MapPoint(20e5, 20e5)); builder.AddPoint(new MapPoint(20e5, -20e5)); builder.AddPoint(new MapPoint(-20e5, -20e5)); // Get geometry from the builder Polygon polygonGeometry = builder.ToGeometry(); // Create symbol for the polygon SimpleFillSymbol polygonSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, System.Drawing.Color.Yellow, null); // Create new graphic Graphic polygonGraphic = new Graphic(polygonGeometry, polygonSymbol); // Create overlay to where graphics are shown _polygonOverlay = new GraphicsOverlay(); _polygonOverlay.Graphics.Add(polygonGraphic); // Add created overlay to the MapView _myMapView.GraphicsOverlays.Add(_polygonOverlay); }
public MessageInABottle() { InitializeComponent(); _inputOverlay = MyMapView.GraphicsOverlays["inputOverlay"]; _resultsOverlay = MyMapView.GraphicsOverlays["resultsOverlay"]; }
/// <summary>Construct Geodesic Buffer sample control</summary> public GeodesicBuffer() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; SetupSymbols(); }
/// <summary>Construct Line and Fill Symbols sample control</summary> public LineFillSymbols() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
void mapView1_SpatialReferenceChanged(object sender, EventArgs e) { resultsOverlay = mapView1.GraphicsOverlays["ResultsGraphicsOverlay"] as GraphicsOverlay; statesOverlay = mapView1.GraphicsOverlays["StatesGraphicsOverlay"] as GraphicsOverlay; var x = LoadParcels(); }
public AttributeQuery() { this.InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; InitializeComboBox(); }
/// <summary>Construct Create Polylines sample control</summary> public CreatePolylines() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.NavigationCompleted += MyMapView_NavigationCompleted; }
public AreaSample() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["AreaOverlay"]; MyMapView.SpatialReferenceChanged += MyMapView_SpatialReferenceChanged; }
/// <summary>Construct Line and Fill Symbols sample control</summary> public LineFillSymbols() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.SpatialReferenceChanged += MyMapView_SpatialReferenceChanged; }
private void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateImagery()); // Create initial map location and reuse the location for graphic MapPoint centralLocation = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); Viewpoint initialViewpoint = new Viewpoint(centralLocation, 7500); // Set initial viewpoint myMap.InitialViewpoint = initialViewpoint; // Provide used Map to the MapView _myMapView.Map = myMap; // Create overlay to where graphics are shown GraphicsOverlay overlay = new GraphicsOverlay(); // Add created overlay to the MapView _myMapView.GraphicsOverlays.Add(overlay); // Create a simple marker symbol SimpleMarkerSymbol simpleSymbol = new SimpleMarkerSymbol() { Color = Color.Red, Size = 10, Style = SimpleMarkerSymbolStyle.Circle }; // Add a new graphic with a central point that was created earlier Graphic graphicWithSymbol = new Graphic(centralLocation, simpleSymbol); overlay.Graphics.Add(graphicWithSymbol); }
private async void MyMapView_Loaded(object sender, RoutedEventArgs e) { // ArcGIS Online への参照を取得 var portal = await ArcGISPortal.CreateAsync(new Uri(PORTAL_URL)); // ID を基にアイテムを取得 var item = await ArcGISPortalItem.CreateAsync(portal, "Web マップ ID"); // アイテムを Web マップとして取得 var webmap = await WebMap.FromPortalItemAsync(item); // Web マップを格納するために WebMapViewModel を作成 var vm = await WebMapViewModel.LoadAsync(webmap, portal); // MapView コントロールの Map プロパティに、WebMap を割り当て MyMapView.Map = vm.Map; // グラフィックス オーバーレイが存在しない場合は、新規に追加 if (MyMapView.GraphicsOverlays.Count == 0) { geocodeResultGraphicsOverlay = new GraphicsOverlay() { Renderer = createGeocoordingSymbol(), }; MyMapView.GraphicsOverlays.Add(geocodeResultGraphicsOverlay); } isMapReady = true; }
private async Task AddModelMarkerSymbol() { // Instantiate a new ModelMarkerSymbol ModelMarkerSymbol modelMarkerSymbol = new ModelMarkerSymbol(); // Set the SourceUri property modelMarkerSymbol.SourceUri = Path.Combine(AssemblyDirectory, @"Samples\Scene\PT-Boat-Model\PTBoat.obj"); // Increase the scale to achieve the desired visual size modelMarkerSymbol.Scale = 50; // Create a new MapPoint for the location MapPoint mapPoint = new MapPoint(-155, 19, -100); // Create a new Graphic to display the model symbol Graphic graphic = new Graphic(mapPoint); // Set the Graphic Symbol property graphic.Symbol = modelMarkerSymbol; // Create a GraphicsOverlay to contain the symbolized Graphic GraphicsOverlay graphicsoverlay = new GraphicsOverlay() { RenderingMode = GraphicsRenderingMode.Dynamic, SceneProperties = new LayerSceneProperties() { SurfacePlacement = SurfacePlacement.Relative } }; // Add the Graphic to the GraphicsOverlay graphicsoverlay.Graphics.Add(graphic); // Add the GraphicsOverlay to the MapView's GraphicsOverlays collection MySceneView.GraphicsOverlays.Add(graphicsoverlay); // Set the Viewpoint await MySceneView.SetViewAsync(new Camera(mapPoint.Y - 0.5, mapPoint.X + 0.5, 25000, 315, 70)); }
/// <summary>Construct Unique Value Renderer sample control</summary> public UniqueValueRendererSample() { InitializeComponent(); _states = MyMapView.GraphicsOverlays["states"]; MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
/// <summary>Construct Class Breaks Renderer sample control</summary> public ClassBreaksRendererSample() { InitializeComponent(); _cities = MyMapView.GraphicsOverlays["cities"]; MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
/// <summary>Construct Text Symbols sample control</summary> public TextSymbols() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays[0]; MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
/// <summary>Construct Distance From Geometry sample control</summary> public DistanceFromGeometry() { InitializeComponent(); _lineSymbol = layoutGrid.Resources["LineSymbol"] as Symbol; _pointSymbol = layoutGrid.Resources["PointSymbol"] as Symbol; _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; }
/// <summary>Construct Clip Geometry sample control</summary> public ClipGeometry() { InitializeComponent(); _clipSymbol = layoutGrid.Resources["ClipRectSymbol"] as Symbol; _clippedGraphicsOverlay = MyMapView.GraphicsOverlays["clippedGraphicsOverlay"]; CreateFeatureLayers(); }
/// <summary>Construct Difference sample control</summary> public Difference() { InitializeComponent(); _fillSymbol = layoutGrid.Resources["FillSymbol"] as Symbol; _differenceGraphics = MyMapView.GraphicsOverlays["resultsOverlay"]; CreateFeatureLayers(); }
/// <summary>Construct Statistics sample control</summary> public Statistics() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.NavigationCompleted += MyMapView_NavigationCompleted; }
/// <summary>Construct Geodesic Ellipse sample control</summary> public GeodesicEllipse() { InitializeComponent(); _pinSymbol = layoutGrid.Resources["PointSymbol"] as Symbol; _sectorSymbol = layoutGrid.Resources["SectorSymbol"] as Symbol; _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; }
/// <summary>Construct Simple Renderer sample control</summary> public SimpleRendererSample() { InitializeComponent(); _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
private async void Initialize() { try { // Get the paths to resources used by the sample. string basemapTilePath = DataManager.GetDataFolder("567e14f3420d40c5a206e5c0284cf8fc", "streetmap_SD.tpk"); string networkGeodatabasePath = DataManager.GetDataFolder("567e14f3420d40c5a206e5c0284cf8fc", "sandiego.geodatabase"); // Create the tile cache representing the offline basemap. TileCache tiledBasemapCache = new TileCache(basemapTilePath); // Create a tiled layer to display the offline tiles. ArcGISTiledLayer offlineTiledLayer = new ArcGISTiledLayer(tiledBasemapCache); // Create a basemap based on the tile layer. Basemap offlineBasemap = new Basemap(offlineTiledLayer); // Create a new map with the offline basemap. Map theMap = new Map(offlineBasemap); // Set the initial viewpoint to show the routable area. theMap.InitialViewpoint = new Viewpoint(_routableArea); // Show the map in the map view. _myMapView.Map = theMap; // Create overlays for displaying the stops and the calculated route. _stopsOverlay = new GraphicsOverlay(); _routeOverlay = new GraphicsOverlay(); // Create a symbol and renderer for symbolizing the calculated route. SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Blue, 2); _routeOverlay.Renderer = new SimpleRenderer(routeSymbol); // Add the stops and route overlays to the map. _myMapView.GraphicsOverlays.Add(_stopsOverlay); _myMapView.GraphicsOverlays.Add(_routeOverlay); // Create the route task, referring to the offline geodatabase with the street network. _offlineRouteTask = await RouteTask.CreateAsync(networkGeodatabasePath, "Streets_ND"); // Get the list of available travel modes. _availableTravelModes = _offlineRouteTask.RouteTaskInfo.TravelModes.ToList(); // Update the UI with the travel modes list. foreach (TravelMode mode in _availableTravelModes) { _travelModeSegment.InsertSegment(mode.Name, _travelModeSegment.NumberOfSegments, false); } _travelModeSegment.SelectedSegment = 0; // Create the default parameters. _offlineRouteParameters = await _offlineRouteTask.CreateDefaultParametersAsync(); // Display the extent of the road network on the map. DisplayBoundaryMarker(); // Now that the sample is ready, hook up the tapped and hover events. _sampleReady = true; _myMapView.GeoViewTapped += MapView_Tapped; _travelModeSegment.ValueChanged += TravelMode_SelectionChanged; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); ShowMessage("Couldn't start sample", "There was a problem starting the sample. See debug output for details."); } }
private async void Initialize() { try { // Create the custom location data source and configure the AR scene view to use it. #if XAMARIN_ANDROID bool locationGranted = await MainActivity.Instance.AskForLocationPermission(); if (!locationGranted) { return; } _locationDataSource = new ARLocationDataSource(Android.App.Application.Context); _locationDataSource.AltitudeMode = ARLocationDataSource.AltitudeAdjustmentMode.NmeaParsedMsl; MyARSceneView.LocationDataSource = _locationDataSource; await MyARSceneView.StartTrackingAsync(ARLocationTrackingMode.Continuous); #elif __IOS__ _locationDataSource = new ARLocationDataSource(); MyARSceneView.LocationDataSource = _locationDataSource; #endif // Create the scene and show it. _scene = new Scene(Basemap.CreateImagery()); MyARSceneView.Scene = _scene; // Create and add the elevation surface. _elevationSource = new ArcGISTiledElevationSource(new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); _elevationSurface = new Surface(); _elevationSurface.ElevationSources.Add(_elevationSource); MyARSceneView.Scene.BaseSurface = _elevationSurface; // Hide the surface in AR. _elevationSurface.NavigationConstraint = NavigationConstraint.None; _elevationSurface.Opacity = 0; // Configure the space and atmosphere effects for AR. MyARSceneView.SpaceEffect = SpaceEffect.None; MyARSceneView.AtmosphereEffect = AtmosphereEffect.None; // Add a graphics overlay for displaying points in AR. _graphicsOverlay = new GraphicsOverlay(); _graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; _graphicsOverlay.Renderer = new SimpleRenderer(_tappedPointSymbol); MyARSceneView.GraphicsOverlays.Add(_graphicsOverlay); // Add the exisiting features to the scene. FeatureLayer treeLayer = new FeatureLayer(_featureTable); treeLayer.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MyARSceneView.Scene.OperationalLayers.Add(treeLayer); // Add the event for the user tapping the screen. MyARSceneView.GeoViewTapped += ARViewTapped; // Disable scene interaction. MyARSceneView.InteractionOptions = new SceneViewInteractionOptions() { IsEnabled = false }; // Enable the calibrate button. CalibrateButton.IsEnabled = true; } catch (Exception ex) { Console.WriteLine(ex.Message); await Application.Current.MainPage.DisplayAlert("Error", "Could not create feature", "OK"); } }
/// <summary>Construct Population for Area sample control</summary> public PopulationForArea() { InitializeComponent(); _areaOverlay = MyMapView.GraphicsOverlays["areaOverlay"]; }
async void InitializeMarkers() { // Get MapView from the view and assign map from view-model _mapView = MyMapView; _mapView.Map = myMap; //add nearshore and offshore marine zones that correspond with the marine point forecasts WmsLayer zoneLayerOne = new WmsLayer(new Uri("https://nowcoast.noaa.gov/arcgis/services/nowcoast/forecast_meteoceanhydro_pts_zones_geolinks/MapServer/WMSServer?request=GetCapabilities&service=WMS&version=1.3.0"), layerOne); WmsLayer zoneLayerTwo = new WmsLayer(new Uri("https://nowcoast.noaa.gov/arcgis/services/nowcoast/forecast_meteoceanhydro_pts_zones_geolinks/MapServer/WMSServer?request=GetCapabilities&service=WMS&version=1.3.0"), layerTwo); WmsLayer zoneLayerThree = new WmsLayer(new Uri("https://nowcoast.noaa.gov/arcgis/services/nowcoast/forecast_meteoceanhydro_pts_zones_geolinks/MapServer/WMSServer?request=GetCapabilities&service=WMS&version=1.3.0"), layerThree); myMap.OperationalLayers.Add(zoneLayerOne); myMap.OperationalLayers.Add(zoneLayerTwo); myMap.OperationalLayers.Add(zoneLayerThree); var legendInfo = await zoneLayerTwo.GetLegendInfosAsync(); // Create graphics overlay GraphicsOverlay userClick = new GraphicsOverlay(); GraphicsOverlay userLocationLayer = new GraphicsOverlay(); // Create simple marker symbol for user location SimpleMarkerSymbol userMarker = new SimpleMarkerSymbol() { Color = Color.Red, Size = 10, Style = SimpleMarkerSymbolStyle.Diamond }; //get user location string userLat = ""; string userLon = ""; try { var request = new GeolocationRequest(GeolocationAccuracy.Medium); var userLocation = await Geolocation.GetLocationAsync(request); if (userLocation != null) { userLat = userLocation.Latitude.ToString(); userLon = userLocation.Longitude.ToString(); string userLocationFormatted = userLat + " " + userLon; MapPoint userMapPoint = CoordinateFormatter.FromLatitudeLongitude(userLocationFormatted, SpatialReferences.Wgs84); Graphic userGraphic = new Graphic(userMapPoint, userMarker); userLocationLayer.Graphics.Add(userGraphic); _mapView.GraphicsOverlays.Add(userLocationLayer); } } catch (FeatureNotSupportedException fnsEx) { // Handle not supported on device exception } catch (FeatureNotEnabledException fneEx) { // Handle not enabled on device exception } catch (PermissionException pEx) { // Handle permission exception } catch (Exception ex) { // Unable to get location } // Create simple marker symbol for where the user clicks on the map SimpleMarkerSymbol userClickMarker = new SimpleMarkerSymbol() { Color = Color.Black, Size = 10, Style = SimpleMarkerSymbolStyle.X }; Graphic userClickGraphic = new Graphic(); userClickGraphic.Symbol = userClickMarker; _mapView.GraphicsOverlays.Add(userClick); // add symbol where user has tapped on the map _mapView.GeoViewTapped += (s, e) => { // get rid of any current markers from previous map taps userClick.Graphics.Clear(); Geometry myGeo = GeometryEngine.Project(e.Location, SpatialReferences.Wgs84); MapPoint projection = (MapPoint)myGeo; double latClick = Convert.ToDouble(projection.Y); double lonClick = Convert.ToDouble(projection.X); string location = latClick.ToString() + " " + lonClick.ToString(); MapPoint startingLocation = CoordinateFormatter.FromLatitudeLongitude(location, SpatialReferences.Wgs84); userClickGraphic.Geometry = startingLocation; userClick.Graphics.Add(userClickGraphic); GetWeather(latClick, lonClick); }; }
private async void Initialize() { // As of ArcGIS Enterprise 10.8.1, using utility network functionality requires a licensed user. The following login for the sample server is licensed to perform utility network operations. AuthenticationManager.Current.ChallengeHandler = new ChallengeHandler(async(info) => { try { // WARNING: Never hardcode login information in a production application. This is done solely for the sake of the sample. string sampleServer7User = "******"; string sampleServer7Pass = "******"; return(await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, sampleServer7User, sampleServer7Pass)); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return(null); } }); try { _loadingView.StartAnimating(); // Disable the UI. _categoryButton.Enabled = _traceButton.Enabled = false; // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl)); // Create a map with layers in this utility network. _myMapView.Map = new Map(BasemapStyle.ArcGISStreetsNight); _myMapView.Map.OperationalLayers.Add(new FeatureLayer(new Uri($"{FeatureServiceUrl}/{LineLayerId}"))); _myMapView.Map.OperationalLayers.Add(new FeatureLayer(new Uri($"{FeatureServiceUrl}/{DeviceLayerId}"))); // Get a trace configuration from a tier. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName) ?? throw new ArgumentException(DomainNetworkName); UtilityTier tier = domainNetwork.GetTier(TierName) ?? throw new ArgumentException(TierName); _configuration = tier.TraceConfiguration; // Create a trace filter. _configuration.Filter = new UtilityTraceFilter(); // Get a default starting location. UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(NetworkSourceName) ?? throw new ArgumentException(NetworkSourceName); UtilityAssetGroup assetGroup = networkSource.GetAssetGroup(AssetGroupName) ?? throw new ArgumentException(AssetGroupName); UtilityAssetType assetType = assetGroup.GetAssetType(AssetTypeName) ?? throw new ArgumentException(AssetTypeName); Guid globalId = Guid.Parse(GlobalId); _startingLocation = _utilityNetwork.CreateElement(assetType, globalId); // Create a graphics overlay. GraphicsOverlay overlay = new GraphicsOverlay(); _myMapView.GraphicsOverlays.Add(overlay); // Display starting location. IEnumerable <ArcGISFeature> elementFeatures = await _utilityNetwork.GetFeaturesForElementsAsync(new List <UtilityElement> { _startingLocation }); MapPoint startingLocationGeometry = elementFeatures.FirstOrDefault().Geometry as MapPoint; Symbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.LimeGreen, 25d); Graphic graphic = new Graphic(startingLocationGeometry, symbol); overlay.Graphics.Add(graphic); // Set the starting viewpoint. await _myMapView.SetViewpointAsync(new Viewpoint(startingLocationGeometry, 3000)); // Build the choice list for categories populated with the `Name` property of each `UtilityCategory` in the `UtilityNetworkDefinition`. _selectedCategory = _utilityNetwork.Definition.Categories.First(); _categoryButton.Title = _selectedCategory.Name; // Enable the UI. _categoryButton.Enabled = _traceButton.Enabled = true; } catch (Exception ex) { new UIAlertView(ex.GetType().Name, ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show(); } finally { _loadingView.StopAnimating(); } }
private async void Initialize() { // Create scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { InitialViewpoint = new Viewpoint(_observerPoint, 1000000) }; // Create the elevation source. ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene. myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer. ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene. myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene. // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted. GraphicsOverlay overlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point. SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, Color.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol. _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay. overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene. MySceneView.GraphicsOverlays.Add(overlay); // Add the taxi to the scene. // Create the model symbol for the taxi. ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(DataManager.GetDataFolder("3af5cfec0fd24dac8d88aea679027cb9", "dolmus.3ds"))); // Set the anchor position for the mode; ensures that the model appears above the ground. taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol. _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay. overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building). // Create the analysis. _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives. TargetOffsetZ = 2 }; // Create the analysis overlay. AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay. myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene. MySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi. Windows.UI.Xaml.DispatcherTimer animationTimer = new Windows.UI.Xaml.DispatcherTimer() { Interval = new TimeSpan(0, 0, 0, 0, 60) }; // Move the taxi every time the timer expires. animationTimer.Tick += AnimationTimer_Tick; // Start the timer. animationTimer.Start(); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible. _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view. MySceneView.Scene = myScene; }
private void Initialize() { _viewHeight = HeightSlider.Value; // Create the scene with the imagery basemap. Scene myScene = new Scene(Basemap.CreateImagery()); MySceneView.Scene = myScene; // Add the surface elevation. Surface mySurface = new Surface(); mySurface.ElevationSources.Add(new ArcGISTiledElevationSource(_localElevationImageService)); myScene.BaseSurface = mySurface; // Add the scene layer. ArcGISSceneLayer sceneLayer = new ArcGISSceneLayer(_buildingsUrl); myScene.OperationalLayers.Add(sceneLayer); // Create the MapPoint representing the initial location. MapPoint initialLocation = new MapPoint(-4.5, 48.4, 46 + _viewHeight); // Create the location viewshed analysis. _viewshed = new LocationViewshed( initialLocation, HeadingSlider.Value, PitchSlider.Value, HorizontalAngleSlider.Value, VerticalAngleSlider.Value, MinimumDistanceSlider.Value, MaximumDistanceSlider.Value); // Create a camera based on the initial location. Camera camera = new Camera(initialLocation, 200.0, 20.0, 70.0, 0.0); // Create a symbol for the viewpoint. _viewpointSymbol = SimpleMarkerSceneSymbol.CreateSphere(Color.Blue, 10, SceneSymbolAnchorPosition.Center); // Add the symbol to the viewpoint overlay. _viewpointOverlay = new GraphicsOverlay { SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) }; _viewpointOverlay.Graphics.Add(new Graphic(initialLocation, _viewpointSymbol)); // Apply the camera to the scene view. MySceneView.SetViewpointCamera(camera); // Create an analysis overlay for showing the viewshed analysis. _analysisOverlay = new AnalysisOverlay(); // Add the viewshed analysis to the overlay. _analysisOverlay.Analyses.Add(_viewshed); // Add the analysis overlay to the SceneView. MySceneView.AnalysisOverlays.Add(_analysisOverlay); // Add the graphics overlay MySceneView.GraphicsOverlays.Add(_viewpointOverlay); // Update the frustum outline Color. // The frustum outline shows the volume in which the viewshed analysis is performed. Viewshed.FrustumOutlineColor = Color.Blue; // Subscribe to tap events. This enables the 'pick up' and 'drop' workflow for moving the viewpoint. MySceneView.GeoViewTapped += MySceneViewOnGeoViewTapped; }
private void Initialize() { // Create and show a new map using the WebMercator spatial reference. Map newMap = new Map(SpatialReferences.WebMercator) { // Set the basemap of the map to be a topographic layer. Basemap = new Basemap(BasemapStyle.ArcGISTopographic) }; // Create a graphics overlay to hold the input geometries for the clip operation. _inputGeometriesGraphicsOverlay = new GraphicsOverlay(); // Add the input geometries graphics overlay to the MapView. _myMapView.GraphicsOverlays.Add(_inputGeometriesGraphicsOverlay); // Create a graphics overlay to hold the resulting geometries from the three GeometryEngine.Clip operations. _clipAreasGraphicsOverlay = new GraphicsOverlay(); // Add the resulting geometries graphics overlay to the MapView. _myMapView.GraphicsOverlays.Add(_clipAreasGraphicsOverlay); // Create a simple line symbol for the 1st parameter of the GeometryEngine.Clip operation - it follows the // boundary of Colorado. SimpleLineSymbol coloradoSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Blue, 4); // Create the color that will be used as the fill for the Colorado graphic. It will be a semi-transparent, blue color. System.Drawing.Color coloradoFillColor = System.Drawing.Color.FromArgb(34, 0, 0, 255); // Create the simple fill symbol for the Colorado graphic - comprised of a fill style, fill color and outline. SimpleFillSymbol coloradoSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, coloradoFillColor, coloradoSimpleLineSymbol); // Create the geometry of the Colorado graphic. Envelope colorado = new Envelope( new MapPoint(-11362327.128340, 5012861.290274, SpatialReferences.WebMercator), new MapPoint(-12138232.018408, 4441198.773776, SpatialReferences.WebMercator)); // Create the graphic for Colorado - comprised of a polygon shape and fill symbol. _coloradoGraphic = new Graphic(colorado, coloradoSimpleFillSymbol); // Add the Colorado graphic to the input geometries graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_coloradoGraphic); // Create a simple line symbol for the three different clip geometries. SimpleLineSymbol clipGeometriesLineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Dot, System.Drawing.Color.Red, 5); // Create an envelope outside Colorado. Envelope outsideEnvelope = new Envelope( new MapPoint(-11858344.321294, 5147942.225174, SpatialReferences.WebMercator), new MapPoint(-12201990.219681, 5297071.577304, SpatialReferences.WebMercator) ); // Create the graphic for an envelope outside Colorado - comprised of a polyline shape and line symbol. _outsideGraphic = new Graphic(outsideEnvelope, clipGeometriesLineSymbol); // Add the envelope outside Colorado graphic to the graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_outsideGraphic); // Create an envelope intersecting Colorado. Envelope intersectingEnvelope = new Envelope( new MapPoint(-11962086.479298, 4566553.881363, SpatialReferences.WebMercator), new MapPoint(-12260345.183558, 4332053.378376, SpatialReferences.WebMercator) ); // Create the graphic for an envelope intersecting Colorado - comprised of a polyline shape and line symbol. _intersectingGraphic = new Graphic(intersectingEnvelope, clipGeometriesLineSymbol); // Add the envelope intersecting Colorado graphic to the graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_intersectingGraphic); // Create a envelope inside Colorado. Envelope containedEnvelope = new Envelope( new MapPoint(-11655182.595204, 4741618.772994, SpatialReferences.WebMercator), new MapPoint(-11431488.567009, 4593570.068343, SpatialReferences.WebMercator) ); // Create the graphic for an envelope inside Colorado - comprised of a polyline shape and line symbol. _containedGraphic = new Graphic(containedEnvelope, clipGeometriesLineSymbol); // Add the envelope inside Colorado graphic to the graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_containedGraphic); // Get the extent of all of the graphics in the graphics overlay with a little padding to used as the initial zoom extent of the map. Geometry visibleExtent = GetExtentOfGraphicsOverlay(_inputGeometriesGraphicsOverlay, 1.3, SpatialReferences.WebMercator); // Set the initial visual extent of the map view to the extent of the graphics overlay. newMap.InitialViewpoint = new Viewpoint(visibleExtent); // Assign the map to the MapView. _myMapView.Map = newMap; }
/// <summary> /// Runs a search and populates the map with results based on the provided information /// </summary> /// <param name="enteredText">Results to search for</param> /// <param name="locationText">Location around which to find results</param> /// <param name="restrictToExtent">If true, limits results to only those that are within the current extent</param> private async void UpdateSearch(string enteredText, string locationText, bool restrictToExtent = false) { // Clear any existing markers _myMapView.GraphicsOverlays.Clear(); // Return gracefully if the textbox is empty or the geocoder isn't ready if (string.IsNullOrWhiteSpace(enteredText) || _geocoder == null) { return; } // Create the geocode parameters GeocodeParameters parameters = new GeocodeParameters(); // Get the MapPoint for the current search location MapPoint searchLocation = await GetSearchMapPoint(locationText); // Update the geocode parameters if the map point is not null if (searchLocation != null) { parameters.PreferredSearchLocation = searchLocation; } // Update the search area if desired if (restrictToExtent) { // Get the current map extent Geometry extent = _myMapView.VisibleArea; // Update the search parameters parameters.SearchArea = extent; } // Show the progress bar _myProgressBar.StartAnimating(); // Get the location information IReadOnlyList <GeocodeResult> locations = await _geocoder.GeocodeAsync(enteredText, parameters); // Stop gracefully and show a message if the geocoder does not return a result if (locations.Count < 1) { _myProgressBar.StopAnimating(); // 1. Hide the progress bar ShowStatusMessage("No results found"); // 2. Show a message return; // 3. Stop } // Create the GraphicsOverlay so that results can be drawn on the map GraphicsOverlay resultOverlay = new GraphicsOverlay(); // Add each address to the map foreach (GeocodeResult location in locations) { // Get the Graphic to display Graphic point = await GraphicForPoint(location.DisplayLocation); // Add the specific result data to the point point.Attributes["Match_Title"] = location.Label; // Get the address for the point IReadOnlyList <GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(location.DisplayLocation); // Add the first suitable address if possible if (addresses.Count() > 0) { point.Attributes["Match_Address"] = addresses.First().Label; } // Add the Graphic to the GraphicsOverlay resultOverlay.Graphics.Add(point); } // Hide the progress bar _myProgressBar.StopAnimating(); // Add the GraphicsOverlay to the MapView _myMapView.GraphicsOverlays.Add(resultOverlay); // Create a viewpoint for the extent containing all graphics Viewpoint viewExtent = new Viewpoint(resultOverlay.Extent); // Update the map viewpoint _myMapView.SetViewpoint(viewExtent); }
private async void Initialize() { // Hook up the DrawStatusChanged event. MyMapView.DrawStatusChanged += OnDrawStatusChanged; // Construct the map and set the MapView.Map property. Map map = new Map(Basemap.CreateLightGrayCanvasVector()); MyMapView.Map = map; try { // Create a ClosestFacilityTask using the San Diego Uri. _task = await ClosestFacilityTask.CreateAsync(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/ClosestFacility")); // List of facilities to be placed around San Diego area. _facilities = new List <Facility> { new Facility(new MapPoint(-1.3042129900625112E7, 3860127.9479775648, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3042193400557665E7, 3862448.873041752, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3046882875518233E7, 3862704.9896770366, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3040539754780494E7, 3862924.5938606677, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3042571225655518E7, 3858981.773018156, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3039784633928463E7, 3856692.5980474586, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3049023883956768E7, 3861993.789732541, SpatialReferences.WebMercator)) }; // Center the map on the San Diego facilities. Envelope fullExtent = GeometryEngine.CombineExtents(_facilities.Select(facility => facility.Geometry)); await MyMapView.SetViewpointGeometryAsync(fullExtent, 50); // Create a symbol for displaying facilities. _facilitySymbol = new PictureMarkerSymbol(new Uri("https://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png")) { Height = 30, Width = 30 }; // Incident symbol. _incidentSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.FromArgb(255, 0, 0, 0), 30); // Route to hospital symbol. _routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(255, 0, 0, 255), 5.0f); // Create Graphics Overlays for incidents and facilities. _incidentGraphicsOverlay = new GraphicsOverlay(); _facilityGraphicsOverlay = new GraphicsOverlay(); // Create a graphic and add to graphics overlay for each facility. foreach (Facility facility in _facilities) { _facilityGraphicsOverlay.Graphics.Add(new Graphic(facility.Geometry, _facilitySymbol)); } // Add each graphics overlay to MyMapView. MyMapView.GraphicsOverlays.Add(_incidentGraphicsOverlay); MyMapView.GraphicsOverlays.Add(_facilityGraphicsOverlay); } catch (Exception e) { await new MessageDialog2(e.ToString(), "Error").ShowAsync(); } }
private void Initialize() { // Create new scene with imagery basemap. Scene scene = new Scene(Basemap.CreateImagery()); // Create a camera with coordinates showing layer data. Camera camera = new Camera(53.04, -4.04, 1300, 0, 90.0, 0); // Assign the Scene to the SceneView. _mySceneView.Scene = scene; // Create ElevationSource from elevation data Uri. ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource( new Uri("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // Add elevationSource to BaseSurface's ElevationSources. _mySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); // Set view point of scene view using camera. _mySceneView.SetViewpointCameraAsync(camera); // Create overlays with elevation modes. _drapedBillboardedOverlay = new GraphicsOverlay(); _drapedBillboardedOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedBillboarded; _mySceneView.GraphicsOverlays.Add(_drapedBillboardedOverlay); _drapedFlatOverlay = new GraphicsOverlay(); _drapedFlatOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.DrapedFlat; GraphicsOverlay relativeOverlay = new GraphicsOverlay(); relativeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; _mySceneView.GraphicsOverlays.Add(relativeOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay(); absoluteOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; _mySceneView.GraphicsOverlays.Add(absoluteOverlay); // Create point for graphic location. MapPoint point = new MapPoint(-4.04, 53.06, 1000, camera.Location.SpatialReference); // Create a red triangle symbol SimpleMarkerSymbol triangleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.FromArgb(255, 255, 0, 0), 10); // Create a text symbol for each elevation mode TextSymbol drapedBillboardedText = new TextSymbol("DRAPED BILLBOARDED", Color.FromArgb(255, 255, 255, 255), 10, HorizontalAlignment.Center, VerticalAlignment.Middle); drapedBillboardedText.OffsetY += 20; TextSymbol drapedFlatText = new TextSymbol("DRAPED FLAT", Color.FromArgb(255, 255, 255, 255), 10, HorizontalAlignment.Center, VerticalAlignment.Middle); drapedFlatText.OffsetY += 20; TextSymbol relativeText = new TextSymbol("RELATIVE", Color.FromArgb(255, 255, 255, 255), 10, HorizontalAlignment.Center, VerticalAlignment.Middle); relativeText.OffsetY += 20; TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Color.FromArgb(255, 255, 255, 255), 10, HorizontalAlignment.Center, VerticalAlignment.Middle); absoluteText.OffsetY += 20; // Add the point graphic and text graphic to the corresponding graphics overlay _drapedBillboardedOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); _drapedBillboardedOverlay.Graphics.Add(new Graphic(point, drapedBillboardedText)); _drapedFlatOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); _drapedFlatOverlay.Graphics.Add(new Graphic(point, drapedFlatText)); relativeOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); relativeOverlay.Graphics.Add(new Graphic(point, relativeText)); absoluteOverlay.Graphics.Add(new Graphic(point, triangleSymbol)); absoluteOverlay.Graphics.Add(new Graphic(point, absoluteText)); }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk. TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(sfBasemap); // Assign the map to the MapView. myMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. myMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. myMapView.ViewpointChanged += MapViewExtentChanged; // Set up event handler for mapview taps. myMapView.GeoViewTapped += GeoViewTapped; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the Uri for this particular layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - in case user doesn't interact with the map. UpdateMapExtent(); // Enable the generate button now that the sample is ready. myGenerateButton.Enabled = true; }
private async void Initialize() { // Apply appropriate maps to the scene and the inset map view. _insetMapView.Map = new Map(Basemap.CreateImagery()); _insetMapView.IsAttributionTextVisible = false; _mySceneView.Scene = new Scene(Basemap.CreateImagery()); // Apply the elevation source. Surface surface = new Surface(); ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl); surface.ElevationSources.Add(elevationSource); _mySceneView.Scene.BaseSurface = surface; // Create and add the graphics overlay. GraphicsOverlay sceneOverlay = new GraphicsOverlay { SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute } }; _mySceneView.GraphicsOverlays.Add(sceneOverlay); // Create a renderer to handle updating plane's orientation. SimpleRenderer renderer3D = new SimpleRenderer(); RendererSceneProperties renderProperties = renderer3D.SceneProperties; // Use expressions to keep the renderer properties updated as parameters of the rendered object. renderProperties.HeadingExpression = "[HEADING]"; renderProperties.PitchExpression = "[PITCH]"; renderProperties.RollExpression = "[ROLL]"; // Apply the renderer to the scene view's overlay. sceneOverlay.Renderer = renderer3D; // Create renderer to symbolize plane and update plane orientation in the inset map. SimpleRenderer renderer2D = new SimpleRenderer { Symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.Blue, 10), RotationExpression = "[ANGLE]" }; // Update the inset map with a new GraphicsOverlay based on the renderer. GraphicsOverlay insetMapOverlay = new GraphicsOverlay { Renderer = renderer2D }; _insetMapView.GraphicsOverlays.Add(insetMapOverlay); // Create placeholder graphic for showing the mission route in the inset map. SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); _routeGraphic = new Graphic { Symbol = routeSymbol }; insetMapOverlay.Graphics.Add(_routeGraphic); // Create the plane graphic; this is symbolized as a blue triangle because of renderer implemented above. Dictionary <string, object> plane2DAttributes = new Dictionary <string, object> { // Set the angle for the plane graphic. ["ANGLE"] = 0f }; // Create the graphic from the attributes and the initial point. _plane2D = new Graphic(new MapPoint(0, 0, SpatialReferences.Wgs84), plane2DAttributes); // Add the plane graphic to the inset map via the overlay. insetMapOverlay.Graphics.Add(_plane2D); // Create the model graphic for the plane. string modelPath = DataManager.GetDataFolder("681d6f7694644709a7c830ec57a2d72b", "Bristol.dae"); // Create the scene symbol from the path to the model. ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0); // Create the graphic with an initial location and the plane symbol. _plane3D = new Graphic(new MapPoint(0, 0, 0, SpatialReferences.Wgs84), plane3DSymbol); // Add the plane to the overlay. sceneOverlay.Graphics.Add(_plane3D); // Create the orbit camera controller to follow the plane. _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 20.0) { CameraPitchOffset = 75.0 }; _mySceneView.CameraController = _orbitCameraController; // Create a timer; this animates the plane. // The value is the duration of the timer in milliseconds. This controls the speed of the animation (fps). _animationTimer = new Timer(60) { AutoReset = true }; // Call the animation method every time the timer expires (once every 60ms per above). _animationTimer.Elapsed += (sender, args) => AnimatePlane(); // Set the initial mission for when the sample loads. await ChangeMission(_missionToItemId.Keys.First()); }
private async void Initialize() { try { BusyIndicator.IsVisible = true; Status.Text = "Loading Utility Network..."; // Setup Map with Feature Layer(s) that contain Utility Network. MyMapView.Map = new Map(Basemap.CreateStreetsNightVector()) { InitialViewpoint = _startingViewpoint }; // Add the layer with electric distribution lines. FeatureLayer lineLayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/115")); UniqueValue mediumVoltageValue = new UniqueValue("N/A", "Medium Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3), 5); UniqueValue lowVoltageValue = new UniqueValue("N/A", "Low Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.DarkCyan, 3), 3); lineLayer.Renderer = new UniqueValueRenderer(new List <string>() { "ASSETGROUP" }, new List <UniqueValue>() { mediumVoltageValue, lowVoltageValue }, "", new SimpleLineSymbol()); MyMapView.Map.OperationalLayers.Add(lineLayer); // Add the layer with electric devices. FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/100")); MyMapView.Map.OperationalLayers.Add(electricDevicelayer); // Set the selection color for features in the map view. MyMapView.SelectionProperties = new SelectionProperties(System.Drawing.Color.Yellow); // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), MyMapView.Map); // Get the utility tier used for traces in this network. For this data set, the "Medium Voltage Radial" tier from the "ElectricDistribution" domain network is used. UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork("ElectricDistribution"); _mediumVoltageTier = domainNetwork.GetTier("Medium Voltage Radial"); // More complex datasets may require using utility trace configurations from different tiers. The following LINQ expression gets all tiers present in the utility network. //IEnumerable<UtilityTier> tiers = _utilityNetwork.Definition.DomainNetworks.Select(domain => domain.Tiers).SelectMany(tier => tier); // Create symbols for starting locations and barriers. _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.LightGreen, 25d); _barrierPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.OrangeRed, 25d); // Create a graphics overlay. GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(graphicsOverlay); // Set the instruction text. Status.Text = "Click on the network lines or points to add a utility element."; } catch (Exception ex) { Status.Text = "Loading Utility Network failed..."; await Application.Current.MainPage.DisplayAlert(ex.GetType().Name, ex.Message, "OK"); } finally { MainUI.IsEnabled = true; BusyIndicator.IsVisible = false; } }
/// <summary>Construct Spatial Query sample control</summary> public QueryRelatedTables() { InitializeComponent(); _wellsOverlay = MyMapView.GraphicsOverlays["wellsOverlay"]; }
private async void Initialize() { // Create a scene. Scene myScene = new Scene(Basemap.CreateImageryWithLabels()); // Create a surface for elevation data. Surface surface = new Surface(); surface.ElevationSources.Add(new ArcGISTiledElevationSource(_elevationUri)); // Add the surface to the scene. myScene.BaseSurface = surface; // Create a graphics overlay for the scene. GraphicsOverlay sceneGraphicsOverlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) }; MySceneView.GraphicsOverlays.Add(sceneGraphicsOverlay); // Location at the crater. MapPoint craterLocation = new MapPoint(-109.929589, 38.437304, 1700, SpatialReferences.Wgs84); // Create the plane symbol and make it 10x larger (to be the right size relative to the scene). ModelSceneSymbol planeSymbol; try { planeSymbol = await ModelSceneSymbol.CreateAsync(_modelUri, 10.0); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); await new MessageDialog("Loading plane model failed. Sample failed to initialize.", "Sample error").ShowAsync(); return; } // Create a graphic using the plane symbol. Graphic planeGraphic = new Graphic(new MapPoint(craterLocation.X, craterLocation.Y, 5000.0, SpatialReferences.Wgs84), planeSymbol); sceneGraphicsOverlay.Graphics.Add(planeGraphic); // Instantiate a new camera controller which orbits a geo element. _orbitPlaneCameraController = new OrbitGeoElementCameraController(planeGraphic, 300.0) { CameraPitchOffset = 30, CameraHeadingOffset = 150 }; // Instantiate a new camera controller which orbits a location. _orbitCraterCameraController = new OrbitLocationCameraController(craterLocation, 6000.0) { CameraPitchOffset = 3, CameraHeadingOffset = 150 }; // Set the starting camera controller. MySceneView.CameraController = _orbitPlaneCameraController; // Enable all of the radio buttons. OrbitPlaneButton.IsEnabled = true; OrbitCraterButton.IsEnabled = true; FreePanButton.IsEnabled = true; // Add the scene to the view. MySceneView.Scene = myScene; }
private async void Initialize() { // Apply appropriate maps to the scene and the inset map view InsetMapView.Map = new Map(Basemap.CreateImagery()); MySceneView.Scene = new Scene(Basemap.CreateImagery()); // Update the mission selection UI MissionSelectionBox.ItemsSource = _missionToItemId.Keys; MissionSelectionBox.SelectedIndex = 0; // Wire up the selection change event to call the ChangeMission method; this method resets the animation and starts a new mission MissionSelectionBox.SelectionChanged += async(sender, args) => { await ChangeMission(args.AddedItems[0].ToString()); }; // Apply the elevation source Surface surface = new Surface(); ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl); surface.ElevationSources.Add(elevationSource); MySceneView.Scene.BaseSurface = surface; // Create and add the graphics overlay GraphicsOverlay sceneOverlay = new GraphicsOverlay { SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute } }; MySceneView.GraphicsOverlays.Add(sceneOverlay); // Create a renderer to handle updating plane's orientation SimpleRenderer renderer3D = new SimpleRenderer(); RendererSceneProperties renderProperties = renderer3D.SceneProperties; // Use expressions to keep the renderer properties updated as parameters of the rendered object renderProperties.HeadingExpression = "[HEADING]"; renderProperties.PitchExpression = "[PITCH]"; renderProperties.RollExpression = "[ROLL]"; // Apply the renderer to the scene view's overlay sceneOverlay.Renderer = renderer3D; // Create renderer to symbolize plane and update plane orientation in the inset map SimpleRenderer renderer2D = new SimpleRenderer(); // Create the symbol that will be used for the plane SimpleMarkerSymbol plane2DSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, System.Drawing.Color.Blue, 10); // Apply the symbol to the renderer renderer2D.Symbol = plane2DSymbol; // Apply a rotation expression to the renderer renderer2D.RotationExpression = "[ANGLE]"; // Update the inset map with a new GraphicsOverlay based on the renderer GraphicsOverlay insetMapOverlay = new GraphicsOverlay { Renderer = renderer2D }; InsetMapView.GraphicsOverlays.Add(insetMapOverlay); // Create placeholder graphic for showing the mission route in the inset map SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Red, 2); _routeGraphic = new Graphic { Symbol = routeSymbol }; insetMapOverlay.Graphics.Add(_routeGraphic); // Create the plane graphic; this is symbolized as a blue triangle because of renderer implemented above // Create the attribute dictionary Dictionary <string, object> plane2DAttributes = new Dictionary <string, object>(); // Set the angle for the plane graphic plane2DAttributes["ANGLE"] = 0f; // Create the graphic from the attributes and the initial point _plane2D = new Graphic(new MapPoint(0, 0, SpatialReferences.Wgs84), plane2DAttributes); // Add the plane graphic to the inset map via the overlay insetMapOverlay.Graphics.Add(_plane2D); // Create the model graphic for the plane // Get the path to the 3D model string modelPath = GetModelPath(); // Create the scene symbol from the path to the model ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0); // Create the graphic with an initial location and the plane symbol _plane3D = new Graphic(new MapPoint(0, 0, 0, SpatialReferences.Wgs84), plane3DSymbol); // Add the plane to the overlay sceneOverlay.Graphics.Add(_plane3D); // Create the orbit camera controller to follow the plane _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 20.0) { CameraPitchOffset = 75.0 }; MySceneView.CameraController = _orbitCameraController; // Create a timer; this will enable animating the plane _animationTimer = new DispatcherTimer() { // This is the duration of the timer in milliseconds. This controls the animation speed (fps) Interval = new TimeSpan(0, 0, 0, 0, 60) }; _animationTimer.Tick += AnimatePlane; // Set the initial mission for when the sample loads await ChangeMission(_missionToItemId.Keys.First()); }
/// <summary> /// Runs a search and populates the map with results based on the provided information. /// </summary> /// <param name="enteredText">Results to search for.</param> /// <param name="locationText">Location around which to find results.</param> /// <param name="restrictToExtent">If true, limits results to only those that are within the current extent.</param> private async void UpdateSearch(string enteredText, string locationText, bool restrictToExtent = false) { // Clear any existing markers. MyMapView.GraphicsOverlays.Clear(); // Return gracefully if the textbox is empty or the geocoder isn't ready. if (String.IsNullOrWhiteSpace(enteredText) || _geocoder == null) { return; } // Create the geocode parameters. GeocodeParameters parameters = new GeocodeParameters(); // Get the MapPoint for the current search location. MapPoint searchLocation = await GetSearchMapPoint(locationText); // Update the geocode parameters if the map point is not null. if (searchLocation != null) { parameters.PreferredSearchLocation = searchLocation; } // Update the search area if desired. if (restrictToExtent) { // Update the search parameters with the current map extent. parameters.SearchArea = MyMapView.VisibleArea; } // Show the progress bar. MyProgressBar.Visibility = Visibility.Visible; // Get the location information. IReadOnlyList <GeocodeResult> locations = await _geocoder.GeocodeAsync(enteredText, parameters); // Stop gracefully and show a message if the geocoder does not return a result. if (locations.Count < 1) { MyProgressBar.Visibility = Visibility.Collapsed; // 1. Hide the progress bar. MessageBox.Show("No results found"); // 2. Show a message. return; // 3. Stop. } // Create the GraphicsOverlay so that results can be drawn on the map. GraphicsOverlay resultOverlay = new GraphicsOverlay(); // Add each address to the map. foreach (GeocodeResult location in locations) { // Get the Graphic to display. Graphic point = await GraphicForPoint(location.DisplayLocation); // Add the specific result data to the point. point.Attributes["Match_Title"] = location.Label; // Get the address for the point. IReadOnlyList <GeocodeResult> addresses = await _geocoder.ReverseGeocodeAsync(location.DisplayLocation); // Add the first suitable address if possible. if (addresses.Any()) { point.Attributes["Match_Address"] = addresses[0].Label; } // Add the Graphic to the GraphicsOverlay. resultOverlay.Graphics.Add(point); } // Hide the progress bar. MyProgressBar.Visibility = Visibility.Collapsed; // Add the GraphicsOverlay to the MapView. MyMapView.GraphicsOverlays.Add(resultOverlay); // Update the map viewpoint. await MyMapView.SetViewpointGeometryAsync(resultOverlay.Extent, 50); }
internal void AddGraphicsOverlay(GraphicsOverlay layer, bool replace = false) => graphicsOverlays.Insert(0, layer);
private void Initialize() { // Create a spatial reference that's suitable for creating planar buffers in north central Texas (State Plane). SpatialReference statePlaneNorthCentralTexas = new SpatialReference(32038); // Define a polygon that represents the valid area of use for the spatial reference. // This information is available at https://developers.arcgis.com/net/latest/wpf/guide/pdf/projected_coordinate_systems_rt100_3_0.pdf List <MapPoint> spatialReferenceExtentCoords = new List <MapPoint> { new MapPoint(-103.070, 31.720, SpatialReferences.Wgs84), new MapPoint(-103.070, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.000, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.00, 31.720, SpatialReferences.Wgs84) }; _spatialReferenceArea = new Polygon(spatialReferenceExtentCoords); _spatialReferenceArea = GeometryEngine.Project(_spatialReferenceArea, statePlaneNorthCentralTexas) as Polygon; // Create a map that uses the North Central Texas state plane spatial reference. Map bufferMap = new Map(statePlaneNorthCentralTexas); // Add some base layers (counties, cities, and highways). Uri usaLayerSource = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer"); ArcGISMapImageLayer usaLayer = new ArcGISMapImageLayer(usaLayerSource); bufferMap.Basemap.BaseLayers.Add(usaLayer); // Use a new EnvelopeBuilder to expand the spatial reference extent 120%. EnvelopeBuilder envBuilder = new EnvelopeBuilder(_spatialReferenceArea.Extent); envBuilder.Expand(1.2); // Set the map's initial extent to the expanded envelope. Envelope startingEnvelope = envBuilder.ToGeometry(); bufferMap.InitialViewpoint = new Viewpoint(startingEnvelope); // Assign the map to the MapView. _myMapView.Map = bufferMap; // Create a graphics overlay to show the buffer polygon graphics. GraphicsOverlay bufferGraphicsOverlay = new GraphicsOverlay { // Give the overlay an ID so it can be found later. Id = "buffers" }; // Create a graphic to show the spatial reference's valid extent (envelope) with a dashed red line. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Red, 5); Graphic spatialReferenceExtentGraphic = new Graphic(_spatialReferenceArea, lineSymbol); // Add the graphic to a new overlay. GraphicsOverlay spatialReferenceGraphicsOverlay = new GraphicsOverlay(); spatialReferenceGraphicsOverlay.Graphics.Add(spatialReferenceExtentGraphic); // Add the graphics overlays to the MapView. _myMapView.GraphicsOverlays.Add(bufferGraphicsOverlay); _myMapView.GraphicsOverlays.Add(spatialReferenceGraphicsOverlay); // Wire up the MapView's GeoViewTapped event handler. _myMapView.GeoViewTapped += MyMapView_GeoViewTapped; }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk TileCache tileCache = new TileCache(GetTpkPath()); // Create the corresponding layer based on the tile cache ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap Map myMap = new Map(sfBasemap); // Assign the map to the MapView myMapView.Map = myMap; // Create a new symbol for the extent graphic SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer GraphicsOverlay extentOverlay = new GraphicsOverlay(); extentOverlay.Renderer = new SimpleRenderer(lineSymbol); // Add graphics overlay to the map view myMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes myMapView.ViewpointChanged += MapViewExtentChanged; // Set up an event handler for 'tapped' events myMapView.GeoViewTapped += GeoViewTapped; // Update the local data path for the geodatabase file String iOSFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); _gdbPath = Path.Combine(iOSFolder, "wildfire.geodatabase"); // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the Uri for this particular layer Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk. TileCache tileCache = new TileCache(DataManager.GetDataFolder("e4a398afe9a945f3b0f4dca1e4faccb5", "SanFrancisco.tpkx")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(sfBasemap); // Assign the map to the MapView. MyMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create a graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. MyMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. MyMapView.ViewpointChanged += MapViewExtentChanged; try { // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the URL for this particular layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Skip tables that aren't for point features.{ if (onlineTable.GeometryType != GeometryType.Point) { continue; } // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - needed in case the user decides not to interact before pressing the button. UpdateMapExtent(); // Enable the generate button. MyGenerateButton.IsEnabled = true; } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } }
private void Initialize() { // Create new Scene Scene myScene = new Scene(); // Set Scene's base map property myScene.Basemap = Basemap.CreateImagery(); // Create a camera with coordinates showing layer data Camera camera = new Camera(53.04, -4.04, 1300, 0, 90.0, 0); // Assign the Scene to the SceneView MySceneView.Scene = myScene; // Create ElevationSource from elevation data Uri ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource( new Uri("http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // Add elevationSource to BaseSurface's ElevationSources MySceneView.Scene.BaseSurface.ElevationSources.Add(elevationSource); // Set view point of scene view using camera MySceneView.SetViewpointCameraAsync(camera); // Create overlays with elevation modes GraphicsOverlay drapedOverlay = new GraphicsOverlay(); drapedOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; MySceneView.GraphicsOverlays.Add(drapedOverlay); GraphicsOverlay relativeOverlay = new GraphicsOverlay(); relativeOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative; MySceneView.GraphicsOverlays.Add(relativeOverlay); GraphicsOverlay absoluteOverlay = new GraphicsOverlay(); absoluteOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Absolute; MySceneView.GraphicsOverlays.Add(absoluteOverlay); // Create point for graphic location MapPoint point = new MapPoint(-4.04, 53.06, 1000, camera.Location.SpatialReference); // Create a red circle symbol SimpleMarkerSymbol circleSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.FromRgb(255, 0, 0), 10); // Create a text symbol for each elevation mode TextSymbol drapedText = new TextSymbol("DRAPED", Color.FromRgb(255, 255, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); TextSymbol relativeText = new TextSymbol("RELATIVE", Color.FromRgb(255, 255, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); TextSymbol absoluteText = new TextSymbol("ABSOLUTE", Color.FromRgb(255, 255, 255), 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Left, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); // Add the point graphic and text graphic to the corresponding graphics overlay drapedOverlay.Graphics.Add(new Graphic(point, circleSymbol)); drapedOverlay.Graphics.Add(new Graphic(point, drapedText)); relativeOverlay.Graphics.Add(new Graphic(point, circleSymbol)); relativeOverlay.Graphics.Add(new Graphic(point, relativeText)); absoluteOverlay.Graphics.Add(new Graphic(point, circleSymbol)); absoluteOverlay.Graphics.Add(new Graphic(point, absoluteText)); }
public GraphicSelection(Graphic graphic, GraphicsOverlay overlay) { SelectedGraphic = graphic; SelectedOverlay = overlay; }
public QueryRelatedRecords() { this.InitializeComponent(); _wellsOverlay = MyMapView.GraphicsOverlays["wellsOverlay"]; }
private void Initialize() { // Configure the basemap _myMapView.Map = new Map(Basemap.CreateTopographic()); // Create the graphics overlay and set the selection color _graphicsOverlay = new GraphicsOverlay() { SelectionColor = System.Drawing.Color.Yellow }; // Add the overlay to the MapView _myMapView.GraphicsOverlays.Add(_graphicsOverlay); // Create the point collection that defines the polygon PointCollection polygonPoints = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(-5991501.677830, 5599295.131468), new MapPoint(-6928550.398185, 2087936.739807), new MapPoint(-3149463.800709, 1840803.011362), new MapPoint(-1563689.043184, 3714900.452072), new MapPoint(-3180355.516764, 5619889.608838) }; // Create the polygon Polygon polygonGeometry = new Polygon(polygonPoints); // Define the symbology of the polygon SimpleLineSymbol polygonOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Green, 2); SimpleFillSymbol polygonFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Green, polygonOutlineSymbol); // Create the polygon graphic and add it to the graphics overlay _polygonGraphic = new Graphic(polygonGeometry, polygonFillSymbol); _graphicsOverlay.Graphics.Add(_polygonGraphic); // Create the point collection that defines the polyline var polylinePoints = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(-4354240.726880, -609939.795721), new MapPoint(-3427489.245210, 2139422.933233), new MapPoint(-2109442.693501, 4301843.057130), new MapPoint(-1810822.771630, 7205664.366363) }; // Create the polyline Polyline polylineGeometry = new Polyline(polylinePoints); // Create the polyline graphic and add it to the graphics overlay _polylineGraphic = new Graphic(polylineGeometry, new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.Red, 4)); _graphicsOverlay.Graphics.Add(_polylineGraphic); // Create the point geometry that defines the point graphic MapPoint pointGeometry = new MapPoint(-4487263.495911, 3699176.480377, SpatialReferences.WebMercator); // Define the symbology for the point SimpleMarkerSymbol locationMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 10); // Create the point graphic and add it to the graphics overlay _pointGraphic = new Graphic(pointGeometry, locationMarker); _graphicsOverlay.Graphics.Add(_pointGraphic); // Listen for taps; the spatial relationships will be updated in the handler _myMapView.GeoViewTapped += myMapView_GeoViewTapped; // Set the viewpoint to center on the point _myMapView.SetViewpointCenterAsync(pointGeometry, 200000000); }
private async void Initialize() { try { // Create a tile cache and load it with the SanFrancisco streets tpk. TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map map = new Map(sfBasemap); // Assign the map to the MapView. _myMapView.Map = map; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. _myMapView.GraphicsOverlays.Add(extentOverlay); // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the Uri for this particular layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Skip tables that aren't for point features.{ if (onlineTable.GeometryType != GeometryType.Point) { continue; } // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { map.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - needed in case the user decides not to interact before pressing the button. UpdateMapExtent(); // Enable the generate button now that the sample is ready. _generateButton.Enabled = true; } catch (Exception ex) { ShowStatusMessage(ex.ToString()); } }
private async void Initialize() { try { // Create the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl)); // Create the map. _myMapView.Map = new Map(Basemap.CreateTopographicVector()); // Get all of the edges and junctions in the network. IEnumerable <UtilityNetworkSource> edges = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge); IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction); // Add all edges that are not subnet lines to the map. foreach (UtilityNetworkSource source in edges) { if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null) { _myMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable)); } } // Add all junctions to the map. foreach (UtilityNetworkSource source in junctions) { if (source.FeatureTable != null) { _myMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable)); } } // Create a graphics overlay for associations. _associationsOverlay = new GraphicsOverlay(); _myMapView.GraphicsOverlays.Add(_associationsOverlay); // Symbols for the associations. Symbol attachmentSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d); Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d); // Create a renderer for the associations. var attachmentValue = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString()); var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString()); _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> { "AssociationType" }, new List <UniqueValue> { attachmentValue, connectivityValue }, string.Empty, null); // Populate the legend in the UI. RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync(); _attachmentImage.Image = await attachmentSwatch?.ToImageSourceAsync(); RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync(); _connectivityImage.Image = await connectSwatch?.ToImageSourceAsync(); // Set the starting viewpoint. await _myMapView.SetViewpointAsync(InitialViewpoint); // Add the associations in the starting viewpoint. AddAssociations(); } catch (Exception ex) { new UIAlertView(ex.GetType().Name, ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show(); } }
/// <summary> /// 在指定图层上添加点要素 /// </summary> /// <param name="overlay">图层实例</param> /// <param name="point">位置</param> /// <param name="pointSymbolStyle">点的呈现样式</param> /// <param name="pointColor">颜色</param> /// <param name="pointSize">大小</param> public void AddPointToGraphicsOverlay(GraphicsOverlay overlay, MapPoint point, SimpleMarkerSymbolStyle pointSymbolStyle, Color pointColor, double pointSize) { Graphic graphic = new Graphic(point, new SimpleMarkerSymbol(pointSymbolStyle, pointColor, pointSize)); overlay.Graphics.Add(graphic); }
private async void Initialize() { // Create scene Scene myScene = new Scene(Basemap.CreateImageryWithLabels()) { // Set initial viewpoint InitialViewpoint = new Viewpoint(_observerPoint, 1000000) }; // Create the elevation source ElevationSource myElevationSource = new ArcGISTiledElevationSource(_elevationUri); // Add the elevation source to the scene myScene.BaseSurface.ElevationSources.Add(myElevationSource); // Create the building scene layer ArcGISSceneLayer mySceneLayer = new ArcGISSceneLayer(_buildingsUri); // Add the building layer to the scene myScene.OperationalLayers.Add(mySceneLayer); // Add the observer to the scene // Create a graphics overlay with relative surface placement; relative surface placement allows the Z position of the observation point to be adjusted GraphicsOverlay overlay = new GraphicsOverlay() { SceneProperties = new LayerSceneProperties(SurfacePlacement.Relative) }; // Create the symbol that will symbolize the observation point SimpleMarkerSceneSymbol symbol = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Sphere, Colors.Red, 10, 10, 10, SceneSymbolAnchorPosition.Bottom); // Create the observation point graphic from the point and symbol _observerGraphic = new Graphic(_observerPoint, symbol); // Add the observer to the overlay overlay.Graphics.Add(_observerGraphic); // Add the overlay to the scene MySceneView.GraphicsOverlays.Add(overlay); try { // Add the taxi to the scene // Create the model symbol for the taxi ModelSceneSymbol taxiSymbol = await ModelSceneSymbol.CreateAsync(new Uri(GetModelUri())); // Set the anchor position for the mode; ensures that the model appears above the ground taxiSymbol.AnchorPosition = SceneSymbolAnchorPosition.Bottom; // Create the graphic from the taxi starting point and the symbol _taxiGraphic = new Graphic(_points[0], taxiSymbol); // Add the taxi graphic to the overlay overlay.Graphics.Add(_taxiGraphic); // Create GeoElement Line of sight analysis (taxi to building) // Create the analysis _geoLine = new GeoElementLineOfSight(_observerGraphic, _taxiGraphic) { // Apply an offset to the target. This helps avoid some false negatives TargetOffsetZ = 2 }; // Create the analysis overlay AnalysisOverlay myAnalysisOverlay = new AnalysisOverlay(); // Add the analysis to the overlay myAnalysisOverlay.Analyses.Add(_geoLine); // Add the analysis overlay to the scene MySceneView.AnalysisOverlays.Add(myAnalysisOverlay); // Create a timer; this will enable animating the taxi Device.StartTimer(new TimeSpan(0, 0, 0, 0, 60), () => { // Move the taxi every time the timer elapses AnimationTimer_Elapsed(this, null); // Keep the timer running return(true); }); // Subscribe to TargetVisible events; allows for updating the UI and selecting the taxi when it is visible _geoLine.TargetVisibilityChanged += Geoline_TargetVisibilityChanged; // Add the scene to the view MySceneView.Scene = myScene; } catch (Exception e) { await((Page)Parent).DisplayAlert("Error", e.ToString(), "OK"); } }