2016-07-24 119 views
-1

我試圖初始化一個新的Gmap指向將顯示在我的視圖中的某個位置。當我檢查我的佈局時,它會正常加載,但它不會創建地圖。這個想法是我的座標作爲一個字符串保存到數據庫中。將不勝感激任何幫助。這是我的路線功能:創建谷歌地圖

<?php 

use Appitventures\Phpgmaps\Phpgmaps as Gmaps; 


Route::get('/', array('http' , 'as' => 'conf.show' , 'uses' => function($slug) 
{ 
    $conference = \Events\Models\Event::where('slug' , '=' , $slug)->first(); 

     $view = [ 
      'conference' => $conference 

     ]; 

    $theme = \Theme::uses('conference'); 
    $template = $conference->eventable->template; 

    $tmpFile = $template ? "landingtemplates.$template.default" : "landing"; 

    // Add map location to conference 

    $loc = $conference->gmap_location; 
    if(strpos($loc, ',')) { 
    $location = explode(",", $loc); 
     $config = array(); 
     $config['center'] = $location[0].', '.$location[1]; 
     $config['zoom'] = 17; 
     $gmaps = new Gmaps(); 
     $gmaps->apiKey = ''; 
     $gmaps->https = TRUE; 
     $gmaps->initialize($config); 

      // set up the marker ready for positioning 
      // once we know the users location 
     $marker = array(); 
     $marker['position'] = $location[0].', '.$location[1]; 
     $gmaps->add_marker($marker); 


     $map = $gmaps->create_map(); 
     Theme::set('map', $map); 


    } 
    return $theme->load('workbench.events.src.views.conf.'.$tmpFile, $view)->render(); 



})); 
?> 

這是我的看法

<div class="container map" id="map"> 

       @if($conference->gmap_location) 
       <?php $map = Theme::get('map'); ?> 
       {{ $map['html'] }} 
       @endif 

</div> 
+0

看看這個。 https://github.com/bradcornford/Googlmapper – Danieboy

回答