I'm having issues with leaflet trying to load tiles that dont exist and that are outside of my MaxBounds.
jsfiddle replicating issue with my tileset
Also tried with the following at the end:
map.setBounds(new L.LatLngBounds(southWest, northEast));
but that seems to just break popups and markers and everything else without solving my issue.
The full size of the map is 4096x4096
Unrelated question, is it possible to change the coord system to always use unprojected pixel coords without having to either use unproject while placing every marker or getting regular coords?
To tell Leaflet that your Tile Layers does not have any tile to serve outside predefined bounds, simply use the bounds
option.
In your case, I guess it would be the same as your map's max bounds.
I see that you are trying to display a game map, that is why you need to change the CRS to L.CRS.Simple
. Be careful as you incorrectly applied the crs
option to your Tile Layer instead of the map, so it had no effect, except that your computed bounds then mismatch the map CRS, and your map.setMaxBounds()
restrain navigation to where you may not wish.
Please note that you should make separate questions.
By the way, not sure why you use tms
option on your Tile Layer. And your tiles at zoom level 4 seem to be totally mismatched compared to previous zoom levels. Updated JSFiddle: https://jsfiddle.net/f2Ljzpbh/2/