none
map:MapControl MapIcon how to add photos to the map RRS feed

  • Question

  • map:MapControl MapIcon how to add photos to the map

    Map Icon format icon. The Image or Bitmap format is not suitable.
    How to marry all this. For example, add a photo from a file to the card.
    Bing Maps was all that simple.

    Saturday, January 18, 2020 7:59 PM

Answers

  • everything turned out to be easier

                                        string fileIcon = App.persons.ElementAt(i).field_Id + ".jpg";
                                        StorageFile dstFile = await App.pub_fotoFolder.GetFileAsync(fileIcon);
                                        if (dstFile != null)
                                        {
                                            IRandomAccessStream fileStream = await dstFile.GetThumbnailAsync(ThumbnailMode.PicturesView, 32, ThumbnailOptions.ResizeThumbnail);
                                            mapIcon.Image = RandomAccessStreamReference.CreateFromStream(fileStream);
                                        }
    

    Sunday, January 19, 2020 4:39 PM

All replies

  • Hi Dmitriy,

    Can you give more detail as to what you would like to accomplish?  If you wish to overlay imagery, there are a number of different ways this can be accomplished including using an overlay like https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/overlay-tiled-images

    Sincerely,

    IoTGirl

    Saturday, January 18, 2020 10:27 PM
    Owner
  •         public static RandomAccessStreamReference ByteToStream(BitmapImage image)
            {
                RandomAccessStreamReference streamRef = RandomAccessStreamReference.CreateFromUri(image.UriSource);
                return streamRef;
            }
                                        var mapIcon = new MapIcon();
                                        mapIcon.Location = myPoint;
                                        mapIcon.Title = App.persons.ElementAt(child).field_Name;
                                        // Display an image of a MapIcon
                                            BitmapImage bitmapImage = new BitmapImage();
                                            bitmapImage = await ImageUtils.GetImage(App.persons.ElementAt(i).field_Foto.Substring(1));
    
                                            mapIcon.Image = ImageUtils.ByteToStream(bitmapImage);
                                        // add to map and center it
                                        map.MapElements.Add(mapIcon);

    The question is, I can’t display photos of people on the map. 

    Since I did not work

    Sunday, January 19, 2020 7:14 AM
  • so far it only turned out

                                            try
                                            {
                                                string fileIcon = App.persons.ElementAt(i).field_Id + ".jpg";
                                                if (dstFile != null)
                                                {
                                                    mapIcon.Image = RandomAccessStreamReference.CreateFromFile(dstFile);
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                            }
    

    Sunday, January 19, 2020 8:31 AM
  • everything turned out to be easier

                                        string fileIcon = App.persons.ElementAt(i).field_Id + ".jpg";
                                        StorageFile dstFile = await App.pub_fotoFolder.GetFileAsync(fileIcon);
                                        if (dstFile != null)
                                        {
                                            IRandomAccessStream fileStream = await dstFile.GetThumbnailAsync(ThumbnailMode.PicturesView, 32, ThumbnailOptions.ResizeThumbnail);
                                            mapIcon.Image = RandomAccessStreamReference.CreateFromStream(fileStream);
                                        }
    

    Sunday, January 19, 2020 4:39 PM
  • Excellent!  Thank you for following up and sharing your success.
    Tuesday, January 21, 2020 7:41 PM
    Owner