【问题标题】:Creating Google map创建谷歌地图
【发布时间】:2016-11-27 22:39:25
【问题描述】:

我正在尝试初始化一个新的 Gmap 指向某个位置,该位置将显示在我的视图中。当我检查我的布局时,它会正常加载,但不会创建地图。这个想法是将我的坐标作为字符串保存到数据库中。将不胜感激任何帮助。这是我的 Route 功能:

<?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>

【问题讨论】:

标签: php google-maps laravel view routes


【解决方案1】:

这似乎就是您要找的东西。

https://github.com/bradcornford/Googlmapper

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    • 2013-05-14
    • 1970-01-01
    相关资源
    最近更新 更多