Unable to load .geojson via leaflet-ajax

With the help of the GRAV Assets plugin, I’ m attempting to use leaflet-ajax to add an external .geojson file to a Leaflet map. The zoning_4326.geojson file is located in the same folder as the Page’s default.md file, so I presume I only have to name the file, and don’t have to worry about a path… I think. The tiles of my Leaflet map are showing up alright-- i.e., I can see a base layer. However, I’m not seeing zoning_4326.geojson in my map.

Perhaps you can provide some code regarding how you are loading the file? You will probably need to access it via the page media object especially if you are passing it to JS.

{{ page.media['zoning_43226.geojson'].url }}

However you will have to add this custom .geojson file type to the user/config/media.yaml file (see system/config/media.yaml)

or simpler,

rename the file to zoning_43226.jeo.json as .json is natively supported.

Apologies for my delayed response, as I somehow missed seeing your reply. I resolved my issue but I’m intrigued by the page.media functionality and editing the media.yaml file. I will have to read up on those!

In this instance, my problem was due two mistakes:

  1. I was using the leaflet-ajax javascript to create a variable of my zoning_4326.geojson but the path had to be specified up to the user folder, so:

"/user/pages/01.portfolio/06.Zoning_Map/GeoJSON_lyrs/zoning_4326.geoj son"
2. Next, Leaflet uses YOUR_VARIABLE.addTo(map); to add a layer to a map. I mistakenly had that command outside/below the {assets:inline_js} section.

A lot of silly mistakes on my part, but I think I’m beginning to understand better how to use the Assets Plugin.

Thanks again for your assistance!