// Create a random graphic private Graphic CreateRandomGraphic(int id) { var symbol = new CompositeSymbol(); symbol.Symbols.Add(new SimpleMarkerSymbol() { Style = SimpleMarkerStyle.Circle, Color = Colors.Red, Size = 16 }); symbol.Symbols.Add(new TextSymbol() { Text = id.ToString(), Color = Colors.White, VerticalTextAlignment = VerticalTextAlignment.Middle, HorizontalTextAlignment = HorizontalTextAlignment.Center, YOffset = -1 }); var graphic = new Graphic() { Geometry = GetRandomMapPoint(), Symbol = symbol }; graphic.Attributes["ID"] = id; return(graphic); }
private Graphic CreateStopGraphic(MapPoint location, int id) { var symbol = new CompositeSymbol(); symbol.Symbols.Add(new SimpleMarkerSymbol() { Style = SimpleMarkerStyle.Circle, Color = Colors.Blue, Size = 16 }); symbol.Symbols.Add(new TextSymbol() { Text = id.ToString(), Color = Colors.White, VerticalTextAlignment = VerticalTextAlignment.Middle, HorizontalTextAlignment = HorizontalTextAlignment.Center, YOffset = -1 }); var graphic = new Graphic() { Geometry = location, Symbol = symbol }; return(graphic); }
private async void AddStop(Android.Graphics.PointF 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, Color.White, 15, HorizontalAlignment.Center, 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); // Add the stop to the overlay. _stopsOverlay.Graphics.Add(newStopGraphic); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); ShowMessage("Couldn't select or add stop", "Couldn't select or add stop. See debug output for details."); } }
private Graphic CreateGraphic(Dictionary <string, object> attributes, double latitude, double longitude, string iconPath, int?countSymbol = 0) { CompositeSymbol compositeSymbol = new CompositeSymbol(); PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol(); TextSymbol textSymbol = new TextSymbol(); pictureMarkerSymbol.SetSourceAsync(new Uri(iconPath)); compositeSymbol.Symbols.Add(pictureMarkerSymbol); if (countSymbol.HasValue && countSymbol != 0) { textSymbol.Text = countSymbol.ToString(); textSymbol.HorizontalTextAlignment = HorizontalTextAlignment.Center; textSymbol.VerticalTextAlignment = VerticalTextAlignment.Middle; textSymbol.Font.FontSize = 18; textSymbol.YOffset = 7; textSymbol.Color = (Color)ColorConverter.ConvertFromString("#d91e18"); compositeSymbol.Symbols.Add(textSymbol); } var graphics = new Graphic(new MapPoint(longitude, latitude, new SpatialReference(4326)), compositeSymbol); foreach (KeyValuePair <string, object> item in attributes) { graphics.Attributes.Add(item.Key, item.Value); } graphics.ZIndex = MARKER_Z_INDEX; return(graphics); }
private void LoadEntireNmeaTrack(string filename) { var layer = mapView.GraphicsOverlays.First(); layer.Graphics.Clear(); if (currentNmeaFile == null) return; List<MapPoint> vertices = new List<MapPoint>(); using (var sr = System.IO.File.OpenText(filename)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line != null && line.StartsWith("$")) { try { var msg = NmeaParser.Messages.NmeaMessage.Parse(line); if (msg is NmeaParser.Messages.Rmc rmc) { if (!double.IsNaN(rmc.Longitude)) vertices.Add(new MapPoint(rmc.Longitude, rmc.Latitude)); } } catch { } } } } var pline = new Esri.ArcGISRuntime.Geometry.Polyline(vertices, SpatialReferences.Wgs84); var linesymbol = new SimpleLineSymbol() { Width = 4, Color = System.Drawing.Color.CornflowerBlue }; var symbol = new CompositeSymbol(); symbol.Symbols.Add(linesymbol); symbol.Symbols.Add(new SimpleMarkerSymbol() { Size = 5, Color = System.Drawing.Color.Black }); layer.Graphics.Add(new Graphic(pline, symbol)); }
/// <summary> /// 获取聚合图形,用户地图展示 /// </summary> /// <returns></returns> public Graphic GetGraphic() { if (Graphics.Count == 1) { return(Graphics[0]); } var g = new Graphic { Geometry = _center }; var cs = new CompositeSymbol(); var sms = new SimpleMarkerSymbol { Outline = new SimpleLineSymbol(), Size = _size }; //聚合数量占比超过30%时,显示为红色 if (100.0 * Graphics.Count / _totalCount > 30) { sms.Color = System.Windows.Media.Color.FromArgb(100, 255, 0, 0); } else if (100.0 * Graphics.Count / _totalCount > 5) { sms.Color = System.Windows.Media.Color.FromArgb(100, 0, 0, 255); } else { sms.Color = System.Windows.Media.Color.FromArgb(100, 0, 255, 0); } sms.Outline.Color = System.Windows.Media.Color.FromArgb(255, 0, 0, 0); sms.Outline.Width = 1; cs.Symbols.Add(sms); var ts = new TextSymbol { HorizontalTextAlignment = HorizontalTextAlignment.Center, VerticalTextAlignment = VerticalTextAlignment.Baseline, Font = { FontSize = 14, FontWeight = SymbolFontWeight.Bold }, Text = Graphics.Count.ToString() }; cs.Symbols.Add(ts); g.Symbol = cs; return(g); }
private Graphic CreateGraphic(double Latitude, double Longitude, string IconPath) { CompositeSymbol compositeSymbol = new CompositeSymbol(); PictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbol(); pictureMarkerSymbol.SetSourceAsync(new Uri(IconPath)); compositeSymbol.Symbols.Add(pictureMarkerSymbol); var graphics = new Graphic(new MapPoint(Longitude, Latitude, new SpatialReference(4326)), compositeSymbol); return(graphics); }
public T CreatSymbol <T>() where T : Symbol { var symbol = new CompositeSymbol(); symbol.Symbols.Add(new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = Colors.Red, Size = 17 }); symbol.Symbols.Add(new TextSymbol { Text = "景", //中文支持有问题 解决方案:设置字体即可 Font = new SymbolFont("宋体", 15), Color = Colors.White, VerticalTextAlignment = VerticalTextAlignment.Middle, HorizontalTextAlignment = HorizontalTextAlignment.Center, YOffset = -1 }); return(symbol as T); }
private Graphic CreateStopGraphic(MapPoint location, int id) { var symbol = new CompositeSymbol(); symbol.Symbols.Add(new SimpleMarkerSymbol() { Style = SimpleMarkerStyle.Circle, Color = Colors.Blue, Size = 16 }); symbol.Symbols.Add(new TextSymbol() { Text = id.ToString(), Color = Colors.White, VerticalTextAlignment = VerticalTextAlignment.Middle, HorizontalTextAlignment = HorizontalTextAlignment.Center, YOffset = -1 }); var graphic = new Graphic() { Geometry = location, Symbol = symbol }; return graphic; }
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, System.Drawing.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; } }
// Create a random graphic private Graphic CreateRandomGraphic(int id) { var symbol = new CompositeSymbol(); symbol.Symbols.Add(new SimpleMarkerSymbol() { Style = SimpleMarkerStyle.Circle, Color = Colors.Red, Size = 16 }); symbol.Symbols.Add(new TextSymbol() { Text = id.ToString(), Color = Colors.White, VerticalTextAlignment = VerticalTextAlignment.Middle, HorizontalTextAlignment = HorizontalTextAlignment.Center, YOffset = -1 }); var graphic = new Graphic() { Geometry = GetRandomMapPoint(), Symbol = symbol }; graphic.Attributes["ID"] = id; return graphic; }
public static CompositeSymbol CreateEntityCompositeSymbol(string label, bool isGrayed) { // Composite symbol is used to collate all the constituent parts var compositeSymbol = new CompositeSymbol(); // Reversed triangle symbol var triangleSymbol = CreatePointMarker(isGrayed); // Map point marker compositeSymbol.Symbols.Add(triangleSymbol); // Entity label double textHeight; var entityLabelSymbol = CreateEntityLabelSymbol(label, triangleSymbol, isGrayed, out textHeight); //compositeSymbol.Symbols.Add(entityLabelSymbol); // Don't add text symbols (we'll get to this later) // Entity icon symbol var entityIconSymbol = CreateEntityIconSymbol(entityLabelSymbol, textHeight); compositeSymbol.Symbols.Add(entityIconSymbol); return(compositeSymbol); }
private void LoadEntireNmeaTrack(string filename) { var layer = mapView.Map.Layers.OfType<GraphicsLayer>().First(); layer.Graphics.Clear(); if (currentNmeaFile == null) return; List<MapPoint> vertices = new List<MapPoint>(); using (var sr = System.IO.File.OpenText(filename)) { while (!sr.EndOfStream) { var line = sr.ReadLine(); if (line.StartsWith("$")) { try { var msg = NmeaParser.Nmea.NmeaMessage.Parse(line); if (msg is NmeaParser.Nmea.Gps.Gprmc) { var rmc = (NmeaParser.Nmea.Gps.Gprmc)msg; if (!double.IsNaN(rmc.Longitude)) vertices.Add(new MapPoint(rmc.Longitude, rmc.Latitude)); } } catch { } } } } var pline = new Esri.ArcGISRuntime.Geometry.Polyline(vertices, SpatialReferences.Wgs84); var linesymbol = new SimpleLineSymbol() { Width = 4, Color = Colors.CornflowerBlue }; var symbol = new CompositeSymbol(); symbol.Symbols.Add(linesymbol); symbol.Symbols.Add(new SimpleMarkerSymbol() { Size = 5, Color = Colors.Black }); Esri.ArcGISRuntime.Layers.Graphic g = new Esri.ArcGISRuntime.Layers.Graphic(pline, symbol); layer.Graphics.Add(g); }