【问题标题】:Yii2 and Google maps APIYii2 和谷歌地图 API
【发布时间】:2016-03-16 13:48:03
【问题描述】:

我有一个空的 Yii2 项目。我需要将谷歌地图设置到指定页面。我知道我必须包含我的 .js 和 .css 文件,但我不知道具体如何。我尝试在 assets/AppAsset.php 中设置我的脚本:

    public $css = [
    'css/site.css',
    'css/mystyles.css'
];
public $js = [
    'js/map-options.js',
    'js/data.json',
    'js/markerclusterer.js'
];

并在视图文件和控制器中添加这些行

// in view
$this->registerJsFile('path/to/myfile');
$this->registerCssFile('path/to/myfile');

// in controller
$this->view->registerJsFile('path/to/myfile');
$this->view->registerCssFile('path/to/myfile');

但它仍然不起作用。求助,怎么解决?

【问题讨论】:

    标签: javascript php css google-maps yii2


    【解决方案1】:

    也许你的css有问题。 试试这个:

    #map{  
      position: absolute;}
    

    或内联插入

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-25
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多