I am building a Leaflet web map and I am using OpenStreetMap as the base layer.
I have a .shp file of land parcels that I converted to GeoJSON with QGIS.
I also was able to get the web map with the base layer displaying correctly in Leaflet.
I will spare you all the header code injection as it is standard, but I am stuck trying to load the GeoJSON layer over my base map. This is my first time doing anything with Leaflet, and I am rather lost.
How can I display the (remotely-hosted) GeoJSON layer? And, ideally, how can I bring it to 30% opacity when overlayed?
Here is the code I have:
<div id="mapid" style="width: 75%; height: 600px;"></div>
<script>
var mymap = L.map('mapid').setView([31.807, -99.040], 50);
// loading GeoJSON file - Here my html and usa_adm.geojson file resides in same folder
$.getJSON("https://www.mywebsite.com/testing/testmap1.geojson",function(data){
// L.geoJson function is used to parse geojson file and load on to map
L.geoJson(data).addTo(mymap);
});
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eythisisthekey', {
maxZoom: 13,
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>',
id: 'mapbox.streets'
}).addTo(mymap);
</script>