TransWikia.com

Cannot read property 'addLayer' of undefined in svelte

Geographic Information Systems Asked by apoorva on March 7, 2021

below is my code. I am using leaflet in svelte to plot a map with image.

<script>
    import { onMount } from 'svelte';
import L from 'leaflet';
    var map;
onMount(() => {
  map = L.map('issmap').setView([51.505, -0.09], 13);
    });
var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg',
    imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]];
L.imageOverlay(imageUrl, imageBounds).addTo(map);
    

</script>


<html lang=en>
    <head>
     <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
   integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
   crossorigin=""/>
         <script src="https://unpkg.com/[email protected]/dist/leaflet.js"
   integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
   crossorigin=""></script>
        <style>
#issmap { height: 180px; }
</style>
    </head>
    <body>
        <div id="issmap">
        </div>
    </body>
</html>

But i am getting a error "Cannot read property ‘addLayer’ of undefined". how can i slove this ?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP