xiaoguang

Created Graphic with PictureFillSymbol don't show

Discussion created by xiaoguang on Sep 5, 2017
Latest reply on Sep 7, 2017 by xiaoguang

Hi, I use  PictureFillSymbol Class Constructors PictureFillSymbol(Uri) \ PictureFillSymbol(Runtime) or PictureFillSymbol.CreateAsync(Stream imageStream)  to create a PictureFillSymbol then use it to create a Graphic and add it to a GraphicOverlay, but the Graphic doesn't show, below is my codes

            // 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(
                "ArcGISRuntime.WPF.Resources.PictureMarkerSymbols.pin_star_blue.png");


            var runtimeimage = await RuntimeImage.FromStreamAsync(resourceStream);



            // Create new symbol using asynchronous factory method from stream
            PictureFillSymbol pinSymbol = new PictureFillSymbol(new Uri("pack://application:,,,/ArcGISRuntime.WPF.Samples.CSharp;component/Resources/PictureMarkerSymbols/pin_star_blue.png"));


           // (1) PictureFillSymbol pinSymbol = new PictureFillSymbol(runtimeimage);

           // (2) PictureFillSymbol pinSymbol =await PictureFillSymbol.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);

            MyMapView.GraphicsOverlays.Add(overlay);

 

Outcomes