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

**URL:** <https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100>\
**Category:** Bug Reports\
**Created:** [October 10, 2016, 1:32pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100 "2016-10-10T13:32:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![louisdecharson](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/louisdecharson/32/491_2.png) [@louisdecharson](https://forums.fusetools.com/u/louisdecharson)\
**Post date:** [October 10, 2016, 1:32pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/1 "2016-10-10T13:32:51Z")

</div>

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 :

```auto
<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 :

```auto
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 :

```auto
<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.

---

<div class="post-metadata">

**Author:** ![John](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@John](https://forums.fusetools.com/u/John)\
**Post date:** [October 10, 2016, 11:35pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/2 "2016-10-10T23:35:05Z")

</div>

EXACT same need 😃

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

---

<div class="post-metadata">

**Author:** ![Andreas\_Ronning](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/andreas_ronning/32/303_2.png) [@Andreas\_Ronning](https://forums.fusetools.com/u/Andreas_Ronning)\
**Post date:** [October 10, 2016, 11:42pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/3 "2016-10-10T23:42:01Z")

</div>

Hey guys, the IconFile property is a very new feature so thanks for putting it through its paces 😉 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.

---

<div class="post-metadata">

**Author:** ![John](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@John](https://forums.fusetools.com/u/John)\
**Post date:** [October 11, 2016, 10:16am UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/4 "2016-10-11T10:16:55Z")

</div>

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

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

Gratefull

Blade

---

<div class="post-metadata">

**Author:** ![John](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@John](https://forums.fusetools.com/u/John)\
**Post date:** [October 13, 2016, 5:11pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/5 "2016-10-13T17:11:51Z")

</div>

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

I will try further

---

<div class="post-metadata">

**Author:** ![louisdecharson](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/louisdecharson/32/491_2.png) [@louisdecharson](https://forums.fusetools.com/u/louisdecharson)\
**Post date:** [October 14, 2016, 12:17pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/6 "2016-10-14T12:17:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@John](https://forums.fusetools.com/u/John)\
**Post date:** [October 14, 2016, 5:54pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/7 "2016-10-14T17:54:42Z")

</div>

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

Thank you very much

---

<div class="post-metadata">

**Author:** ![louisdecharson](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/louisdecharson/32/491_2.png) [@louisdecharson](https://forums.fusetools.com/u/louisdecharson)\
**Post date:** [October 14, 2016, 8:18pm UTC](https://forums.fusetools.com/t/could-not-open-png-file-used-in-new-iconfile-property-of-mapmarker/5100/8 "2016-10-14T20:18:14Z")

</div>

Sure :

```auto
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);
}

```
