Treer/minecraft-map

Custom icon example?

Opened this issue · 2 comments

It's not super clear how to implement custom icons. I think an example would do wonders...

Treer commented
  • Example of a map with a custom icon
  • The locations list file that created the map. It has the following changes:
    • It specifies the url for the icons file (line 10).
    • One of the locations has an icon index set to 64, which is the index that custom icons currenty start at (line 50)
    • The location has had two newlines - "\n\n" - added to the start of the label, this drops the label by two lines so it appears under the large custom image instead of over the top of it (line 50)
  • The custom icons image file used. This only contains one icon, so it might not be as illustrative as desired. The image is 64 x 128, the top 64 x 64 square is for the icon foreground (which I've left blank), and the bottom 64 x 64 square is for the icon's background, which I've placed the picture in. The difference between the foreground and background is that label text and all icon foregrounds are drawn on top of backgrounds. In this case I put the picture in the background because it's so big it might cover labels. If the .png were to contain 2 custom icons, it would have been 128 x 128.

The custom icons feature could probably do with some extra polishing, but I don't think anybody is using them. Perhaps that's due to my lack of clear documentation and an example, but you're the first person to ask about them. Next time I update the documentation I'll include the example.

Treer commented

I may have found your problem.

  • There's a bug in v1.7.2: it doesn't load custom icons if they're cross-domain, even if your image hosting site enables CORS (e.g. imgur.com), and it doesn't give an error message either it just fails to draw the map.

    This bug is fixed in the repository now, and icons can be loaded cross domain via CORS, but I still need to push out a new release v1.7.3 has now been released.

    My example above was unaffected as the image file is hosted on the same site as the map webpage, but anyone wanting to use custom icons without hosting their own copy of the map needs v1.7.3.

  • Browsers have now also started disallowing webpages loaded via https from dynamically loading via http, and this can block the loading of custom icons if you use mismatching urls. However, I suspect the lack of CORS support is the first problem.