我想手动安装2amigos/yii2-google-maps-library小部件。
我在"2amigos/yii2-google-maps-library" : "*"
的必填部分添加了composer.json
,并在'dosamigos\\google\\maps\\' => array($vendorDir . '/2amigos/yii2-google-maps-library'),
composer autoload_psr4.php
我在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
答案 0 :(得分:0)
哦,谢谢,我终于得到了解决方案。我添加了带有反斜杠的命名空间,导致错误。我修好了
'2amigos/yii2-google-maps-library' =>
array (
'name' => '2amigos/yii2-google-maps-library',
'version' => '9999999-dev',
'alias' =>
array (
'@dosamigos/google/maps' => $vendorDir . '/2amigos/yii2-google-maps-library',
),
),
在extensions.php中