webbingbrasil / filament-maps

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

Multiple markers not rending #19

Closed n1xn closed 1 year ago

n1xn commented 1 year ago

Describe the bug Returning an array of Markers does only render one in getMarkers().

To Reproduce Steps to reproduce the behavior:

<?php

namespace App\Filament\Widgets;

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

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

    protected bool $hasBorder = false;

    public function getMarkers(): array
    {
        $markers = [];
        $woodLots = auth()->user()->companies()->first()->woodLots()->with('location')->get();
        foreach ($woodLots as $woodLot) {
            $point = $woodLot->location->point;
            $markers[] = Marker::make('pos2')
                ->lat($point->getLatitude())
                ->lng($point->getLongitude())
                ->tooltip($woodLot->lot_number . ' ' . $point->getAltitude() . ' Höhenmeter')
                ->popup('Popup?');
        }

        return $markers;
    }

    public function getActions(): array
    {
        return [
        ];
    }
}

Expected behavior Should load all markers and put it on the map.

Screenshots image

Additional context Add any other context about the problem here.

dmandrade commented 1 year ago

You need to set a unique name for each Marker:

Marker::make($woodLot->getKey)

Let me know if this worked for you.

n1xn commented 1 year ago

Tahnks for your answer, the issue was that the name „pos2“ was always the same and got overwritten.

Sent from Outlook for iOShttps://aka.ms/o0ukef


From: Danilo Andrade @.> Sent: Friday, March 31, 2023 12:01:44 AM To: webbingbrasil/filament-maps @.> Cc: NIXN @.>; Author @.> Subject: Re: [webbingbrasil/filament-maps] Multiple markers not rending (Issue #19)

You need to set a unique name for each Marker:

Marker::make($woodLot->getKey)

Let me know if this worked for you.

— Reply to this email directly, view it on GitHubhttps://github.com/webbingbrasil/filament-maps/issues/19#issuecomment-1491019987, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHGBCA52IHPCBKEA6LG4HKLW6X7ERANCNFSM6AAAAAAWNQIKSA. You are receiving this because you authored the thread.Message ID: @.***>