LarsWiegers / laravel-maps

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

Maps within wire-elements/modal #34

Closed ryangurn closed 1 year ago

ryangurn commented 2 years ago

When I attempt to use laravel-maps within a wire-elements modal I get the following error.

@LarsWiegers do you have any recommendations for how to address this? I am currently just using one of the examples from the readme for testing purposes.

<div class="bg-white overflow-hidden shadow rounded-lg divide-y divide-gray-200">
    <div class="px-4 py-5 sm:p-6">
        <x-maps-leaflet :centerPoint="['lat' => 52.16, 'long' => 5]"></x-maps-leaflet>
    </div>
</div>

The above html code is a part of the following livewire component that has the attached class.

<?php

namespace App\Http\Livewire\Modals;

use LivewireUI\Modal\ModalComponent;

class ViewMap extends ModalComponent
{
    public function render()
    {
        return view('livewire.modals.view-map');
    }
}

I am able to use this component when not including it in a wire-element/modal but I am unsure why I get this error when attempting to load the map within the modal.

Unhandled Promise Rejection: ReferenceError: Can't find variable: L
image
ryangurn commented 2 years ago

It appears that if I take the script and duplicate it right before the closing body tag I am able to get the modal to properly render without any issue.

<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
        integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
        crossorigin=""></script>
</body>
</html>
LarsWiegers commented 2 years ago

The library does not currently support livewire, but if you got it working awesome! To be honest i dont use livewire. But feel free to send in a pr for supporting it.

LarsWiegers commented 1 year ago

@ryangurn pls see my last message

LarsWiegers commented 1 year ago

Closing this as @ryangurn did not respond, feel free to reopen if this is something you want to move further.