jeudi 20 juillet 2017

Laravel googlemapper package, Cannot get variables from the config file, "Google maps API key is required." ERROR

I was using your plugin these days trying to implement a googlemap on my site. I followed all installation steps and set a variety of variables. I am on laravel 5.4.

I stuck in this error: "Google maps API key is required.". Even I try to hard set the API in your core function, then it throws another error says "region is required". seems like the config file cannot be reached. I also tried to fix the file permissions, but unfortunately that's not the issue. Do you have any ideas about this? This is part of my controller file

use Cornford\Googlmapper\Mapper;
use Cornford\Googlmapper\Facades\MapperFacade;
use Illuminate\Support\Facades\Route;

   public function index(Mapper $mapper)
   {
        ............
        $firstMapItem = reset($mapArrays);
        $mapper->map(
         $firstMapItem->latitude, $firstMapItem->longitude,
         [
            'zoom' => 10,
            'markers' => ['title' => 'My Location', 'animation' => 'DROP'],
            'clusters' => ['size' => 10, 'center' => true, 'zoom' => 20]
         ]
      );

      // Add information window for each address
      foreach ($mapArrays as $mapArray) {
         $mapper->marker($mapArray->latitude, $mapArray->longitude);
      }
}

Route

Route::get( '/map', 'MapController@index');

view

<div style="width: 100%; height: auto;">
    {!! Mapper::render() !!}
</div>

Thank you so much!

BTW, I already changed the API value there, my problem is this API value has not been referenced. But if I move the Mapper function from the controller to the Route file, everything is fine. But if I do what I did as above, the API value from the googlmapper.php file isn't referenced.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ueuTqL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire