Created Graphic with PictureFillSymbol don't show

805
2
09-05-2017 08:34 PM
xiaoguangyan
New Contributor III

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);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Tags (1)
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor

The following code works for me, `T` here is just a png with BuildAction=Embedded Resource. `Forum` was my project namespace. I think the reason it didn't work for you is because you have a PictureFillSymbol for MapPoint geometry. Did you mean to use PictureMarkerSymbol then?

            MyMapView.Map = new Map(Basemap.CreateTopographic());
            MyMapView.GraphicsOverlays.Add(new GraphicsOverlay());
            MyMapView.GeoViewTapped += async (s, e) =>
              {
                  var overlay = MyMapView.GraphicsOverlays.FirstOrDefault();
                  var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Forum.T.png");
                  var runtimeimage = await RuntimeImage.FromStreamAsync(resourceStream);
                  overlay.Graphics.Add(new Graphic(GeometryEngine.Buffer(e.Location, 1000), new PictureFillSymbol(runtimeimage)));
                  MyMapView.SetViewpoint(new Viewpoint(overlay.Extent));
              };
0 Kudos
xiaoguangyan
New Contributor III

Tahnks, Jennifer, I think I was using the PictureFillSymbol for MapPoint geometry 

0 Kudos