正在创建谷歌地图


Creating Google map

我正在尝试初始化一个指向某个位置的新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>

这似乎就是您想要的。

https://github.com/bradcornford/Googlmapper