I am attempting to load a very large geojson to a leaflet map. The map is written in a JavaScript script and is referenced by the HTML script as is outlined below. This was done in accordance (I believe) with the leaflet documentation.
Here is the javascript file:
const apiKey = 'pk.eyJ1IjoibWF4ZHVzbyIsImEiOiJja3p3Mzh3cHQ4M2VuMm5waGE3c3NpcGRoIn0.RCKfV5n8aOn2AUbXiS2qqA';
const mymap = L.map('map').setView([54.828018, -125.049246],6);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: apiKey
}).addTo(mymap);
This creates a base map with the desired bounds as expected. ALl good so far. I now know that my html is properly linked to my JS script seemingly correctly. However, after that, displaying my own data on the map is not working. When I try to set the source of my geojson within the html script, then load it into the JS script, it does not get displayed upon loading html in server. The basemap still shows but nothing else.
HTML
<!-- Make sure you put the following AFTER Leaflet CSS -->
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<!-- Load the geojson file tobe mapped by leaflet-->
<script src="C:\Users\User\Desktop\CPAWS\website\cp.geojson"></script>
<!-- Refer to the JS file containing the mapping information -->
<script src="PAWSmap.js"></script>
JavaScript Added to the above JS script
L.geoJSON(cp).addTo(map)
So I figured, try starting more simple. I added script for a marker instead using the simple following, copied directly from the leaflet documentation but with coordinates found within my map range:
var marker = L.marker([50.1, -122.9]).addTo(map);
So my question is: Why is geospatial data not being displayed on my map? Additionally, is my geojson not being shown for the same reason as the marker or is there something else wrong with my methodology there.
Edit browser console error messages
when attempting to place marker:
Uncaught TypeError: t.addLayer is not a function
at i.addTo (Layer.js:52:7)
at PAWSmap.js:16:49
when attempting to laod geojson:
Not allowed to load local resource: file:///C:/Users/User/Desktop/CPAWS/website/cp.geojson
Uncaught ReferenceError: cp is not defined at PAWSmap.js:14:11
crbug/1173575, non-JS module files deprecated.
I have noticed in some tutorials involving feature collection geojsons that they are converted to json files before loading. Not sure if this is the problem but I was not able to do so due to the size of the file. I also thought it would be ok as geojson as leaflet seems to suggest so.
Thank you very much for reading and hopefully understanding my issue.