It took me a few years to figure this out.
this.load.tilemapTiledJSON("map", "assets/tilemaps/maps/multi-tileset-v12.json");
this.load.once(
"filecomplete-tilemapJSON-map",
function (key, type, data) {
this.load.setPath("/assets/tilemaps/maps/");
for (var tileset of data.data.tilesets) {
this.load.image(tileset.name, tileset.image);
}
},
this
);
You can also add tilesets and layers directly from the map data:
var map = this.add.tilemap("map");
for (var tileset of map.tilesets) {
map.addTilesetImage(tileset.name);
}
for (var layerData of map.layers) {
map.createLayer(layerData.name, map.tilesets);
}