Googlmapper icon indicating copy to clipboard operation
Googlmapper copied to clipboard

Recenter Map With Livewire

Open DevTiago opened this issue 2 years ago • 3 comments

Hi there,

Congratz for the package! Is working great, although i need to recenter with coordinates sent form the frontend.

I have a list of available coordinates, and when i click on one of them i fire a function that updates map coordinates.

I'll past the code from the controller:

 public $latitude = '0.0';
 public $longitude = '0.0';

public function centerMap($id)
    {
        $dg = DeliveryGuyDetail::find($id);

        $this->latitude = $dg->delivery_lat;
        $this->longitude = $dg->delivery_long;
    }


public function render()
    {

        Mapper::map($this->latitude, $this->longitude, ['zoom' => 18, 'async' => true, 'clusters' => ['size' => 20, 'center' => true], 'draggable' => true ]);

        return view('livewire.manager.delivery-map');
    }

i'm starting with the coordinates (0, 0) and updating them after the user click on the available coordinates and fire the function "centerMap". But when that happens the map disappear.

Any advice on that?

Thanks in advance.

DevTiago avatar Oct 26 '22 15:10 DevTiago

I think you have to use the google panTo() function for that

michellaurent avatar Nov 03 '22 19:11 michellaurent

@DevTiago Did you find any resolution to this?

MohdSohail avatar Nov 10 '22 07:11 MohdSohail

No, not yet!

DevTiago avatar Nov 10 '22 09:11 DevTiago