webbingbrasil / filament-maps

Map widget for filament admin
MIT License
61 stars 20 forks source link

not work with filament moduler package #20

Open milad4444 opened 1 year ago

milad4444 commented 1 year ago

im using this widget in my Najam named Module in my filament admin panel and this error shows cannot read properties of undefined (reading 'modules.najma.filament.widgets.map')

dmandrade commented 1 year ago

Can you provide a code snippet or a repo with a demo?

gladjanus43 commented 6 months ago

Im having the same issue. The widget is loading but the following error is thrown livewire.js?id=239a5c52:1203 Alpine Expression Error: Cannot read properties of undefined (reading 'leaflet-map-widget')

In the packageRegistered method of my module I initialised a livewire component and it is rendering the view succesfully: Livewire::component('leaflet-map-widget', LeafletMapWidget::class);

This is the widget class, which I added to the module.

<?php

namespace Uxit\ModuleTransportOrder\Livewire;

use Webbingbrasil\FilamentMaps\Actions;
use Webbingbrasil\FilamentMaps\Marker;
use Webbingbrasil\FilamentMaps\Widgets\MapWidget;

class LeafletMapWidget extends MapWidget
{
    protected int | string | array $columnSpan = 2;

    protected bool $hasBorder = false;

    public function getMarkers(): array
    {
        return [
            Marker::make('pos2')->lat(-15.7942)->lng(-47.8822)->popup('Hello Brasilia!'),
        ];
    }

    public function getActions(): array
    {
        return [
            Actions\ZoomAction::make(),
            Actions\CenterMapAction::make()->zoom(2),
        ];
    }
}

In the view I am then rendering the component, which does correctly show the actions etc but the map is not loading due to the above error

<div>
    <div>
        @livewire('leaflet-map-widget')
    </div>
    <div class="p-4 w-full h-screen flex justify-center">
        <div class="">

            <form wire:submit="create">
                {{ $this->form }}
            </form>

            <x-filament-actions::modals />
        </div>
    </div>
</div>