Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlazorLeaflet not working with WebAssembly and .net core 3.1 #46

Open
mennowo opened this issue Jul 31, 2020 · 7 comments
Open

BlazorLeaflet not working with WebAssembly and .net core 3.1 #46

mennowo opened this issue Jul 31, 2020 · 7 comments
Labels
bug Something isn't working investigating Exploring the issue with the author to make sure it is a problem in the codebase.

Comments

@mennowo
Copy link

mennowo commented Jul 31, 2020

Hello,

when I download the repository and run the sample, all works fine. However, when I try integrating a map in my own application, I get this error:

Microsoft.JSInterop.JSException: Could not find 'leafletBlazor' in 'window.window'.

I referenced the BlazorLeaflet.dll file I built myself from my project and added a script reference in index.html. Do I have to do anything beyond that to get it to work?

Thanks! Greets, Menno

@mennowo
Copy link
Author

mennowo commented Jul 31, 2020

A follow-up: I get the same error when using the lib in a server project.

It does however work (server-side only, not with WebAssembly), when I include the BlazorLeaflet project in my own solution, and reference the project from my web app.

@losbaltica
Copy link

Same issue here. The only way I manage to run this package is by downloading project and then referencing to my app

@Mehigh17 Mehigh17 added bug Something isn't working investigating Exploring the issue with the author to make sure it is a problem in the codebase. labels Oct 9, 2020
@pdowideit
Copy link

pdowideit commented Dec 17, 2020

Similiar issue in client-side Blazor Webassembly (.net 5.0): "Error: Could not find 'window.leafletBlazor.create' ('leafletBlazor' was undefined)."

Am I missing something?
Should I create a new issue for that?

@bryanrcarlson
Copy link

I was having similar issues; resolved them by referencing leaflet.js in index.html/_Host.cshtml. The README doesn't specify to do this, but I believe you have to?

From sample project:

    <link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
          integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
          crossorigin="" />
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"
            integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
            crossorigin=""></script>

@erikthysell
Copy link

My experience was that with an older browser I got the window.window error, but with newer browsers it seems to work. I actually believe (as far as I can remember) it was a challenge for older browsers with the spread operator ... that is used in the leafletBlazorInterops.js file.

@BenBurge
Copy link

I was getting the same error message as shown above. The fix for me was to add the following line after your leaflet script tag.

<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
<script src="_content/BlazorLeaflet/leafletBlazorInterops.js"></script>

I am using Leaflet 1.9.3 and the 0.4.0 alpha release of the BlazorLeaflet library from NuGet. I found this by reviewing the example section and saw this was the only difference between my code and the example code.

@K2-Software
Copy link

Do you have any info about this problem? For me the only possibility to solve this was to add the BlazorLeaflet project to my solution, other combinations had failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigating Exploring the issue with the author to make sure it is a problem in the codebase.
Projects
None yet
Development

No branches or pull requests

8 participants