Цю сторінку ще не перекладено українською, тому нижче англійська версія.

map() html()

A map (maps plugin): html()->map($spec) is _class('maps')->render($spec); one div with the spec as JSON, drawn by the yf_maps starter.

html()->map($spec = [])

Опції

ОпціяЗначення
center, zoom[lat, lng] (PHP order) and 0-22; default the markers, else the whole world.
tilesosm, mapy[:basic|outdoor|winter|aerial] (key), pmtiles[:auto|light|dark] (own archive or the bundled world basemap), custom:<name>.
markersList of lat, lng, title (tooltip), popup (text) or popup_html (HTML from your code only).
cluster, fitCluster the markers; fit the view to them (default with several markers and no center).
heightCSS length or pixels (default 360px).
consentauto (default: click to load for tiles that are not self-hosted), none, always.
scroll_zoom, min_zoom, max_zoom, id, class, titleWheel zoom (on), zoom limits, attributes of the div.

Приклад

Код

return html()->map(['tiles' => 'pmtiles', 'center' => [48.5, 20], 'zoom' => 3, 'height' => 260, 'markers' => [
    ['lat' => 50.4501, 'lng' => 30.5234, 'title' => 'Kyiv', 'popup' => 'Kyiv'],
    ['lat' => 48.8566, 'lng' => 2.3522, 'title' => 'Paris', 'popup' => 'Paris'],
]]);

Примітки

  • No inline script: the spec goes out as JSON with every HTML character escaped; popup text is set as text in the browser.
  • Maps in content that htmx swaps in start too; maps htmx removes are destroyed.
  • The example uses the bundled world basemap, served by this site: no key and no third party.

Див. також: html/map_view, form/map_select