【发布时间】:2017-10-21 20:43:55
【问题描述】:
我想手动安装2amigos/yii2-google-maps-library 小部件。
我在composer.json 的必填部分添加了"2amigos/yii2-google-maps-library" : "*",我在composer autoload_psr4.php 中添加了'dosamigos\\google\\maps\\' => array($vendorDir . '/2amigos/yii2-google-maps-library'),
我在 composer 的 extensions.php 中添加了'2amigos/yii2-google-maps-library' =>
array (
'name' => '2amigos/yii2-google-maps-library',
'alias' =>
array (
'@dosamigos\google\maps' => $vendorDir . '2amigos/yii2-google-maps-library',
),
), 代码。
我的视图代码是
<?php
use dosamigos\google\maps\LatLng;
use dosamigos\google\maps\services\DirectionsWayPoint;
use dosamigos\google\maps\services\TravelMode;
use dosamigos\google\maps\overlays\PolylineOptions;
use dosamigos\google\maps\services\DirectionsRenderer;
use dosamigos\google\maps\services\DirectionsService;
use dosamigos\google\maps\overlays\InfoWindow;
use dosamigos\google\maps\overlays\Marker;
use dosamigos\google\maps\Map;
use dosamigos\google\maps\services\DirectionsRequest;
use dosamigos\google\maps\overlays\Polygon;
use dosamigos\google\maps\layers\BicyclingLayer;
/* @var $this yii\web\View */
$this->title = Yii::$app->name;
?>
<section>
<div class="container">
<div class="row">
<?php
$coord = new LatLng(['lat' => 39.720089311812094, 'lng' => 2.91165944519042]);
$map = new Map([
'center' => $coord,
'zoom' => 14,
]);
?>
</div>
</div>
</section>
但是当我运行这个给我错误
Class 'dosamigos\google\maps\LatLng' not found
【问题讨论】:
-
"2amigos/yii2-google-maps-library" 是正确路径上的下载文件夹,即 vendor/2amigos/yii2-google-maps-library ?
-
是的,它在正确的文件夹中。
标签: yii2 widget composer-php