未找到传单扩展名和Geosearch目录

时间:2015-11-27 15:19:24

标签: yii2 leaflet

我是Yii框架的新手。我试图让传单扩展来处理我的项目。我通过composer安装它,一切似乎都安装得正确,但当我尝试将它插入activeForm时,它会抛出这个错误:

The file or directory to be published does not exist: /vendor/bower/leaflet/dist

我正在尝试使用地图构建Geosearch字段。 我安装的扩展程序是:

" 2 amigos/yii2-leaflet-extension" ;:" ~1.0", " 2 amigos/yii2-leaflet-geocoder-plugin":" ~1.0", " 2 amigos/yii2-leaflet-geosearch-plugin" ;:" ~1.0"

这是我在ActiveForm上的代码(它与GitHub上提供的代码相同):

use dosamigos\leaflet\layers\TileLayer; 
use dosamigos\leaflet\LeafLet; 
use dosamigos\leaflet\types\LatLng; 
use dosamigos\leaflet\plugins\geosearch\GeoSearch; 
use dosamigos\leaflet\widgets\Map; 

<?php
    $center = new LatLng(['lat' => 39.67442740076734, 'lng' => 2.9347229003906246]); 

    $geoSearchPlugin = new GeoSearch([ 
        'service' => GeoSearch::SERVICE_OPENSTREETMAP 
    ]); 

    $tileLayer = new TileLayer([ 
        'urlTemplate' => 'link not allowed because its one of my first posts...', 
        'clientOptions' => [ 
            'attribution' => 'Tiles Courtesy of MapQuest ' . ', ' . 'Map data © OpenStreetMap contributors, ' . 'CC-BY-SA', 'subdomains' => '1234' 
        ] 
    ]); 

    $leafLet = new LeafLet([ 
        'name' => 'geoMap', 
        'tileLayer' => $tileLayer, 
        'center' => $center, 
        'zoom' => 10, 
        'clientEvents' => [ // setting up one of the geo search events for fun 
            'geosearch_showlocation' => 'function(e){ console.log(e.target); }' 
        ] 
    ]); 

    // add the plugin 
    $leafLet->installPlugin($geoSearchPlugin); 
    // run the widget (you can also use Map::widget([...])) 
    echo $leafLet->widget(); 
?>

我有什么遗失或做错了吗? 先谢谢

1 个答案:

答案 0 :(得分:0)

您的问题是Bower不再提供原始的Leaflet js和css文件,2amigos没有更改其作曲家文件以反映更改。 Yii正在尝试从请求的位置发布css文件,并且该文件尚不存在,因此出现错误消息。您需要转到original Leaflet repository并将相关文件复制到所需目录中,或者更新composer文件以指向GitHub上的原始文件。对不起,我对作曲家的了解不足以帮助解决这个问题!