Markers - Elektromann/yii2-openlayers-maps GitHub Wiki

About

You can create many markers to show your office, shop, a street or other position on the map. A marker has title and description options to set information about the place.

Add marker

Marker default

The markers option is an array. If you add an empty array to the option, the marker position equals the map center position.

<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [],
    ],
]); ?>

Set marker position

You can set position by longitude and latitude (LonLat)

<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [
            'center' => [-0.1476482, 51.5186017],
        ],
    ],
]); ?>

or by address (geocoding)

<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [
            'center' => "London, Harley Place",
        ],
    ],
]); ?>

Set title

Marker title

It shows when the cursor is on the market.

<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [
            'center' => "London, Clareville Street",
            'title' => "This is the Clareville Street",
        ],
    ],
]); ?>

Set description

Marker description

It shows by one click on the marker.

<?= \elektromann\openlayers\Map::widget([
    'center' => "London",
    'markers' => [
        [
            'center' => "Lambeth, London SE1 7PB",
            'description' =>
                "This is the London Eye<br>About it you can visit the "
                . "<a href='https://en.wikipedia.org/wiki/London_Eye'>Wikipedia</a>",
        ],
    ],
]); ?>