map_view() html()

Rows with coordinates on one map (maps plugin): each row becomes a marker; clustered and fitted to the points.

html()->map_view($rows = [], $extra = [])

Options

OptionMeaning
$rowsList of arrays, e.g. a database result.
lat_key, lng_keyKeys of the coordinates (default lat, lng); rows without a valid point are left out.
title_key, popup_keyTooltip and popup text (default title; the popup defaults to the title).
other keysMap spec keys of html()->map(): tiles, height, consent, cluster (on), fit (on), ...

Example

Code

$rows = [
    ['name' => 'Kyiv', 'lat' => 50.4501, 'lng' => 30.5234],
    ['name' => 'Lviv', 'lat' => 49.8397, 'lng' => 24.0297],
    ['name' => 'Odesa', 'lat' => 46.4825, 'lng' => 30.7233],
    ['name' => 'Kharkiv', 'lat' => 49.9935, 'lng' => 36.2304],
];
return html()->map_view($rows, ['title_key' => 'name', 'tiles' => 'pmtiles', 'height' => 260]);

Notes

  • At most yf_maps::$MAX_MARKERS markers (5000) go into the page; more points belong in a GIS layer (later phase).

See also: html/map