【问题标题】:How to add multiple content to yii2 google maps infowindow?如何向 yii2 谷歌地图信息窗口添加多个内容?
【发布时间】:2016-01-28 01:03:34
【问题描述】:

我正在使用 2amigos 的 yii2 谷歌地图,但我不知道如何在标记的信息窗口弹出窗口中添加更多内容。 我想在信息窗口中放置多个图像和一些描述。现在,我只有一张图片。

    $x = 0;
foreach ($dataProvider->models as $model) {
    $marker[$x] = new Marker([
        'position' => $coords[$x],
        'title' => $model->location,
    ]);

    $marker[$x]->attachInfoWindow(
        new InfoWindow([
            'content' => Html::img('@web/'.$model->pic_north,['width'=>180], ['alt'=>'North'])
        ])
    );

    // Add marker to the map
    $map->addOverlay($marker[$x]);
    $x++;
}

echo $map->display();

【问题讨论】:

标签: php google-maps yii2 google-maps-markers


【解决方案1】:

尝试添加模式 img

$contentTest =  Html::img('@web/'.$model->pic_north,['width'=>180],
   ['alt'=>'Phil-LiDAR 2.2.13']) .  
   Html::img('@web/'.$model->pic_2,['width'=>180], ['alt'=>'pic_2']) . 
   Html::img('@web/'.$model->pic_3,['width'=>180], ['alt'=>'pic_3']);

 $marker[$x]->attachInfoWindow(
    new InfoWindow([
        'content' => $contentTest,
    ])
);

img 的 html 帮助器使选项(see the doc) 轻松可用

这意味着你可以通过这种方式在助手中添加你需要的样式

Html::img('@web/'.$model->pic_3,['width'=>180], 
  ['alt'=>'pic_3'], 'left'=>200], ['top'=>120]);

【讨论】:

  • 谢谢!有效。另一件事,我如何改变图像的位置?
猜你喜欢
  • 1970-01-01
  • 2011-05-21
  • 2014-09-04
  • 2011-09-28
  • 1970-01-01
  • 2011-11-09
  • 1970-01-01
  • 2018-06-05
  • 1970-01-01
相关资源
最近更新 更多