google_maps() form()
A Google map to place up to N markers; their coordinates post in a field.
form()->google_maps($name = '', $desc = '', $extra = [], $replace = [])Options
| Option | Meaning |
|---|---|
$name | Default map. |
markers_limit, start_zoom | Most markers (5); zoom (5). |
disable_edit_mode | Show the markers only. |
use_maps | Draw this field with the maps plugin (default: the form2_google_maps.USE_MAPS setting, off). |
Example
Not run here: the map loads the Google Maps API from Google (network, and a key), which the docs pages do not do.
Code
return form(['shops' => ''])->google_maps('shops', 'Shops on the map', ['markers_limit' => 3]);Notes
- Uses the
google-maps-apiasset and the templatesform2/google_maps/form2/google_maps_view. - Google requires a key: with
$PROJECT_CONF['maps']['GOOGLE_KEY']the loader carries it; without one Google shows an error on the map. - For maps without Google (OpenStreetMap, own tiles) and several on one page, see
map_select(). - With
use_maps(or$PROJECT_CONF['form2_google_maps']['USE_MAPS'] = true) the field ismap_select()withmultipleandformatindexed: the same name, markers limit, start zoom and posted JSON, the site's default tiles, no Google key and no jQuery. Off by default.
See also: form/country_box, form/map_select