[Universal Windows Platform] PictureMarkerSymbol and Local Folder

2497
1
12-27-2015 11:11 PM
steelissteelis
New Contributor

Hi Everyone,

I am currently developing an app on the Universal Windows Platform with Esri Runtime for Dotnet10.2.6.

I have a dynamic list of Images that needs to be applied different Color before being inserted into the Esri Map via PictureMarkerSymbol. I am currently facing problem trying to load an image from my App’s Local folder into the PictureMarkerSymbol although I have no problem loading an image that is already included In the project.

This is the code that is able to load the Image properly into a Image control:

var folder = Windows.Storage.ApplicationData.Current.LocalFolder;

var file = await folder.GetFileAsync("test.png");

Uri path = new Uri(file.Path, UriKind.Absolute);

image_Button.Source = new BitmapImage(path);

This is the code that is not loading the same image correctly for the PictureMarkerSymbol:

var folder = Windows.Storage.ApplicationData.Current.LocalFolder;

var file = await folder.GetFileAsync("test.png");

Uri path = new Uri(file.Path, UriKind.Absolute);

await myPicMarkerSymbol.SetSourceAsync(path);

However, if I were to load an image of an image already included in the project, I will be able to load the image correctly within the PictureMarkerSymbol.

Uri path = new Uri(@"ms-appx:/// Assets/MapSymbolsDefault/test.png");

await unitPicMarkerSymbol.SetSourceAsync(path);

As the online resources that I have found thus far are currently using some online image as the PictureMarkerSymbol, is the PictureMarkerSymbol able to load images from the Local folder(or Temporary, Cached etc)? If so, may I know if there are sample codes on how to do it? If not, what are the proper ways to do dynamic image generation for usage with PictureMarkerSymbol?

Thanks in advance for any help.

0 Kudos
1 Reply
steelissteelis
New Contributor

I have found out how to load from the local folder using the SetSourceAsync(Uri).

Instead of constructing an Uri from a StorageFile path, construct an Uri using the format "ms-appdata://local/<filename>".

I was hoping that the input for PictureMarkerSymbol to be similar to BitmapImage or the Image control.

I think it will still be great if someone is able to share how to load the images into the PictureMarkerSymbol using the StorageFile, StorageFolder API for navigating through a Folder(Temp, Local, LocalCached etc..) or Library.

0 Kudos