1

I am having an issue in my MVVM client app going from ESRI.ArcGISRuntime.Toolkit v10.2.7.0 into ESRI ArcGISRuntime v100.1, where the symbols I was using to locate a stop are randomly not being created. I pass a List into the following method:

 private async void SetMapSymbols()
    {
        var previousLayer = GraphicsLayer[SEARCH_LAYER];
        GraphicsLayer.Remove(previousLayer);

        var graphicsOverlay = new GraphicsOverlay() { Id = SEARCH_LAYER };
        var graphicList = new List<Graphic>();

        int order = 0;

        foreach (ObjectInfoModel entry in ObjectList)
        {
            order++;

            if (entry.SiteGeoLat == null || entry.SiteGeoLong == null) continue;

            var pointAttribList = ConvertObjectToDictionary(entry);
            DictionaryUtility.AddItemTodictionaryAttribute(pointAttribList, ORDER_ATTRIBUTE, order.ToString());
            var geo = entry.AltSiteGeoLat != null && entry.AltSiteGeoLong != null ? WebMercatorUtility.ConvertToMercator(entry.AltSiteGeoLong.Value, entry.AltSiteGeoLat.Value) : WebMercatorUtility.ConvertToMercator(entry.SiteGeoLong.Value, entry.SiteGeoLat.Value);
            var graphic = new Graphic(
                        new MapPoint(geo.Lon, geo.Lat, new SpatialReference(SPATIAL_REFERENCE)),
                        pointAttribList,
                     string.IsNullOrEmpty(entry.Area) ? await SymbolUtility.CreateSymbols(order.ToString(), SymbolTypes.Blue, SymbolShapes.Pin) :
                                                                await SymbolUtility.CreateSymbols(order.ToString(), SymbolTypes.Red, SymbolShapes.Arrow));
            if (entry.SiteGeoTypeCode != MAPPABLE)
            {
                graphic.Symbol = string.IsNullOrEmpty(entry.Area) ? await SymbolUtility.CreateSymbols(order.ToString(), SymbolTypes.Blue, SymbolShapes.Pin2) :
                                                                             await SymbolUtility.CreateSymbols(order.ToString(), SymbolTypes.Red, SymbolShapes.Arrow2);
            }

            graphicList.Add(graphic);

        }

        graphicList.ForEach(x => graphicsOverlay.Graphics.Add(x));
        GraphicsLayer.Add(graphicsOverlay);
    }

As you can see, it awaits the SymbolUtility to create a symbol for each item in the list. So here is that method:

        public static async Task<Symbol> CreateSymbols(string text, SymbolTypes type, SymbolShapes shape)
    {
        var iconPath = string.Empty;
        iconPath = string.Format(@"pack://application:,,,/Images/{0}_{1}.png", type.ToString(), shape.ToString());

        var pc = new PictureMarkerSymbol(new Uri(iconPath, UriKind.RelativeOrAbsolute));
        pc.Width = 30;
        pc.Height = 30;

        var cm = new CompositeSymbol();
        var ts = new TextSymbol()
        {
            Color = Colors.Black,
            FontStyle = FontStyle.Normal,
            FontDecoration = FontDecoration.None,
            FontFamily = "Arial",
            FontWeight = FontWeight.Bold,
            Size = 14,
            VerticalAlignment = VerticalAlignment.Middle,
            HorizontalAlignment = HorizontalAlignment.Center,
            OffsetY = shape == SymbolShapes.Arrow ? 5 : 0
        };

        ts.Text = text;
        cm.Symbols.Add(pc);
        cm.Symbols.Add(ts);

        return await Task.Factory.StartNew<Symbol>(() => { return cm; });
    }

The PNG files are located in the same solution as the Utility, but not the same project. The issue that is occurring is the symbol wont render the PNG part randomly, but will always return the text part of the symbol.

Picture with 3 point locations, two without the PNG rendering

If anyone has any ideas on this, I would be very appreciative.

tCoe
  • 401
  • 1
  • 5
  • 24

1 Answers1

1

If icon path was used in an Image control, do you see the image? It may be that icon path is incorrect or build action or copy to output directory need to change (see: msdn doc) If the icon path is good, does the symbol render outside CompositeSymbol (using only PictureMarkerSymbol)? If yes, does it get fixed by updating SDK to 100.4 or maybe updating GraphicsRenderingMode or maybe as you zoom-in/out of the map?

I am not able to reproduce with the following code where note.png is added as Content, Copy if newer.

MyMapView.Map = new Map(SpatialReferences.Wgs84);
var symbol = new CompositeSymbol();
symbol.Symbols.Add(new PictureMarkerSymbol(new Uri("pack://application:,,,/note.png")));
symbol.Symbols.Add(new TextSymbol("1", Color.Black, 10, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle));
var overlay = new GraphicsOverlay();
overlay.Graphics.Add(new Graphic(new MapPoint(0, 0), symbol));
MyMapView.GraphicsOverlays.Add(overlay);

Fellow ArcGIS Runtime developers might be able to help you in this forum.

jnery
  • 11
  • 1
  • I know that the path is good to the PNG image, and zooming in and out doesn't fix the icon, once it is like those in the snip above. The only thing that fixes it is reloading the map. I will be able to try the format you use tomorrow. Thank you very much for the suggestions and the link. If your suggestion doesn't help I will go there. – tCoe Dec 26 '18 at 22:36
  • Unfortunately, this did not resolve my issue. However, it is a much cleaner way to construct the symbol so i will still use it. – tCoe Dec 27 '18 at 17:15