private async Task SetupSymbols() { _pinSymbol = new PictureMarkerSymbol() { Width = 24, Height = 24, YOffset = 12 }; await _pinSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickPin.png")); _bufferSymbol = LayoutRoot.Resources["BufferSymbol"] as SimpleFillSymbol; }
private async void FindAddressButton_Click(object sender, RoutedEventArgs e) { OnlineLocatorTask locator = GetLocation(); var findParams = new OnlineLocatorFindParameters(AddressTextBox.Text); findParams.OutSpatialReference = MyMapView.SpatialReference; findParams.SourceCountry = "US"; var results = await locator.FindAsync(findParams, new System.Threading.CancellationToken()); if (results.Count > 0) { var firstMatch = results[0].Feature; var matchLocation = firstMatch.Geometry as MapPoint; var matchSym = new PictureMarkerSymbol(); var pictureURI = new Uri("http://static.arcgis.com/images/Symbols/Basic/GreenStickpin.png"); await matchSym.SetSourceAsync(pictureURI); var matchGraphic = new Graphic(matchLocation, matchSym); var graphicsLayer = MyMap.Layers["GeocodeResults"] as GraphicsLayer; graphicsLayer.Graphics.Add(matchGraphic); var matchExtent = new Envelope(matchLocation.X - 100, matchLocation.Y - 100, matchLocation.X + 100, matchLocation.Y + 100); await MyMapView.SetViewAsync(matchExtent); } }
private async Task SetupSymbols() { _pinSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await _pinSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png")); _bufferSymbol = layoutGrid.Resources["BufferSymbol"] as SimpleFillSymbol; }
// Setup the pin graphic and graphics layer renderer private async Task SetSimpleRendererSymbols() { var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await markerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png")); var renderer = new SimpleRenderer() { Symbol = markerSymbol }; addressesGraphicsLayer.Renderer = renderer; }
public static PictureMarkerSymbol CreatePushpinSymbol() { PictureMarkerSymbol pms = new PictureMarkerSymbol() { Source = new BitmapImage(new Uri(@"pack://application:,,,/OperationsDashboardAddIns;component/Images/FlickrPin64.png")), OffsetX = 35, OffsetY = 60, }; return pms; }
// Load the picture symbol image private async Task SetupSymbolsAsync() { try { _pictureMarkerSymbol = LayoutRoot.Resources["PictureMarkerSymbol"] as PictureMarkerSymbol; await _pictureMarkerSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/x-24x24.png")); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private async Task InitializePictureMarkerSymbol() { try { pms = LayoutRoot.Resources["MyPictureMarkerSymbol"] as PictureMarkerSymbol; await pms.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickPin.png")); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
// Create marker symbols private async Task SetupSymbolsAsync() { try { const int size = 24; // Create simple marker symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List<MarkerSymbol>() { new SimpleMarkerSymbol() { Color = Colors.Red, Size = 15, Style = SimpleMarkerStyle.Circle, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Green, Size = 15, Style = SimpleMarkerStyle.Diamond, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Blue, Size = 15, Style = SimpleMarkerStyle.Square, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Purple, Size = 15, Style = SimpleMarkerStyle.X, Outline = blackOutlineSymbol }, }; // Set image sources for picture marker symbols List<Task> setSourceTasks = new List<Task>(); var stickPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(stickPinSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png"))); _symbols.Add(stickPinSymbol); var pushPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(pushPinSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedPushpin.png"))); _symbols.Add(pushPinSymbol); var xPictureSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(xPictureSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png"))); _symbols.Add(xPictureSymbol); await Task.WhenAll(setSourceTasks); // Create image swatches for the UI Task<ImageSource>[] swatchTasks = _symbols.OfType<SimpleMarkerSymbol>() .Select(sym => sym.CreateSwatchAsync(size, size, 96.0, Colors.Transparent)) .ToArray(); var imageSources = new List<ImageSource>(await Task.WhenAll(swatchTasks)); // Manually create swatches for the picture marker symbols imageSources.Add(LoadImage("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png", size)); imageSources.Add(LoadImage("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedPushpin.png", size)); imageSources.Add(LoadImage("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png", size)); symbolCombo.ItemsSource = imageSources; } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
// Load the picture symbol image private async void SetupSymbols() { try { _pictureMarkerSymbol = LayoutRoot.Resources["PictureMarkerSymbol"] as PictureMarkerSymbol; await _pictureMarkerSymbol.SetSourceAsync(new Uri("ms-appx:///ArcGISRuntimeSamplesStore/Assets/x-24x24.png")); } catch (Exception ex) { var _x = new MessageDialog("Error occurred : " + ex.Message, "Label Point Sample").ShowAsync(); } }
// Load the picture symbol image private async Task SetupSymbolsAsync() { try { _pictureMarkerSymbol = layoutGrid.Resources["PictureMarkerSymbol"] as PictureMarkerSymbol; await _pictureMarkerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png")); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
// Load the picture symbol image private async void SetupSymbols() { try { _pictureMarkerSymbol = layoutGrid.Resources["PictureMarkerSymbol"] as PictureMarkerSymbol; await _pictureMarkerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png")); } catch (Exception ex) { MessageBox.Show("Error occurred : " + ex.Message, "Label Point Sample"); } }
private async void SetupSymbols() { try { _pms = LayoutRoot.Resources["MyPictureMarkerSymbol"] as PictureMarkerSymbol; await _pms.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickPin.png")); } catch (Exception ex) { var _x = new MessageDialog(ex.Message, "Buffer Sample").ShowAsync(); } }
private async void InitializePictureMarkerSymbol() { try { var imageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///ArcGISRuntimeSamplesPhone/Assets/x-24x24.png")); var imageSource = await imageFile.OpenReadAsync(); pictureMarkerSymbol = LayoutRoot.Resources["MyPictureMarkerSymbol"] as PictureMarkerSymbol; await pictureMarkerSymbol.SetSourceAsync(imageSource); } catch (Exception ex) { var _x = new MessageDialog("Error occurred : " + ex.Message, "Label Point Sample").ShowAsync(); } }
private async Task InitializePictureMarkerSymbol() { try { var imageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/i_pushpin.png")); var imageSource = await imageFile.OpenReadAsync(); pms = LayoutRoot.Resources["MyPictureMarkerSymbol"] as PictureMarkerSymbol; await pms.SetSourceAsync(imageSource); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
// Setup marker symbol and renderer private async void SetupRendererSymbols() { try { var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await markerSymbol.SetSourceAsync( new Uri("ms-appx:///ArcGISRuntimeSamplesStore/Assets/RedStickpin.png")); _graphicsOverlay.Renderer = new SimpleRenderer() { Symbol = markerSymbol, }; } catch (System.Exception ex) { var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } }
// Setup marker symbol and renderer private async void SetupRendererSymbols() { try { var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await markerSymbol.SetSourceAsync( new Uri("pack://application:,,,/ArcGISRuntimeSamplesDesktop;component/Assets/RedStickpin.png")); _graphicsOverlay.Renderer = new SimpleRenderer() { Symbol = markerSymbol, }; } catch(Exception ex) { MessageBox.Show("Error occurred : " + ex.Message, "Sample error"); } }
private async void SetupSymbols() { try { _pinSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await _pinSymbol.SetSourceAsync( new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png")); _bufferSymbol = layoutGrid.Resources["BufferSymbol"] as SimpleFillSymbol; } catch (Exception ex) { MessageBox.Show("Error occured : " + ex.Message, "Buffer Sample"); } }
private async void InitializePictureMarkerSymbol() { _pinMarkerSymbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as PictureMarkerSymbol; try { await _pinMarkerSymbol.SetSourceAsync( new Uri("pack://application:,,,/IS3.Desktop;component/Images/pin_red.png")); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
// Setup the pin graphic and graphics overlay renderer private async void SetSimpleRendererSymbols() { try { var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await markerSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickpin.png")); var renderer = new SimpleRenderer() { Symbol = markerSymbol }; _addressOverlay.Renderer = renderer; } catch (Exception ex) { var _x = new MessageDialog("Selection Error: " + ex.Message, "Find Place Sample").ShowAsync(); } }
// Setup the pin graphic and graphics overlay renderer private async void SetSimpleRendererSymbols() { try { var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await markerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png")); var renderer = new SimpleRenderer() { Symbol = markerSymbol }; _addressOverlay.Renderer = renderer; } catch (Exception ex) { MessageBox.Show("Error occurred : " + ex.Message, "Find Place Sample"); } }
private async void SetupSymbols() { try { _pinSymbol = new PictureMarkerSymbol() { Width = 24, Height = 24, YOffset = 12 }; await _pinSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickPin.png")); _bufferSymbol = LayoutRoot.Resources["BufferSymbol"] as SimpleFillSymbol; } catch (Exception ex) { var _x = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } }
// Create marker symbols private async Task SetupSymbolsAsync() { try { int size = Convert.ToInt32(LayoutRoot.Resources["ImageSize"]); int sizePt = (int)((float)size / DisplayInformation.GetForCurrentView().LogicalDpi * 72); // Create simple marker symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List<MarkerSymbol>() { new SimpleMarkerSymbol() { Color = Colors.Red, Size = sizePt, Style = SimpleMarkerStyle.Circle, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Green, Size = sizePt, Style = SimpleMarkerStyle.Diamond, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Blue, Size = sizePt, Style = SimpleMarkerStyle.Square, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Purple, Size = sizePt, Style = SimpleMarkerStyle.X, Outline = blackOutlineSymbol }, }; // Set image sources for picture marker symbols List<Task> setSourceTasks = new List<Task>(); var stickPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(stickPinSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickpin.png"))); _symbols.Add(stickPinSymbol); var pushPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(pushPinSymbol.SetSourceAsync(new Uri("http://static.arcgis.com/images/Symbols/Basic/RedShinyPin.png"))); _symbols.Add(pushPinSymbol); var xPictureSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(xPictureSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/x-24x24.png"))); _symbols.Add(xPictureSymbol); await Task.WhenAll(setSourceTasks); // Create image swatches for the UI Task<ImageSource>[] swatchTasks = _symbols .Select(sym => sym.CreateSwatchAsync()) .ToArray(); symbolCombo.ItemsSource = await Task.WhenAll(swatchTasks); symbolCombo.SelectedIndex = 0; } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
private void AddGraphicToMap_Click(object sender, RoutedEventArgs e) { // Create a diagonal linear gradient with four stops. // http://msdn.microsoft.com/en-us/library/system.windows.media.lineargradientbrush.aspx LinearGradientBrush myLinearGradientBrush = new LinearGradientBrush(); myLinearGradientBrush.StartPoint = new Point(0, 0); myLinearGradientBrush.EndPoint = new Point(1, 1); myLinearGradientBrush.GradientStops.Add( new GradientStop(Colors.Yellow, 0.0)); myLinearGradientBrush.GradientStops.Add( new GradientStop(Colors.Red, 0.25)); myLinearGradientBrush.GradientStops.Add( new GradientStop(Colors.Blue, 0.75)); myLinearGradientBrush.GradientStops.Add( new GradientStop(Colors.LimeGreen, 1.0)); // Add an Ellipse Element // http://msdn.microsoft.com/en-us/library/system.windows.shapes.ellipse.aspx Ellipse myEllipse = new Ellipse(); myEllipse.Stroke = System.Windows.Media.Brushes.Black; myEllipse.Fill = myLinearGradientBrush; myEllipse.HorizontalAlignment = HorizontalAlignment.Left; myEllipse.VerticalAlignment = VerticalAlignment.Center; myEllipse.Width = 50; myEllipse.Height = 50; //Force render myEllipse.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity)); myEllipse.Arrange(new Rect(myEllipse.DesiredSize)); RenderTargetBitmap render = new RenderTargetBitmap(200, 200, 150, 150, PixelFormats.Pbgra32); render.Render(myEllipse); PictureMarkerSymbol pms = new PictureMarkerSymbol() { Source = render, }; Random random = new Random(); var graphic = new Graphic() { Geometry = new MapPoint(random.Next(-20000000, 20000000), random.Next(-20000000, 20000000)) }; graphic.Symbol = pms; MarkerGraphicsLayer.Graphics.Add(graphic); }
private void LocationButton_Checked(object sender, RoutedEventArgs e) { _myLocationOverlay.Graphics.Clear(); var point = MyMapView.LocationDisplay.CurrentLocation.Location; var buffer = GeometryEngine.GeodesicBuffer(point, 300, LinearUnits.Meters); MyMapView.SetView(buffer.Extent); var symbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; symbol.SetSourceAsync(new Uri("ms-appx:///Assets/CollPin.png")); var graphic = new Graphic() { Geometry = point, Symbol = symbol }; _myLocationOverlay.Graphics.Add(graphic); }
private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) { // Get current assembly that contains the image var currentAssembly = Assembly.GetExecutingAssembly(); // 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); }
private static void CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay) { // Create uri to the used image Uri symbolUri = new Uri( "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae"); // Create new symbol using asynchronous factory method from uri. PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(symbolUri) { Width = 40, Height = 40 }; // Create location for the campsite MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(campsiteGraphic); }
private async Task CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay) { // Create uri to the used image var symbolUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae"); // Create new symbol using asynchronous factory method from uri PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(symbolUri); // Optionally set the size (if not set, the size in pixels of the image will be used) campsiteSymbol.Height = 18; campsiteSymbol.Width = 18; // Create location for the campsite MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(campsiteGraphic); }
private void loadPointSymbolConfigControl() { PictureMarkerSymbol symbol = getCurrentSymbol(); if (symbol == null) { return; } if (CurrentSymbolImage != null) { CurrentSymbolImage.Source = symbol.Source; } if (OpacitySlider != null) { OpacitySlider.SetBinding(Slider.ValueProperty, new System.Windows.Data.Binding { Path = new PropertyPath("Opacity"), Source = symbol }); OpacitySlider.Value = symbol.Opacity; } }
//==========================放球站标记======================== private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) { // Get current assembly that contains the image Assembly currentAssembly = Assembly.GetExecutingAssembly(); // Get image as a stream from the resources // Picture is defined as EmbeddedResource and DoNotCopy Stream resourceStream = currentAssembly.GetManifestResourceStream( this.GetType(), "pin_star_blue.png"); // Create new symbol using asynchronous factory method from stream PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); pinSymbol.Width = 50; pinSymbol.Height = 50; // Create location for the pint MapPoint pinPoint1 = new MapPoint(lon(111.35000), lat(30.73000), SpatialReferences.WebMercator); MapPoint pinPoint2 = new MapPoint(lon(114.05000), lat(30.60000), SpatialReferences.WebMercator); MapPoint pinPoint3 = new MapPoint(lon(112.78000), lat(28.010000), SpatialReferences.WebMercator); MapPoint pinPoint4 = new MapPoint(lon(115.00000), lat(25.87000), SpatialReferences.WebMercator); MapPoint pinPoint5 = new MapPoint(lon(115.90110), lat(28.59000), SpatialReferences.WebMercator); MapPoint pinPoint6 = new MapPoint(lon(116.97000), lat(30.62000), SpatialReferences.WebMercator); // Create graphic with the location and symbol Graphic pinGraphic1 = new Graphic(pinPoint1, pinSymbol); Graphic pinGraphic2 = new Graphic(pinPoint2, pinSymbol); Graphic pinGraphic3 = new Graphic(pinPoint3, pinSymbol); Graphic pinGraphic4 = new Graphic(pinPoint4, pinSymbol); Graphic pinGraphic5 = new Graphic(pinPoint5, pinSymbol); Graphic pinGraphic6 = new Graphic(pinPoint6, pinSymbol); // Add graphic to the graphics overlay overlay.Graphics.Add(pinGraphic1); overlay.Graphics.Add(pinGraphic2); overlay.Graphics.Add(pinGraphic3); overlay.Graphics.Add(pinGraphic4); overlay.Graphics.Add(pinGraphic5); overlay.Graphics.Add(pinGraphic6); }
/// <summary> /// Loads the symbol images and creates symbols, applying scale factor and offsets /// </summary> private async Task ConfigureImages() { var originImage = new RuntimeImage(new Uri("pack://application:,,,/MapsApp;component/Images/Depart.png")); var destinationImage = new RuntimeImage(new Uri("pack://application:,,,/MapsApp;component/Images/Stop.png")); // Images must be loaded to ensure dimensions will be available await Task.WhenAll(originImage.LoadAsync(), destinationImage.LoadAsync()); // OffsetY adjustment is specific to the pin marker symbol, to make sure it is anchored at the pin point, rather than center. _originPinSymbol = new PictureMarkerSymbol(originImage) { OffsetY = originImage.Height * PinScaleFactor / 2, Height = originImage.Height * PinScaleFactor, Width = originImage.Width * PinScaleFactor }; _mapPinSymbol = new PictureMarkerSymbol(originImage) { OffsetY = originImage.Height * PinScaleFactor / 2, Height = originImage.Height * PinScaleFactor, Width = originImage.Width * PinScaleFactor }; _destinationPinSymbol = new PictureMarkerSymbol(destinationImage) { OffsetY = destinationImage.Height * PinScaleFactor / 2, Height = destinationImage.Height * PinScaleFactor, Width = destinationImage.Width * PinScaleFactor }; }
// Setup the pin graphic and graphics overlay renderer private async void SetSimpleRendererSymbols() { try { var markerSymbol = new PictureMarkerSymbol() { Width = 48, Height = 48, YOffset = 24 }; await markerSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png")); var renderer = new SimpleRenderer() { Symbol = markerSymbol }; _addressOverlay.Renderer = renderer; } catch (Exception ex) { MessageBox.Show("Error occured : " + ex.Message, "Find Place Sample"); } }
private PictureMarkerSymbol CreateMarkerSymbol(string symbolUri, double offsetX, double offsetY) { if (!string.IsNullOrEmpty(symbolUri)) { PictureMarkerSymbol pictureSymbol = new PictureMarkerSymbol(); pictureSymbol.OffsetX = offsetX; pictureSymbol.OffsetY = offsetY; if (symbolUri.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { pictureSymbol.Source = new BitmapImage(new Uri(symbolUri, UriKind.Absolute)); } else { pictureSymbol.Source = new BitmapImage(new Uri(symbolUri, UriKind.Relative)); } return(pictureSymbol); } return(null); }
private async void HandleMapTap(MapPoint mapLocation) { // Normalize geometry - important for geometries that will be sent to a server for processing. mapLocation = (MapPoint)GeometryEngine.NormalizeCentralMeridian(mapLocation); switch (_currentSampleState) { case SampleState.AddingBarriers: // Buffer the tapped point to create a larger barrier. Geometry bufferedGeometry = GeometryEngine.BufferGeodetic(mapLocation, 500, LinearUnits.Meters); // Create the graphic to show the barrier. Graphic barrierGraphic = new Graphic(bufferedGeometry, _barrierSymbol); // Add the graphic to the overlay - this will cause it to appear on the map. _barriersOverlay.Graphics.Add(barrierGraphic); break; case SampleState.AddingStops: // Get the name of this stop. string stopName = $"{_stopsOverlay.Graphics.Count + 1}"; // Create the marker to show underneath the stop number. PictureMarkerSymbol pushpinMarker = await GetPictureMarker(); // Create the text symbol for showing the stop. TextSymbol stopSymbol = new TextSymbol(stopName, Color.White, 15, HorizontalAlignment.Center, VerticalAlignment.Middle); stopSymbol.OffsetY = 15; CompositeSymbol combinedSymbol = new CompositeSymbol(new MarkerSymbol[] { pushpinMarker, stopSymbol }); // Create the graphic to show the stop. Graphic stopGraphic = new Graphic(mapLocation, combinedSymbol); // Add the graphic to the overlay - this will cause it to appear on the map. _stopsOverlay.Graphics.Add(stopGraphic); break; } }
/// <summary> /// 设置地图显示,并显示地图中心要素 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SetScaleAndLocationCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { ViewSpot data = e.Parameter as ViewSpot; foreach (Graphic g in ArcGISMapView.PointOverlay.Graphics) { MapPoint point = g.Geometry as MapPoint; //如果经纬度匹配 if (point.X == data.GetLng() && point.Y == data.GetLat()) { //更改图标 PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol(IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin]) { Width = 16, Height = 24, OffsetX = 0, OffsetY = 9.5 }; g.Symbol = pictureMarkerSymbol; } else { //恢复其他已被改变的图标 if ((g.Symbol as PictureMarkerSymbol).Uri != IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue]) { PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol(IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue]) { Width = 16, Height = 24, OffsetX = 0, OffsetY = 9.5 }; g.Symbol = pictureMarkerSymbol; } } } //改变地图视角 ArcGISMapView.SetScaleAndLoction(new MapPoint(data.GetLng(), data.GetLat(), SpatialReferences.Wgs84), 10000); }
private void CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay) { // Create URL to the image. Uri symbolUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0/images/e82f744ebb069bb35b234b3fea46deae"); // Create new symbol using asynchronous factory method from URL. PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(symbolUri) { // Optionally set the size (if not set, the size in pixels of the image will be used). Height = 40, Width = 40 }; // Create location for the campsite. MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator); // Create graphic with the location and symbol. Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol); // Add graphic to the graphics overlay. overlay.Graphics.Add(campsiteGraphic); }
private async void LoadService(string uri) { StreamInfo = "Initializing stream..."; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(StreamInfo))); var client = await StreamServiceClient.CreateAsync(new Uri(uri)); client.FeatureTimeout = TimeSpan.FromMinutes(5); // Removes any features that hasn't reported back in over 5 minutes client.OnUpdate += Client_OnUpdate; // Create overlay for rendering updates var si = typeof(LocationDisplay).Assembly.GetManifestResourceStream("Esri.ArcGISRuntime.Esri.ArcGISRuntime.LocationDisplayCourse.scale-200.png"); var ri = await RuntimeImage.FromStreamAsync(si); PictureMarkerSymbol vehicleSymbol = new PictureMarkerSymbol(ri) { Width = 25, Height = 25 }; var overlay = new Esri.ArcGISRuntime.UI.GraphicsOverlay() { Renderer = new SimpleRenderer(vehicleSymbol), SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute) //In case we use it in 3D and have Z values }; var headingField = client.ServiceInfo.Fields.Where(f => f.Name.ToLower() == "heading").Select(f => f.Name).FirstOrDefault(); if (!string.IsNullOrEmpty(headingField)) { overlay.Renderer.RotationExpression = $"[{headingField}]"; overlay.Renderer.SceneProperties.HeadingExpression = $"[{headingField}]"; } Overlays.Add(overlay); client.Overlay = overlay; // Connect await client.ConnectAsync(); StreamInfo = "Connected"; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(StreamInfo))); }
private async void PlaceFacilityButton_Click(object sender, RoutedEventArgs e) { try { // Let the user tap on the map view using the point sketch mode. SketchCreationMode creationMode = SketchCreationMode.Point; Geometry geometry = await MyMapView.SketchEditor.StartAsync(creationMode, false); // Symbology for a facility. PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(new Uri("http://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png")) { Height = 30, Width = 30 }; // Create a graphic for the facility. Graphic facilityGraphic = new Graphic(geometry, new Dictionary <string, object>() { { "Type", "Facility" } }, facilitySymbol) { ZIndex = 2 }; // Add the graphic to the graphics overlay. MyMapView.GraphicsOverlays[0].Graphics.Add(facilityGraphic); } catch (TaskCanceledException) { // Ignore this exception. } catch (Exception ex) { // Report exceptions. await new MessageDialog("Error drawing facility:\n" + ex.Message, "Sample error").ShowAsync(); } }
private async void DrawFacilities(UIAlertAction action) { try { // Let the user tap on the map view using the point sketch mode. SketchCreationMode creationMode = SketchCreationMode.Point; Geometry geometry = await _myMapView.SketchEditor.StartAsync(creationMode, true); // Symbology for a facility. PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(new Uri("https://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png")) { Height = 30, Width = 30 }; // Create a graphic for the facility. Graphic facilityGraphic = new Graphic(geometry, new Dictionary <string, object>() { { "Type", "Facility" } }, facilitySymbol) { ZIndex = 2 }; // Add the graphic to the graphics overlay. _myMapView.GraphicsOverlays[0].Graphics.Add(facilityGraphic); } catch (TaskCanceledException) { // Ignore this exception. } catch (Exception ex) { // Report exceptions. CreateErrorDialog("Error drawing facility:\n" + ex.Message); } }
private Graphic GenerateGraphic(Diamond1EntityItem item) { MapPoint point = new MapPoint(item.Longitude, item.Latitude, SpatialReferences.Wgs84); var graphic = new Graphic(point); if (Validation.IsValidInt(item.WindAngle)) { var symbol = new PictureMarkerSymbol(); symbol.SetSourceAsync(new Uri("pack://application:,,,/Pmss.Micaps.Render;component/Img/Wind.png")).GetAwaiter().GetResult(); symbol.Angle = item.WindAngle; graphic.Symbol = symbol; } else { var symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = Colors.Black, Size = 5 }; graphic.Symbol = symbol; } graphic.Attributes[Diamond1Attributes.StationNumber] = item.StationNumber; graphic.Attributes[Diamond1Attributes.CloudAmount] = Validation.IsValidInt(item.CloudAmount) ? item.CloudAmount.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.WindSpeed] = Validation.IsValidInt(item.WindSpeed) ? item.WindSpeed.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.AirPressure] = Validation.IsValidInt(item.AirPressure) ? item.AirPressure.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.ThreehoursAP] = Validation.IsValidInt(item.ThreehoursAP) ? item.ThreehoursAP.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.SixhoursRain] = Validation.IsValidFloat(item.SixhoursRain) ? item.SixhoursRain.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.DiYunLiang] = Validation.IsValidInt(item.DiYunLiang) ? item.DiYunLiang.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.DiYunGao] = Validation.IsValidInt(item.DiYunGao) ? item.DiYunGao.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.DewPoint] = Validation.IsValidInt(item.DewPoint) ? item.DewPoint.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.Visibility] = Validation.IsValidFloat(item.Visibility) ? item.Visibility.ToString() : string.Empty; graphic.Attributes[Diamond1Attributes.Temperature] = Validation.IsValidFloat(item.Temperature) ? item.Temperature.ToString() : string.Empty; return(graphic); }
private async void AddStop(Point tappedPosition) { try { // Get the location on the map. MapPoint tappedLocation = MyMapView.ScreenToLocation(tappedPosition); // Name the stop by its number. string stopName = $"{_stopsOverlay.Graphics.Count + 1}"; // Create a pushpin marker for the stop. PictureMarkerSymbol pushpinMarker = await GetPictureMarker(); // Create the text symbol for labeling the stop. TextSymbol stopSymbol = new TextSymbol(stopName, System.Drawing.Color.White, 15, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle); stopSymbol.OffsetY = 15; // Create a combined symbol with the pushpin and the label. CompositeSymbol combinedSymbol = new CompositeSymbol(new MarkerSymbol[] { pushpinMarker, stopSymbol }); // Create the graphic from the geometry and the symbology. Graphic newStopGraphic = new Graphic(tappedLocation, combinedSymbol); // Update the selection. _selectedStopGraphic = newStopGraphic; // Add the stop to the overlay. _stopsOverlay.Graphics.Add(newStopGraphic); } catch (Exception e) { Debug.WriteLine(e); ShowMessage("Couldn't select or add stop", "Couldn't select or add stop. See debug output for details."); } }
private void myPointSymbolSure_Click(object sender, RoutedEventArgs e) { if (myPointComboBox.SelectedIndex == 0) { MarkerType = enumMarkerType.SimpleMarker; if (myPointSymbolSize.Text != "") { simplePointSymbol.Size = Convert.ToInt32(myPointSymbolSize.Text); } } else if (myPointComboBox.SelectedIndex == 1) { MarkerType = enumMarkerType.PictureMarker; PictureMarkerSymbol pm = new PictureMarkerSymbol(ImgUri); pm.Width = 20; pm.Height = 20; ptSymbol.Symbol = pm; } else if (myPointComboBox.SelectedIndex == 2) { MarkerType = enumMarkerType.Text; } w.Close(); }
private async Task <Graphic> GetVehiculeGraphic(Vehicule vehicule) { try { MapPoint geometry = new MapPoint(vehicule.X, vehicule.Y, _mapView.SpatialReference); PictureMarkerSymbol symbol = await GetVehiculeSymbol(vehicule); Graphic graphic = new Graphic { Geometry = geometry, Symbol = symbol }; graphic.Attributes.Add("NumeroCarrosserie", vehicule.NumeroCarrosserie); graphic.Attributes.Add("Ligne", vehicule.Ligne); graphic.Attributes.Add("Destination", vehicule.Destination); graphic.Attributes.Add("Cap", vehicule.Cap); graphic.Attributes.Add("Vehicule", JsonConvert.SerializeObject(vehicule, Formatting.None)); return(graphic); } catch (Exception) { return(null); } }
/// <summary> /// Gets the value of the OriginalSource attached property for a specified PictureMarkerSymbol. /// </summary> /// <param name="element">The PictureMarkerSymbol from which the property value is read.</param> /// <returns>The OriginalSource property value for the PictureMarkerSymbol.</returns> public static string GetOriginalSource(PictureMarkerSymbol element) { if (element == null) { throw new ArgumentNullException("element"); } return element.GetValue(OriginalSourceProperty) as string; }
private void OnSymbolSelected(SymbolSelectedEventArgs e) { if (CurrentSymbolImage != null) { CurrentSymbolImage.Source = new BitmapImage { UriSource = new Uri(e.SelectedImage.RelativeUrl, UriKind.Relative) }; } PictureMarkerSymbol Symbol = new PictureMarkerSymbol() { Source = new BitmapImage() { UriSource = new Uri(e.SelectedImage.RelativeUrl, UriKind.Relative) }, OffsetX = e.SelectedImage.CenterX, OffsetY = e.SelectedImage.CenterY, Width = e.SelectedImage.Width, Height = e.SelectedImage.Height, Opacity = OpacitySlider.Value, // TODO //CursorName = DataContext is TableLayerInfo ? Cursors.Hand.ToString() : Cursors.Arrow.ToString() }; GraphicsLayer layer = DataContext as GraphicsLayer; if (layer != null) { // TODO:- verify if we still need this //LayerInfo layerInfo = DataContext as LayerInfo; //// refresh the graphics layer //GraphicsLayer lyr = ApplicationInstance.Instance.FindLayerForLayerInfo(layerInfo) as GraphicsLayer; //if (lyr != null) //{ // ensureCustomClassBreakRendererIsSet(lyr, layerInfo); // CustomClassBreakRenderer cb = lyr.Renderer as CustomClassBreakRenderer; // if (cb != null) // { // ImageFillSymbol imageFillSymbol = cb.DefaultSymbol as ImageFillSymbol; // if (imageFillSymbol != null) // { // imageFillSymbol.Fill = new ImageBrush // { // ImageSource = new BitmapImage // { // UriSource = new Uri(e.SelectedImage.RelativeUrl, UriKind.Relative) // } // }; // imageFillSymbol.CursorName = DataContext is TableLayerInfo ? Cursors.Hand.ToString() : Cursors.Arrow.ToString(); // } // } //} // update the model ClassBreaksRenderer renderer = layer.Renderer as ClassBreaksRenderer; if (renderer != null) { renderer.DefaultSymbol = Symbol; } } else { if (SymbolSelected != null) SymbolSelected(this, e); } }
private async void FindAddressButton_Click(object sender, RoutedEventArgs e) { try { progress.Visibility = Visibility.Visible; //The constructor takes two arguments: the URI for the geocode service and a token (required for secured services). var uri = new Uri("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"); var token = String.Empty; var locator = new OnlineLocatorTask(uri, token); // OnlineLocatorFindParameters object, which holds all relevant information for the address search. //var findParams = new OnlineLocatorFindParameters(AddressTextBox.Text); var findParams = new OnlineLocatorFindParameters(InputAddress.Text + " " + City.Text + " " + State.Text + " " + Zip.Text); findParams.OutSpatialReference = MyMapView.SpatialReference; findParams.SourceCountry = "US"; // var results = await locator.FindAsync(findParams, new System.Threading.CancellationToken()); if (results.Count > 0) { var firstMatch = results[0].Feature; var matchLocation = firstMatch.Geometry as MapPoint; //Add a point graphic at the address location var matchSym = new PictureMarkerSymbol(); var pictureUri = new Uri("http://static.arcgis.com/images/Symbols/Basic/GreenStickpin.png"); await matchSym.SetSourceAsync(pictureUri); var matchGraphic = new Graphic(matchLocation, matchSym); // Get a reference to the graphic layer you defined for the map, and add the new graphic. var graphicsLayer = MyMap.Layers["MyGraphics"] as GraphicsLayer; if (graphicsLayer.Graphics.Contains(oldGraphic)) { graphicsLayer.Graphics.Remove(oldGraphic); } graphicsLayer.Graphics.Add(matchGraphic); oldGraphic = matchGraphic; // _graphicsOverlay.Graphics.Add(matchGraphic); txtResult.Visibility = System.Windows.Visibility.Visible; txtResult.Text = ("Address Found: " + matchLocation.X +", " + matchLocation.Y); // zooms into pin point graphic: //The Envelope is created by subtracting 1000 meters from the location's //minimum X and Y values and adding 1000 meters to the maximum X and Y values. var matchExtent = new Envelope(matchLocation.X, matchLocation.Y, matchLocation.X, matchLocation.Y); await MyMapView.SetViewAsync(matchExtent); } else { MessageBox.Show("Unable to find address. "); return; } } catch (Exception ex) { MessageBox.Show("Unable to find address. ", ""); } }
private async void AddGraphics(string p_parameters, string p_textLabel ) { // check if there is a previous pinpoint //The constructor takes two arguments: the URI for the geocode service and a token (required for secured services). var uri = new Uri("http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"); var token = String.Empty; var locator = new OnlineLocatorTask(uri, token); // OnlineLocatorFindParameters object, which holds all relevant information for the address search. var findParams = new OnlineLocatorFindParameters(p_parameters); findParams.OutSpatialReference = MyMapView.SpatialReference; findParams.SourceCountry = "US"; // var results = await locator.FindAsync(findParams, new System.Threading.CancellationToken()); if (results.Count > 0) { var firstMatch = results[0].Feature; var matchLocation = firstMatch.Geometry as MapPoint; //Add a point graphic at the address location var matchSym = new PictureMarkerSymbol(); var pictureUri = new Uri("http://static.arcgis.com/images/Symbols/Animated/EnlargeGradientSymbol.png"); await matchSym.SetSourceAsync(pictureUri); var matchGraphic = new Graphic(matchLocation, matchSym); // Get a reference to the graphic layer you defined for the map, and add the new graphic. var graphicsLayer = MyMap.Layers["MyGraphics"] as GraphicsLayer; graphicsLayer.Graphics.Add(matchGraphic); // create a text symbol: define color, font, size, and text for the label var textSym = new Esri.ArcGISRuntime.Symbology.TextSymbol(); textSym.Color = Colors.DarkRed; textSym.Font = new Esri.ArcGISRuntime.Symbology.SymbolFont("Arial", 12); textSym.BackgroundColor = Colors.White; textSym.Text = p_textLabel; //textSym.Angle = -60; // create a graphic for the text (apply TextSymbol) var textGraphic = new Esri.ArcGISRuntime.Layers.Graphic(matchLocation, textSym); graphicsLayer.Graphics.Add(textGraphic); } }
// Create marker symbols private async Task SetupSymbolsAsync() { try { const int size = 24; // Create simple marker symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List <MarkerSymbol>() { new SimpleMarkerSymbol() { Color = Colors.Red, Size = 15, Style = SimpleMarkerStyle.Circle, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Green, Size = 15, Style = SimpleMarkerStyle.Diamond, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Blue, Size = 15, Style = SimpleMarkerStyle.Square, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Purple, Size = 15, Style = SimpleMarkerStyle.X, Outline = blackOutlineSymbol }, }; // Set image sources for picture marker symbols List <Task> setSourceTasks = new List <Task>(); var stickPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(stickPinSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png"))); _symbols.Add(stickPinSymbol); var pushPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(pushPinSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedPushpin.png"))); _symbols.Add(pushPinSymbol); var xPictureSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(xPictureSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png"))); _symbols.Add(xPictureSymbol); await Task.WhenAll(setSourceTasks); // Create image swatches for the UI Task <ImageSource>[] swatchTasks = _symbols .Select(sym => sym.CreateSwatchAsync(size, size, 96.0, Colors.Transparent)) .ToArray(); symbolCombo.ItemsSource = await Task.WhenAll(swatchTasks); } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
// Create marker symbols private async Task SetupSymbolsAsync() { try { int size = Convert.ToInt32(LayoutRoot.Resources["ImageSize"]); int sizePt = (int)((float)size / DisplayInformation.GetForCurrentView().LogicalDpi * 72); // Create simple marker symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List <MarkerSymbol>() { new SimpleMarkerSymbol() { Color = Colors.Red, Size = sizePt, Style = SimpleMarkerStyle.Circle, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Green, Size = sizePt, Style = SimpleMarkerStyle.Diamond, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Blue, Size = sizePt, Style = SimpleMarkerStyle.Square, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Purple, Size = sizePt, Style = SimpleMarkerStyle.X, Outline = blackOutlineSymbol }, }; // Set image sources for picture marker symbols List <Task> setSourceTasks = new List <Task>(); var stickPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(stickPinSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickpin.png"))); _symbols.Add(stickPinSymbol); var pushPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(pushPinSymbol.SetSourceAsync(new Uri("http://static.arcgis.com/images/Symbols/Basic/RedShinyPin.png"))); _symbols.Add(pushPinSymbol); var xPictureSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(xPictureSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/x-24x24.png"))); _symbols.Add(xPictureSymbol); await Task.WhenAll(setSourceTasks); // Create image swatches for the UI Task <ImageSource>[] swatchTasks = _symbols .Select(sym => sym.CreateSwatchAsync()) .ToArray(); symbolCombo.ItemsSource = await Task.WhenAll(swatchTasks); symbolCombo.SelectedIndex = 0; } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
private async void ConfigureMapView() { try { // Configure location display _mapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Recenter; _mapView.LocationDisplay.InitialZoomScale = 150; _mapView.LocationDisplay.IsEnabled = AppSettings.CurrentSettings.IsLocationServicesEnabled; } catch (Exception ex) { ErrorLogger.Instance.LogException(ex); ShowError("UnableToEnableLocationDisplayErrorTitle".Localize(), "UnableToEnabledLocationDisplayErrorMessage".Localize()); } try { // Configure identify overlay _identifiedFeatureOverlay = new GraphicsOverlay(); var pinImage = UIImage.FromBundle("MapPin"); var mapPin = await pinImage.ToRuntimeImageAsync(); var roomMarker = new PictureMarkerSymbol(mapPin) { OffsetY = pinImage.Size.Height * 0.65 }; _identifiedFeatureOverlay.Renderer = new SimpleRenderer(roomMarker); // Configure home location overlay _homeOverlay = new GraphicsOverlay(); var homeImage = UIImage.FromBundle("HomePin"); var homePin = await homeImage.ToRuntimeImageAsync(); var homeMarker = new PictureMarkerSymbol(homePin) { OffsetY = homeImage.Size.Height * 0.65 }; _homeOverlay.Renderer = new SimpleRenderer(homeMarker); // configure route overlay _routeOverlay = new GraphicsOverlay(); var routeSymbol = new SimpleLineSymbol { Width = 5, Style = SimpleLineSymbolStyle.Solid, Color = System.Drawing.Color.FromArgb(127, 18, 121, 193) }; // line symbol renderer will be used for every graphic without its own symbol _routeOverlay.Renderer = new SimpleRenderer(routeSymbol); // Keep route graphics at the ready _routeStartSymbol = new PictureMarkerSymbol(await UIImage.FromBundle("StartCircle").ToRuntimeImageAsync()); _routeEndSymbol = new PictureMarkerSymbol(await UIImage.FromBundle("EndCircle").ToRuntimeImageAsync()); // Add graphics overlays to the map _mapView.GraphicsOverlays.Add(_identifiedFeatureOverlay); _mapView.GraphicsOverlays.Add(_homeOverlay); _mapView.GraphicsOverlays.Add(_routeOverlay); } catch (Exception ex) { ErrorLogger.Instance.LogException(ex); // Show error and crash app since this is an invalid state. ShowError("UnableToConfigureMapErrorTitle".Localize(), "ApplicationWillCloseDueToErrorMessage".Localize(), null, System.Threading.Thread.CurrentThread.Abort); } }
private static MarkerSymbol cloneMarkerSymbol(MarkerSymbol symbol) { if (symbol == null) { return(null); } ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol imageFillSymbol = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol; if (imageFillSymbol != null) { ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol ifs = new ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol() { Color = CloneBrush(imageFillSymbol.Color), ControlTemplate = imageFillSymbol.ControlTemplate, OffsetX = imageFillSymbol.OffsetX, OffsetY = imageFillSymbol.OffsetY, OriginX = imageFillSymbol.OriginX, OriginY = imageFillSymbol.OriginY, Opacity = imageFillSymbol.Opacity, Size = imageFillSymbol.Size, ImageData = imageFillSymbol.ImageData, Source = imageFillSymbol.Source, Fill = CloneBrush(imageFillSymbol.Fill), CursorName = imageFillSymbol.CursorName, }; return(ifs); } ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol ms = symbol as ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol; if (ms != null) { ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol marSymb = new ESRI.ArcGIS.Mapping.Core.Symbols.MarkerSymbol() { DisplayName = ms.DisplayName, Offset = new Point(ms.Offset.X, ms.Offset.Y), Color = CloneBrush(ms.Color), ControlTemplate = ms.ControlTemplate, OffsetX = ms.OffsetX, OffsetY = ms.OffsetY, OriginX = ms.OriginX, OriginY = ms.OriginY, Opacity = ms.Opacity, Size = ms.Size, }; return(marSymb); } ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol simpleMarkerSymbol = symbol as ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol; if (simpleMarkerSymbol != null) { ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol sms = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol() { Color = CloneBrush(simpleMarkerSymbol.Color), ControlTemplate = simpleMarkerSymbol.ControlTemplate, Size = simpleMarkerSymbol.Size, // Simple marker symbol doesn't allow setting OffsetX, OffsetY }; return(sms); } TextSymbol textSymbol = symbol as TextSymbol; if (textSymbol != null) { TextSymbol ts = new TextSymbol() { ControlTemplate = textSymbol.ControlTemplate, FontFamily = textSymbol.FontFamily, FontSize = textSymbol.FontSize, Foreground = CloneBrush(textSymbol.Foreground), OffsetX = textSymbol.OffsetX, OffsetY = textSymbol.OffsetY, Text = textSymbol.Text, }; return(ts); } PictureMarkerSymbol pictureMarkerSymbol = symbol as PictureMarkerSymbol; if (pictureMarkerSymbol != null) { PictureMarkerSymbol pictMs = new PictureMarkerSymbol() { ControlTemplate = pictureMarkerSymbol.ControlTemplate, Height = pictureMarkerSymbol.Height, OffsetX = pictureMarkerSymbol.OffsetX, OffsetY = pictureMarkerSymbol.OffsetY, Opacity = pictureMarkerSymbol.Opacity, Source = pictureMarkerSymbol.Source, Width = pictureMarkerSymbol.Width, }; return(pictMs); } MarkerSymbol markerS = new MarkerSymbol() { ControlTemplate = symbol.ControlTemplate, OffsetX = symbol.OffsetX, OffsetY = symbol.OffsetY, }; return(markerS); }
/// <summary> /// When view is tapped, clear the map of selection, close keyboard and bottom sheet /// </summary> /// <param name="sender">Sender element.</param> /// <param name="e">Eevent args.</param> private async void MapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { // Wait for double tap to fire await Task.Delay(500); // If view has been double tapped, set tapped to handled and flag back to false // If view has been tapped just once clear the map of selection, close keyboard and bottom sheet if (this.isViewDoubleTapped == true) { e.Handled = true; this.isViewDoubleTapped = false; } else { // If route card is visible, do not dismiss route if (this.RouteCard.Alpha == 1) { // Create a new Alert Controller UIAlertController actionSheetAlert = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet); // Add Actions actionSheetAlert.AddAction(UIAlertAction.Create("Clear Route", UIAlertActionStyle.Destructive, (action) => this.ClearRoute())); actionSheetAlert.AddAction(UIAlertAction.Create("Keep Route", UIAlertActionStyle.Default, null)); // Required for iPad - You must specify a source for the Action Sheet since it is // displayed as a popover UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = this.View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the alert this.PresentViewController(actionSheetAlert, true, null); } else { // get the tap location in screen unit var tapScreenPoint = e.Position; var layer = this.MapView.Map.OperationalLayers[AppSettings.CurrentSettings.RoomsLayerIndex]; var pixelTolerance = 10; var returnPopupsOnly = false; var maxResults = 1; try { // Identify a layer using MapView, passing in the layer, the tap point, tolerance, types to return, and max result IdentifyLayerResult idResults = await this.MapView.IdentifyLayerAsync(layer, tapScreenPoint, pixelTolerance, returnPopupsOnly, maxResults); // create a picture marker symbol var uiImagePin = UIImage.FromBundle("MapPin"); var mapPin = this.ImageToByteArray(uiImagePin); var roomMarker = new PictureMarkerSymbol(new RuntimeImage(mapPin)); roomMarker.OffsetY = uiImagePin.Size.Height * 0.65; var identifiedResult = idResults.GeoElements.First(); // Create graphic var mapPinGraphic = new Graphic(identifiedResult.Geometry.Extent.GetCenter(), roomMarker); // Add pin to mapview var graphicsOverlay = this.MapView.GraphicsOverlays["PinsGraphicsOverlay"]; graphicsOverlay.Graphics.Clear(); graphicsOverlay.Graphics.Add(mapPinGraphic); // Get room attribute from the settings. First attribute should be set as the searcheable one var roomAttribute = AppSettings.CurrentSettings.ContactCardDisplayFields[0]; var roomNumber = identifiedResult.Attributes[roomAttribute]; if (roomNumber != null) { var employeeNameLabel = string.Empty; if (AppSettings.CurrentSettings.ContactCardDisplayFields.Count > 1) { var employeeNameAttribute = AppSettings.CurrentSettings.ContactCardDisplayFields[1]; var employeeName = identifiedResult.Attributes[employeeNameAttribute]; employeeNameLabel = employeeName as string ?? string.Empty; } this.ShowBottomCard(roomNumber.ToString(), employeeNameLabel.ToString(), false); } else { this.MapView.GraphicsOverlays["PinsGraphicsOverlay"].Graphics.Clear(); this.HideContactCard(); } } catch (Exception ex) { this.MapView.GraphicsOverlays["PinsGraphicsOverlay"].Graphics.Clear(); this.HideContactCard(); } if (this.LocationSearchBar.IsFirstResponder == true) { this.LocationSearchBar.ResignFirstResponder(); } } } }
private async void Initialize() { try { // Construct the map and set the MapView.Map property. _myMapView.Map = new Map(Basemap.CreateLightGrayCanvasVector()); // Add a graphics overlay to MyMapView. (Will be used later to display routes) _myMapView.GraphicsOverlays.Add(new GraphicsOverlay()); // Create a ClosestFacilityTask using the San Diego Uri. _task = await ClosestFacilityTask.CreateAsync(_closestFacilityUri); // Create a symbol for displaying facilities. PictureMarkerSymbol facilitySymbol = new PictureMarkerSymbol(new Uri("http://static.arcgis.com/images/Symbols/SafetyHealth/FireStation.png")) { Height = 30, Width = 30 }; // Incident symbol. PictureMarkerSymbol incidentSymbol = new PictureMarkerSymbol(new Uri("http://static.arcgis.com/images/Symbols/SafetyHealth/esriCrimeMarker_56_Gradient.png")) { Height = 30, Width = 30 }; // Create a list of line symbols to show unique routes. Different colors help make different routes visually distinguishable. _routeSymbols = new List <SimpleLineSymbol>() { new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 25, 45, 85), 5.0f), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 35, 65, 120), 5.0f), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 55, 100, 190), 5.0f), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(125, 75, 140, 255), 5.0f) }; // Create a table for facilities using the FeatureServer. _facilityTable = new ServiceFeatureTable(_facilityUri); // Create a feature layer from the table. _facilityLayer = new FeatureLayer(_facilityTable) { Renderer = new SimpleRenderer(facilitySymbol) }; // Create a table for facilities using the FeatureServer. _incidentTable = new ServiceFeatureTable(_incidentUri); // Create a feature layer from the table. _incidentLayer = new FeatureLayer(_incidentTable) { Renderer = new SimpleRenderer(incidentSymbol) }; // Add the layers to the map. _myMapView.Map.OperationalLayers.Add(_facilityLayer); _myMapView.Map.OperationalLayers.Add(_incidentLayer); // Wait for both layers to load. await _facilityLayer.LoadAsync(); await _incidentLayer.LoadAsync(); // Zoom to the combined extent of both layers. Envelope fullExtent = GeometryEngine.CombineExtents(_facilityLayer.FullExtent, _incidentLayer.FullExtent); await _myMapView.SetViewpointGeometryAsync(fullExtent, 50); // Enable the solve button. _solveRoutesButton.Enabled = true; } catch (Exception exception) { CreateErrorDialog("An exception has occurred.\n" + exception.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="StartPage"/> class. /// </summary> public StartPage() { InitializeComponent(); InitializeBasemapSwitcher(); PictureMarkerSymbol endMapPin = CreateMapPin("end.png"); PictureMarkerSymbol startMapPin = CreateMapPin("start.png"); var geocodeViewModel = Resources["GeocodeViewModel"] as GeocodeViewModel; var fromGeocodeViewModel = Resources["FromGeocodeViewModel"] as GeocodeViewModel; var toGeocodeViewModel = Resources["ToGeocodeViewModel"] as GeocodeViewModel; _routeViewModel = Resources["RouteViewModel"] as RouteViewModel; geocodeViewModel.PropertyChanged += (o, e) => { switch (e.PropertyName) { case nameof(GeocodeViewModel.Place): { var graphicsOverlay = MapView.GraphicsOverlays["PlacesOverlay"]; graphicsOverlay?.Graphics.Clear(); GeocodeResult place = geocodeViewModel.Place; if (place == null) { return; } var graphic = new Graphic(geocodeViewModel.Place.DisplayLocation, endMapPin); graphicsOverlay?.Graphics.Add(graphic); break; } } }; fromGeocodeViewModel.PropertyChanged += (o, e) => { switch (e.PropertyName) { case nameof(GeocodeViewModel.Place): { _routeViewModel.FromPlace = fromGeocodeViewModel.Place; break; } } }; toGeocodeViewModel.PropertyChanged += (o, e) => { switch (e.PropertyName) { case nameof(GeocodeViewModel.Place): { _routeViewModel.ToPlace = toGeocodeViewModel.Place; break; } } }; _routeViewModel.PropertyChanged += (s, e) => { switch (e.PropertyName) { case nameof(RouteViewModel.Route): { var graphicsOverlay = MapView.GraphicsOverlays["RouteOverlay"]; // clear existing graphics graphicsOverlay?.Graphics?.Clear(); if (_routeViewModel.FromPlace == null || _routeViewModel.ToPlace == null || _routeViewModel.Route == null || graphicsOverlay == null) { return; } // Add route to map var routeGraphic = new Graphic(_routeViewModel.Route.Routes.FirstOrDefault()?.RouteGeometry); graphicsOverlay?.Graphics.Add(routeGraphic); // Add start and end locations to the map var fromGraphic = new Graphic(_routeViewModel.FromPlace.RouteLocation, startMapPin); var toGraphic = new Graphic(_routeViewModel.ToPlace.RouteLocation, endMapPin); graphicsOverlay?.Graphics.Add(fromGraphic); graphicsOverlay?.Graphics.Add(toGraphic); break; } } }; // start location services var mapViewModel = Resources["MapViewModel"] as MapViewModel; MapView.LocationDisplay.DataSource = mapViewModel.LocationDataSource; MapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Recenter; MapView.LocationDisplay.IsEnabled = true; #if __IOS__ // This is necessary because on iOS the SearchBar doesn't get unfocused automatically when a geocode result is selected SearchSuggestionsList.ItemSelected += (s, e) => { AddressSearchBar.Unfocus(); }; FromLocationSuggestionsList.ItemSelected += (s, e) => { FromLocationTextBox.Unfocus(); }; ToLocationSuggestionsList.ItemSelected += (s, e) => { ToLocationTextBox.Unfocus(); }; #endif }
private void ShowFlag(MapCoord coord, Uri imageUri) { var mapPoint = coord.ToEsriWebMercatorMapPoint(); if (_flagsGraphicsLayer == null || mapPoint == null) { throw new ArgumentNullException("coord", "Coordinates or Graphic layers is null"); } var symbol = new PictureMarkerSymbol {Source = new BitmapImage(imageUri), OffsetX=1, OffsetY=30}; // Ação quando o usuário responder o local var graphic = new Graphic { Symbol = symbol, Geometry = mapPoint }; _flagsGraphicsLayer.Graphics.Add(graphic); }
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) { MessageBox.Show(e.ToString(), "Error"); } }
/// <summary> /// Fires when a new route is generated /// </summary> /// <returns>The new route</returns> private async Task OnRouteChangedAsync() { if (this.Route != null) { // get the route from the results var newRoute = this.Route.Routes.FirstOrDefault(); // create a picture marker symbol for start pin var uiImageStartPin = UIImage.FromBundle("StartCircle"); var startPin = this.ImageToByteArray(uiImageStartPin); var startMarker = new PictureMarkerSymbol(new RuntimeImage(startPin)); // create a picture marker symbol for end pin var uiImageEndPin = UIImage.FromBundle("EndCircle"); var endPin = this.ImageToByteArray(uiImageEndPin); var endMarker = new PictureMarkerSymbol(new RuntimeImage(endPin)); if (newRoute != null) { StringBuilder walkTimeStringBuilder = new StringBuilder(); // Add walk time and distance label if (newRoute.TotalTime.Hours > 0) { walkTimeStringBuilder.Append(string.Format("{0} h {1} m", newRoute.TotalTime.Hours, newRoute.TotalTime.Minutes)); } else { walkTimeStringBuilder.Append(string.Format("{0} min", newRoute.TotalTime.Minutes + 1)); } var tableSource = new List <Feature>() { this.FromLocationFeature, this.ToLocationFeature }; this.ShowRouteCard(tableSource, walkTimeStringBuilder.ToString()); // Create point graphics var startGraphic = new Graphic(newRoute.RouteGeometry.Parts.First().Points.First(), startMarker); var endGraphic = new Graphic(newRoute.RouteGeometry.Parts.Last().Points.Last(), endMarker); // create a graphic to represent the routee var routeSymbol = new SimpleLineSymbol(); routeSymbol.Width = 5; routeSymbol.Style = SimpleLineSymbolStyle.Solid; routeSymbol.Color = System.Drawing.Color.FromArgb(127, 18, 121, 193); var routeGraphic = new Graphic(newRoute.RouteGeometry, routeSymbol); // Add graphics to overlay this.MapView.GraphicsOverlays["RouteGraphicsOverlay"].Graphics.Clear(); this.MapView.GraphicsOverlays["RouteGraphicsOverlay"].Graphics.Add(routeGraphic); this.MapView.GraphicsOverlays["RouteGraphicsOverlay"].Graphics.Add(startGraphic); this.MapView.GraphicsOverlays["RouteGraphicsOverlay"].Graphics.Add(endGraphic); // Hide the pins graphics overlay this.MapView.GraphicsOverlays["PinsGraphicsOverlay"].IsVisible = false; try { await this.MapView.SetViewpointGeometryAsync(newRoute.RouteGeometry, 30); } catch { // If panning to the new route fails, just move on } } else { this.ShowBottomCard("Routing Error", "Please retry route", true); } } else { this.ShowBottomCard("Routing Error", "Please retry route", true); } }
/// <summary> /// Sets the value of the OriginalSource attached property to a specified PictureMarkerSymbol. /// </summary> /// <param name="element">The PictureMarkerSymbol to which the attached property is written.</param> /// <param name="value">The needed OriginalSource value.</param> public static void SetOriginalSource(PictureMarkerSymbol element, string value) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(OriginalSourceProperty, value); }
private void Initialize() { // Define the route stop locations (points) MapPoint fromPoint = new MapPoint(-112.068962, 33.638390, SpatialReferences.Wgs84); MapPoint toPoint = new MapPoint(-112.1028099, 33.7334937, SpatialReferences.Wgs84); // Create Stop objects with the points and add them to a list of stops Stop stop1 = new Stop(new MapPoint(-112.068962, 33.638390, SpatialReferences.Wgs84)); Stop stop2 = new Stop(new MapPoint(-111.994930, 33.618900, SpatialReferences.Wgs84)); Stop stop3 = new Stop(new MapPoint(-112.0021089, 33.6858299, SpatialReferences.Wgs84)); Stop stop4 = new Stop(new MapPoint(-111.9734644, 33.6348065, SpatialReferences.Wgs84)); Stop stop5 = new Stop(new MapPoint(-112.1028099, 33.7334937, SpatialReferences.Wgs84)); _routeStops = new List <Stop> { stop1, stop2, stop3, stop4, stop5 }; //// Create Stop objects with the points and add them to a list of stops //Stop stop1 = new Stop(fromPoint); //Stop stop2 = new Stop(toPoint); //_routeStops = new List<Stop> { stop1, stop2 }; // Picture marker symbols: from = car, to = checkered flag PictureMarkerSymbol carSymbol = new PictureMarkerSymbol(_carIconUri); PictureMarkerSymbol flagSymbol = new PictureMarkerSymbol(_checkedFlagIconUri); // Add a slight offset (pixels) to the picture symbols. carSymbol.OffsetX = -carSymbol.Width / 2; carSymbol.OffsetY = -carSymbol.Height / 2; flagSymbol.OffsetX = -flagSymbol.Width / 2; flagSymbol.OffsetY = -flagSymbol.Height / 2; // Set the height and width. flagSymbol.Height = 60; flagSymbol.Width = 60; carSymbol.Height = 60; carSymbol.Width = 60; // Create graphics for the stops Graphic fromGraphic = new Graphic(fromPoint, carSymbol) { ZIndex = 1 }; Graphic toGraphic = new Graphic(toPoint, flagSymbol) { ZIndex = 1 }; // Create the graphics overlay and add the stop graphics _routeGraphicsOverlay = new GraphicsOverlay(); _routeGraphicsOverlay.Graphics.Add(fromGraphic); _routeGraphicsOverlay.Graphics.Add(toGraphic); // Get an Envelope that covers the area of the stops (and a little more) Envelope routeStopsExtent = new Envelope(fromPoint, toPoint); EnvelopeBuilder envBuilder = new EnvelopeBuilder(routeStopsExtent); envBuilder.Expand(1.5); // Create a new viewpoint apply it to the map view when the spatial reference changes Viewpoint sanDiegoViewpoint = new Viewpoint(envBuilder.ToGeometry()); MyMapView.SpatialReferenceChanged += (s, e) => MyMapView.SetViewpoint(sanDiegoViewpoint); // Add a new Map and the graphics overlay to the map view MyMapView.Map = new Map(Basemap.CreateImageryWithLabelsVector()); MyMapView.GraphicsOverlays.Add(_routeGraphicsOverlay); }
private void Initialize() { _lostTime = DateTime.Now; _currentTime = DateTime.Now.AddHours(0.5); SetRadius(); Console.WriteLine(_radius); Console.WriteLine(DateTime.Now.ToString()); // Create a new map view, set its map, and provide the coordinates for laying it out _mapView = new MapView() { Map = _mapViewModel.Map // Use the map from the view-model }; // Create a new ArcGISVectorTiledLayer with the URI Selected by the user ArcGISVectorTiledLayer vectorTiledLayer = new ArcGISVectorTiledLayer(new Uri("https://ess.maps.arcgis.com/home/item.html?id=08155fea456d47279946f95134609d05")); // Create new Map with basemap _mapView.Map = new Map(new Basemap(vectorTiledLayer)); _mapView.GeoViewTapped += MyMapView_GeoViewTapped; //Create graphics overlays and add them _bufferOverlay = new GraphicsOverlay(); _barrierOverlay = new GraphicsOverlay(); _interestOverlay = new GraphicsOverlay(); _lostOverlay = new GraphicsOverlay(); _shelter = new MapPoint(-117.203551, 34.060069, SpatialReferences.Wgs84); PictureMarkerSymbol shelterPicture = new PictureMarkerSymbol(new Uri("http://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png")) { Height = 40, Width = 40 }; _mapView.GraphicsOverlays.Add(_bufferOverlay); _mapView.GraphicsOverlays.Add(_barrierOverlay); _mapView.GraphicsOverlays.Add(_interestOverlay); _mapView.GraphicsOverlays.Add(_lostOverlay); _interestOverlay.Graphics.Add(new Graphic(_shelter, new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.Red, 15))); //get redlands boundary // Create URI to the used feature service. Uri serviceUri = new Uri("https://services.arcgis.com/FLM8UAw9y5MmuVTV/ArcGIS/rest/services/CityLimits_Redlands/FeatureServer/0"); // Create new FeatureLayer by URL. _redlandsBoundary = new FeatureLayer(serviceUri); // Create URI to the used feature service. Uri waterUri = new Uri("https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/Hackathoughts/FeatureServer/1"); _water = new FeatureLayer(waterUri); _water.Renderer = new SimpleRenderer(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Blue, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 2.0))); //new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Blue, new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 5.0) ); Uri parkUri = new Uri("https://services.arcgis.com/FLM8UAw9y5MmuVTV/ArcGIS/rest/services/Redlands_Park_Boundaries/FeatureServer/0"); _parks = new FeatureLayer(parkUri); Uri buildingsUri = new Uri("https://services.arcgis.com/Wl7Y1m92PbjtJs5n/arcgis/rest/services/Hackathoughts2/FeatureServer/1"); _buildings = new FeatureLayer(buildingsUri); // Add layers to the map. _mapView.Map.OperationalLayers.Add(_redlandsBoundary); _mapView.Map.OperationalLayers.Add(_water); _mapView.Map.OperationalLayers.Add(_parks); _mapView.Map.OperationalLayers.Add(_buildings); _water.LoadAsync(); AsyncInitProcesses(); }