bradcornford / Googlmapper

An easy way to integrate Google Maps with Laravel
MIT License
464 stars 142 forks source link

[Q] Is it possible to use redirect with mapper? #363

Closed activatedtmx closed 4 years ago

activatedtmx commented 4 years ago

Hi,

Is it somehow possible to render maps when using redirect? Like so, from controller, where I don't have one specific static view: // Controller public function mapEdit($id) { $data = Data::findOrFail($id);

    Mapper::map(0, 0,
    [
        'zoom' => 15,
        'draggable' => true,
        'marker' => false,
        'center' => false,
        'draggable' => true, 
        'eventClick' => 'console.log(data.latLng.lat() + ", " + data.latLng.lng());'
    ]);

    Mapper::marker($data->Lat, $data->Lng);

    return redirect('/editMap/'.$id);
}

If I pass this data to static view, all shows up and works great, but I was wondering how can this be done in cases like this?

activatedtmx commented 4 years ago

Ok, fixed it by putting maps in other controller to avoid redirects. I guess no one should make redirects from one controller to another. Rookie mistake. Sorry for spam.