0

这是我绑定到标注的格式化字符串,但我只能在标注中看到我的字符串的一些内容

private async void WebMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
    {
    try
    {
    WebMapView.DismissCallout();
    MapPoint mapLocation = null;
    var layers = await WebMapView.IdentifyLayersAsync(e.Position, 20, false);
    if (layers.Count > 0)
    {
    foreach (var idResults in layers)
    {
    FeatureLayer idLayer = idResults.LayerContent as FeatureLayer;

                        await idLayer.LoadAsync();


                        var result = layers.First();
                        var feature = result.GeoElements.First() as ArcGISFeature;
                        await feature.LoadAsync(); // Load feature to get all attributes
                        Feature idFeature = result.GeoElements.First() as Feature;
                        featureAttrs = idFeature.Attributes;

                        var stateExtent = idFeature.Geometry;

                        Graphicoverlay = new GraphicsOverlay();
                        Graphic graphicLine = null;

                        graphicLine = new Graphic(stateExtent, AppConstant.HighLight1);
                        Graphicoverlay.Graphics.Add(graphicLine);

                        EnvelopeBuilder myEnvelopeBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);
                        //Geometry abd = oneGraphic.Geometry;
                        myEnvelopeBuilder.UnionOf(graphicLine.Geometry.Extent);
                        myEnvelopeBuilder.Expand(1.3);

                        mapLocation = myEnvelopeBuilder.Center;

                        Geometry myGeometry = GeometryEngine.Project(mapLocation, SpatialReferences.WebMercator);
                        MapPoint projectedLocation = (MapPoint)myGeometry;
                        string formattedString = "";
                        if (featureAttrs.Count > 0)
                        {
                            foreach (var attributes in featureAttrs)
                            {
                                string recordOneAttribute = $"{attributes.Key}  {attributes.Value}";
                                formattedString = $"{formattedString}\n{ recordOneAttribute}";
                            }
                        }
                        CalloutDefinition calloutDef = new CalloutDefinition("Feature:",formattedString);


                        WebMapView.ShowCalloutAt(mapLocation, calloutDef);

                    }

        }
4

0 回答 0