I am trying to add a JSON file to my webmap in leaflet but I keep getting this error.

I am calling an external js file and adding it as a variable to my map

<!DOCTYPE html>
    <meta charset="UTF-8">
    <title>Bunuba Heritage Map (BETA2)</title>

   <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"
    <!-- esri -->
    <script src="https://unpkg.com/esri-leaflet@2.0.8"></script>
    <script src="http://maps.stamen.com/js/tile.stamen.js?v1.3.0" type="text/javascript"></script>
<!-- Boundary GeoJSON -->
<script type="text/javascript" src="JSON/BunubaNTarea.js"></script>
<!-- Plugin Mini Map -->
<link rel ="stylesheet" href= "/Minimap/src/Control.MiniMap.css"/>
<script type="text/javascript" src = "Minimap/src/Control.MiniMap.js"> </script>
<!-- Plugin Full screen -->
<link rel="stylesheet" href="FullScreen/Control.FullScreen.css" />
    <script src="FullScreen/Control.FullScreen.js"></script>
    #map {
        width: 1800px;
        height: 800px;
    <h1>Bunuba Heritage Map (BETA) </h1>
     <div id="map"><div>

    var map = L.map('map',{center: [-17.723, 125.409], zoom: 10, attributionControl :
    var ESRI = L.esri.basemapLayer('Imagery').addTo(map);
    var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'   }); 
    var Stamen = new L.StamenTileLayer("terrain");
    var capas_base = {"ESRI Satellite": ESRI, "Open Street Maps": osm, "Terrain": Stamen};
    var overlay = {"Bunuba Country": Boundary};
    L.control.layers(capas_base, overlay).addTo(map);
    L.control.scale({position:'bottomright',metric:true, imperial: false, maxWidth: 500}).addTo(map);
var capa_mp = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png');
var miniMap = new L.Control.MiniMap(capa_mp, { toggleDisplay: true }).addTo(map);
         ({position: 'topleft',title: 'fullscreen', titleCancel: 'Exit', content: null, forceSeparateButton: true,  forcePseudoFullscreen: false, fullscreenElement: false 
    map.on('enterFullscreen', function(){
  console.log('entered fullscreen');

map.on('exitFullscreen', function(){
  console.log('exited fullscreen');
  • Change L.geoJSON(Boundary).addTo(Map); to var boundaryLayer = L.geoJSON(Boundary); boundary.addTo(map); and replace also var overlay = {"Bunuba Country": Boundary}; with var overlay = {"Bunuba Country": boundaryLayer};
    – ThomasG77
    Aug 7 '20 at 3:05
  • thanks for the help, the map works but it is not displaying the requested file, maybe there is something with the imported geoJSON file?
    – Josh
    Aug 7 '20 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.