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

map_select() form()

Pick one point on a map (maps plugin): latitude and longitude inputs filled by a click or a dragged marker; they post plain numbers.

form()->map_select($name = '', $desc = '', $extra = [], $replace = [])

Опції

ОпціяЗначення
$nameDefault point; the inputs are <name>_lat and <name>_lng.
lat_field, lng_fieldOther input names, e.g. the columns of your table.
singleOne input <name> holding lat,lng instead of two.
mapMap spec keys (_class('maps')->render()): tiles, zoom, center, height, consent, ...
locate"Use my location" button (default on); the browser asks only after a click.
disable_edit_mode, readonlyShow the point only.

Приклад

Код

return form(['spot_lat' => '50.4501', 'spot_lng' => '30.5234'])->map_select('spot', 'Meeting point', ['map' => ['tiles' => 'pmtiles', 'zoom' => 5, 'height' => 260]]);

Примітки

  • A typed value moves the marker; without JavaScript the inputs still work. Validate the posted numbers as any input (e.g. numeric, a range).
  • With tiles that are not self-hosted (OpenStreetMap, Mapy.com) the map starts as a click-to-load placeholder; the inputs are usable before.
  • The example uses the bundled world basemap (tiles => pmtiles), which is served by this site.

Див. також: html/map, form/google_maps