Could not open .png file used in new IconFile property of MapMarker

I’m using the IconFile property of MapMarker.
I’ve downloaded a bunch of png images and stored them in Assets/pins/
My code is as follows :

<Page ux:Name="map" Background="#332A6C">
	 <NativeViewHost>
      <MapView Latitude="48.8639796552" Longitude="2.33559960389" Zoom="12">
    	<Each Items="{markers}">
        	<MapMarker Latitude="{lat}" Longitude="{lng}" Label="{title}" IconFile="{icon}"/>
    	</Each>
</MapView>

where icon is the path (string) toward a pin icon. I got the following error :

Uno.IO.IOException: Couldn't open file: Assets/pins/pin-b-0.png
   at Uno.IO.FileSystemImpl.CppXliOpenRead(string)
   at Uno.IO.File.OpenRead(string)
   at Fuse.Scripting.JSFileSource.OpenRead()
   at Uno.UX.FileSource.ReadAllBytes()
   at Fuse.Maps.MarkerSource.get_Path()
   at Fuse.Maps.MarkerIconCache.Get(Uno.UX.FileSource)
   at Fuse.Maps.iOS.MapView.UpdateMarkers()
   at Fuse.Controls.MapView.UpdateMarkers()
   at Fuse.Controls.MapView.DeferredMarkerUpdate()
   at Fuse.UpdateListener.Invoke()
   at Fuse.UpdateManager.Update(Fuse.Stage)
   at Fuse.UpdateManager.Update()
   at Fuse.AppBase.OnUpdate()
   at Fuse.App.OnUpdate()
   at Outracks.Simulator.Application.OnUpdate()
   at Fuse.App.OnTick(object,Uno.Platform.TimerEventArgs)
   at Uno.Platform2.Display.OnTick(Uno.Platform.TimerEventArgs)
Couldn't open file: Assets/pins/pin-b-0.png

When I’m using the same image elsewhere in the code the image is rendered as expected (I tried to use it at a dock-icon).
But this code is working :

<MapMarker Latitude="{lat}" Longitude="{lng}" Label="{title}" IconFile="Assets/pins/pin-b-0.png"/>

But I need to have a different icon for each marker.
I’m using Fuse 0.27.0 on OS X El Capitan.

EXACT same need :smiley:

The only workaround I could imagine is to put a logic into the javascript part of the code, which changes the value of the IconFile in dependency of what you need.

Any help of our fuse-gods would be awesome :DD

Hey guys, the IconFile property is a very new feature so thanks for putting it through its paces :wink: As a test, try adding Assets/pins/*.png:Bundle to your unoproj: I think what’s happening right now is that the file isn’t bundled automatically since it’s a dynamic reference.

Thats what I call religion.
A god that doesnt only listen, but also talks to you :smiley:

Thank you very much Andreas Rønning!!! I will test this tonight :slight_smile:

Gratefull

Blade

It does get built, but gets stuck as soon as opening the map :confused:

I will try further

This is working for me ! Thanks you very much @Andreas !
Is it possible by any chance to adjust the icon size (width * height) ?

Cool, could you show me your javascript part of {icon} ?

Thank you very much

Sure :

Marker = function(lat,lng,icon){
	this.lat = lat;
	this.lng = lng;
	this.icon = icon;
}
for (var i = 0; i < data.length ; i++) {
	var item = data[i];
	var iconFile = "Assets/pins/pin_b_"+item.A.toString()+".png";
	var marker = new Marker(item.position.lat, item.position.lng, iconFile.toString());
	markers.add(marker);
}