LarsWiegers / laravel-maps

Your laravel maps libary.
https://github.com/LarsWiegers/laravel-maps
MIT License
254 stars 35 forks source link

Livewire Uncaught (in promise) ReferenceError: L is not defined #16

Closed wazimshizm closed 2 years ago

wazimshizm commented 2 years ago

When including the component inside a livewire component with an @if tag, the component throws a Uncaught (in promise) ReferenceError: L is not defined in the console and fails to render the rest of the page.

It works inside the livewire component if not inside an @if tag.

I'm guessing this has to do with the order the scripts are loaded? Any help would be hugely appreciated. Thanks!

LarsWiegers commented 2 years ago

Hi! Thx for creating an issue.

I have not yet tried to do any livewire things with this package.

Maybe livewire does not like the script tag that is included in the component?

what you could do is instead of ` @if(someCondition)

@endif `

do this: `

`

A test repository would help identifying what is going wrong. Do you know how to set that up?

wazimshizm commented 2 years ago

The issue was fixed by including the

<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"...

after the livewire scripts at the bottom of the page. It must be to do with the order they are loaded.

LarsWiegers commented 2 years ago

Cool, thx for getting back and posting your solution.

In the future we might include a default livewire component.

Closing the issue for now.