POST
|
This is an interesting question, but I think the basic answer is "no". The lowest level at which symbols are applied is for a geoelement (feature or graphic, ie), so it sounds like your approach of showing a larger geometry using geoelements for each segment is the best workaround. If you only want to display feature segments individually but not store them that way, you might consider a "hybrid" approach where you store only the larger feature in your dataset, but use a graphics overlay to display the segments with unique symbols. Especially if you only need to display segments for certain workflows. Perhaps allow the user to select a polyline that they want to see the segments for (?). Performance might be a concern if you start handling lots of segments (thousands). The guide doc topic here has some tips for improving performance when working with a graphics-intensive app: https://developers.arcgis.com/net/programming-patterns/performance-considerations/#graphics One tip is to use a renderer for a graphics overlay rather than symbols for each graphic. To implement that, you might do something like generate a random number for each graphic (perhaps between 1-10, eg) and apply a renderer to the overlay that shows a unique color for each possible value (1-10, or whatever range you use).
... View more
09-08-2022
11:13 AM
|
0
|
0
|
634
|
POST
|
I think you're just missing the quotes around the guid value: WhereClause = $"GUID LIKE '{guid}'" Here's the code that worked for me: private async void CreatePolyButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
var poly = await MyMapView.SketchEditor.StartAsync(SketchCreationMode.Polygon, false);
string guid = Guid.NewGuid().ToString();
var attr = new Dictionary<string, object>
{
{ "GUID", guid }
};
var graphic = new Graphic(poly, attr);
_overlay.Graphics.Add(graphic);
var labelDef = GetGraphicLabelDef(System.Drawing.Color.Firebrick, guid);
_overlay.LabelDefinitions.Clear();
_overlay.LabelsEnabled = true;
_overlay.LabelDefinitions.Add(labelDef);
}
private LabelDefinition GetGraphicLabelDef(System.Drawing.Color color, string guid)
{
// Create a text symbol for styling the label.
TextSymbol textSymbol = new TextSymbol
{
Size = 12,
FontFamily = "Arial",
Color = color,
HaloColor = Color.White,
HaloWidth = 2,
};
// Create a label expression using an Arcade expression script.
LabelExpression arcadeLabelExpression = new ArcadeLabelExpression("$feature.GUID");
// Create a new LabelInfo object and set the relevant properties (including the text symbol).
var labelInfo = new LabelClassInfo(GeometryType.Polygon)
{
LabelPosition = LabelPosition.Static,
ArcadeExpression = arcadeLabelExpression.Expression,
MinScale = 0,
MaxScale = 0,
LabelPlacement = LabelPlacement.PolygonAlwaysHorizontal,
Priority = 30,
RemoveDuplicateLabels = DuplicateLabels.FeatureType,
StackLabel = true,
Symbol = textSymbol,
WhereClause = $"GUID LIKE '{guid}'"
};
// Get the raw JSON from the label info object.
string labelJson = labelInfo.ToJson();
// Create a new label definition from the JSON string.
LabelDefinition labelDef = LabelDefinition.FromJson(labelJson);
return labelDef;
}
... View more
08-17-2022
12:36 PM
|
0
|
2
|
894
|
POST
|
If you have more than just a few graphics, it probably wouldn't make sense to have a different label class for each one. I guess it depends on what your use case is. If you're doing something like showing the selected geoelement with a special label, you can have a dedicated label class for a selected graphic's label and then dynamically set the where clause on the class to include just the one graphic. But yes, you can also modify the label symbol at run time as well to change font, size, color, etc.
... View more
08-15-2022
08:17 AM
|
0
|
4
|
899
|
POST
|
Here's the function: private Geometry CreateDensifiedWedgeGeometry(MapPoint center, double radius, double arcAngle, double azimuth)
{
SpatialReference spatialReference = center.SpatialReference;
// Get the angle of the azimuth.
var directionAngle = 90 - azimuth;
directionAngle = (directionAngle < 0) ? directionAngle + 360 : directionAngle;
directionAngle = (directionAngle > 360) ? directionAngle - 360 : directionAngle;
// Subtract half of the arc angle from the direction (wedge should be split by the azimuth angle).
var startPointDegrees = directionAngle - (arcAngle / 2);
startPointDegrees = (startPointDegrees < 0) ? startPointDegrees + 360 : startPointDegrees;
startPointDegrees = (startPointDegrees > 360) ? startPointDegrees - 360 : startPointDegrees;
// Get the radian values of the angles.
var startPointRadians = startPointDegrees * Math.PI / 180.0;
var arcAngleRadians = arcAngle * Math.PI / 180;
// Create an arc segment with the center point, radius, start point of the arc, arc angle, and spatial reference.
EllipticArcSegment arc = EllipticArcSegment.CreateCircularEllipticArc(center, radius, startPointRadians, arcAngleRadians, spatialReference);
// create the sides of the wedge (center point to start/end points of the arc).
var startSide = new LineSegment(center, arc.StartPoint);
//var endSide = new LineSegment(center, arc.EndPoint);
// Create the wedge-shaped polygon.
PolygonBuilder builder = new PolygonBuilder(spatialReference);
// Note: only need to add one of the sides to complete the polygon.
builder.AddPart(
new Part(new Segment[]
{
startSide,
arc
}, spatialReference)
);
// Densify the arc for display in 3D.
var densifiedPoly = GeometryEngine.Densify(builder.ToGeometry(), 100000);
return densifiedPoly; // builder.ToGeometry();
} I call it with this: private void CreateWedgeButton_Click(object sender, RoutedEventArgs e)
{
MapPoint origin = new MapPoint(x: 40e5, y: 5e5, SpatialReferences.WebMercator);
Geometry wedgeGeometry = CreateDensifiedWedgeGeometry(origin, 1000000, 90, 360);
Graphic wedgeGraphic = new Graphic(wedgeGeometry);
var curvedGraphicsOverlay = MySceneView.GraphicsOverlays["curvedoverlay"];
curvedGraphicsOverlay.Graphics.Add(wedgeGraphic);
MySceneView.SetViewpoint(new Viewpoint(wedgeGeometry));
}
... View more
08-11-2022
03:25 PM
|
1
|
0
|
984
|
POST
|
It would change it for all labels in the label definition. When you create a label definition, you can use a where clause to restrict which features are included. That allows you to do things like label major cities with a different label than smaller ones, etc. I don't think that was illustrated in the JSON class example, but it would look something like this (notice the addition of the 'WhereClause'). // Create a new LabelInfo object and set the relevant properties (including the text symbol).
LabelClassInfo labelInfo = new LabelClassInfo()
{
LabelPosition = "static",
ArcadeExpression = "return $feature['" + LabelFieldComboBox.SelectedItem + "'];",
MinScale = 0,
MaxScale = 0,
Priority = 30,
RemoveDuplicateLabels = "featureType",
StackLabel = true,
Symbol = textSymbol,
WhereClause = $"POP2020 > 1000000"
};
// Get the raw JSON from the label info object.
labelJson = labelInfo.GetJson();
// Create a new label definition from the JSON string.
LabelDefinition labelDef = LabelDefinition.FromJson(labelJson); This will label all features with a POP2020 attribute value greater than one million using the symbol defined. If you change the font or other properties of the symbol, it will only change the labels in this definition. If you need to narrow this down to a single feature, you could use a where clause based on a unique ID and then control that one feature's label. Your other option would be to add a graphic to display the label for the feature. You can create a point to define where the label should appear, apply the appropriate TextSymbol, and then add it to a GraphicsOverlay in the view (see doc here for more info: https://developers.arcgis.com/net/maps-2d/add-graphics-to-a-map-view/#display-text).
... View more
08-10-2022
04:25 PM
|
0
|
1
|
921
|
POST
|
I think the way you were doing it should work well, simply changing the text symbol properties on the label class. I tested a little and found that code like this worked as expected to change the font family for my labels. _labelDefinition.TextSymbol.FontFamily = FontFamilyTextBox.Text.Trim(); The "_labelDefinition" variable is one of the label definitions defined for a feature layer. I simply stored it as a member variable so I could refer to it later. I did find that some fonts didn't work (like Segoe UI Emoji, eg) and the labels would just fall back to something like Arial. I also noticed that some fonts would result in a larger label and change which features labels were displayed. One caveat, I was testing using the same JSON label class but with a newer version of runtime (100.14).
... View more
08-09-2022
03:36 PM
|
0
|
1
|
927
|
POST
|
Hey Francisco, for display in 3D, you need to densify the arc. This will represent the arc as a series of linear segments rather than a true curve. The tricky part might be finding the ideal "maxSegmentLength" to get a smooth curve (without going too small, which could hurt performance). Here's an example of densifying so the returned "curve" is composed of segments not less than 10,000 meters (10 km). // Densify the arc for display in 3D.
var densifiedPoly = GeometryEngine.Densify(builder.ToGeometry(), 10000);
return densifiedPoly; // builder.ToGeometry();
... View more
08-09-2022
12:54 PM
|
0
|
2
|
989
|
POST
|
Hey Luis! That's an extension method in Esri.ArcGISRuntime.UI. If you add the following "using" statement to the top of your code file, you should see it. using Esri.ArcGISRuntime.UI;
... View more
08-05-2022
04:58 PM
|
0
|
0
|
549
|
POST
|
This seems to work, perhaps give it a test to make sure you get the correct shape based on your inputs. private Geometry CreateWedgeGeometry(MapPoint center, double radius, double arcAngle, double azimuth)
{
SpatialReference spatialReference = center.SpatialReference;
// Get the angle of the azimuth.
var directionAngle = 90 - azimuth;
directionAngle = (directionAngle < 0) ? directionAngle + 360 : directionAngle;
directionAngle = (directionAngle > 360) ? directionAngle - 360 : directionAngle;
// Subtract half of the arc angle from the direction (wedge should be split by the azimuth angle).
var startPointDegrees = directionAngle - (arcAngle / 2);
startPointDegrees = (startPointDegrees < 0) ? startPointDegrees + 360 : startPointDegrees;
startPointDegrees = (startPointDegrees > 360) ? startPointDegrees - 360 : startPointDegrees;
// Get the radian values of the angles.
var startPointRadians = startPointDegrees * Math.PI / 180.0;
var arcAngleRadians = arcAngle * Math.PI / 180;
// Create an arc segment with the center point, radius, start point of the arc, arc angle, and spatial reference.
EllipticArcSegment arc = EllipticArcSegment.CreateCircularEllipticArc(center, radius, startPointRadians, arcAngleRadians, spatialReference);
// create the sides of the wedge (center point to start/end points of the arc).
var startSide = new LineSegment(center, arc.StartPoint);
//var endSide = new LineSegment(center, arc.EndPoint);
// Create the wedge-shaped polygon.
PolygonBuilder builder = new PolygonBuilder(spatialReference);
// Note: only need to add one of the sides to complete the polygon.
builder.AddPart(
new Part(new Segment[]
{
startSide,
arc
}, spatialReference)
);
return builder.ToGeometry();
} Based on your image, "arcAngle" is α, and "radius" is D. The "azimuth" defines the orientation (compass direction) of the wedge. To create something like what's shown in your image, you'd call it like this: Geometry wedge = CreateWedgeGeometry(originPoint, 1000000, 90.0, 360.0); Hope that helps, Thad
... View more
08-05-2022
04:50 PM
|
1
|
6
|
1024
|
POST
|
Hi, I'm sorry to hear the JSON label code isn't working for you. The good news is, as of v100.11, ArcGIS Runtime provides a labeling API to wrap this functionality. If you're able to move to a more recent version, perhaps try using the API to add your labels. You'll find more details in the developer guide here: https://developers.arcgis.com/net/styles-and-data-visualization/add-labels/
... View more
08-05-2022
11:30 AM
|
0
|
3
|
937
|
POST
|
Hi Harold! While not a video, I think this tutorial can help get you started: https://developers.arcgis.com/net/maps-2d/tutorials/display-a-map/ If you have further questions, please post a question in the runtime thread: https://community.esri.com/t5/arcgis-runtime-sdks/ct-p/arcgis-runtime-sdks -Thad
... View more
06-21-2021
10:22 AM
|
1
|
0
|
1105
|
POST
|
Hey Chris - This is an excellent question and something we need to document better. When you run QueryFeaturesAsync, you're querying the local version of the data. Depending on your caching mode (ServiceFeatureTable.FeatureRequestMode), this may not include all the features available in the service. PopulateFromServiceAsync, on the other hand, runs the query on the feature service and populates your local version of the table with the results. I hope that helps! Thad
... View more
02-13-2020
11:08 AM
|
0
|
2
|
1000
|
POST
|
Hi! Do you want to render each symbol primitive in the style and add it to a list or grid? Or do you want to display symbols generated from the style for a particular feature (set of attributes)? To get the symbol for a set of attributes, use DictionarySymbolStyle.GetSymbolAsync. For searching symbols by category, etc. see DictionarySymbolStyle.SearchSymbolsAsync (you can then iterate the results). You can find some good examples in the samples: - Read samples from a mobile style (see the GetCurrentSymbol function for getting a symbol for a set of attributes and ReadMobileStyle for an example of iterating all symbols in the style) - Custom dictionary style - an example of using a custom dictionary style I hope that helps! Thad
... View more
10-25-2019
09:06 AM
|
0
|
1
|
729
|
POST
|
Yeah, I agree with Joe, you might want to experiment with some other relationships just to see what you get. Maybe it's a spatial reference issue? Are you sure the geometry you're querying with is coincident with the input features? Perhaps, as a quick test, you could try zooming to the extent of the envelope used for the query.
... View more
07-26-2019
11:02 AM
|
0
|
1
|
722
|
POST
|
Hi Gonzalo, The `GraphicsOverlays` collection also has methods to manage the order of the `GraphicsOverlays` it contains (Add, Insert, Move, Remove, etc.). Within a `GraphicsOverlay`, you can also set a z-index property on individual graphics. A larger z-index means the graphic is higher in the draw order (for graphics in the same overlay). bottomGraphic.ZIndex = 0;
topGraphic.ZIndex = 1; Note: Graphics overlays *always* draw on top of layers in the map. Thad
... View more
07-26-2019
10:34 AM
|
2
|
0
|
1145
|
Title | Kudos | Posted |
---|---|---|
1 | 03-14-2019 01:59 PM | |
1 | 10-17-2023 12:39 PM | |
1 | 10-30-2023 11:55 AM | |
1 | 10-28-2023 12:47 PM | |
2 | 10-28-2023 11:56 AM |
Online Status |
Online
|
Date Last Visited |
6 hours ago
|