Marker icon - Elektromann/yii2-openlayers-maps GitHub Wiki

You can use your own marker icon. I downloaded free icons from icons8.com

Marker icons

Set icon

<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [
            'icon' => \yii\helpers\Url::to("@web/images/marker.png"),
        ],
    ],
]); ?>

Icon position

You can choose from 5 positions:

  • top
  • bottom
  • left
  • right
  • center
<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [
            'icon' => \yii\helpers\Url::to("@web/images/marker-bottom.png"),
            'iconPosition' => "bottom",
        ],
    ],
]); ?>

If you use icon position, by automatically change description position to.

Icon size

By default icon size is 20px * 20px. The first string is the width, second is the height.

Icon size

<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [
            'icon' => \yii\helpers\Url::to("@web/images/marker.png"),
            'iconSize' => ["40px", "40px"],
        ],
    ],
]); ?>
⚠️ **GitHub.com Fallback** ⚠️