Skip to content

The Maps field ​

Maps comes with a fieldtype: add a field of the type Maps (By Reinos) to show a map on the Publish page. (Part of Maps from v5.0.0, before it was the separate Maps Fieldtype add-on.)

Field settings ​

When you create a Maps field, the following settings are available:

SettingDefaultDescription
ModeMultiple layersSingle location: one marker with an address, see Single location. Multiple layers: markers, lines and areas with the drawing tools. (from v5.0.0)
Icon dir{base_path}themes/user/reinos_maps_fieldtype/assets/markers/The server path of the folder with the marker icons you can choose from when editing a marker. By default the 177 icons that come with Maps; point it to your own folder to use your own icons.
Icon url{base_url}themes/user/reinos_maps_fieldtype/assets/markers/The URL of that same folder.
LocationEuropeThe location (an address or a latitude, longitude) the map starts on when the field has no data yet.
Height500pxThe height of the map on the Publish page, as a CSS height (500px, 60vh, 100%). A number without a unit is saved as pixels.
Max markers(empty)The maximum number of markers that can be added (1 - 200). Leave it empty for no limit.
Default zoom level1The zoom level (1 - 22) of a new map.
Show map toolsSuper AdminThe member roles that see the map tools in the toolbar. See Permissions.
Show search toolsSuper AdminThe member roles that can search an address.
Show add marker iconSuper AdminThe member roles that can add markers.
Show circle iconSuper AdminThe member roles that can draw circles.
Show polygon iconSuper AdminThe member roles that can draw polygons.
Show polyline iconSuper AdminThe member roles that can draw polylines.
Show rectangle iconSuper AdminThe member roles that can draw rectangles.
Hide edit option for the layersnoneThe member roles that can not edit, delete, move or reshape the markers, circles, polylines, polygons and rectangles.
Auto center on new elementsnoCenter the map when a searched marker is placed on the map: no, yes or Yes and zoom in.
Zoom level for auto center10The zoom level (1 - 22) used when you choose Yes and zoom in.
Set default Tile provideropenstreetmapThe default tile provider of the map, chosen from the tile providers that are enabled in the Maps module.

Icon dir and Icon url can be set for all Maps fields at once in your config.php; these win over the field settings:

php
$config['maps_icon_dir'] = '/var/www/html/images/map-icons/';
$config['maps_icon_url'] = 'https://example.com/images/map-icons/';

Single location ​

For the most common case, one location per entry (a store, an event, an office), set the Mode of the field to Single location. The editor is then a map with just a search field: (from v5.0.0)

  • Search an address (or type a latitude, longitude) and pick a result: the marker is placed there, with the address of the result.
  • Click on the map or drag the marker to move it, the address is looked up again.
  • The address of the location is shown below the search field.
  • There is one marker: a new location replaces the old one. The drawing tools are not shown.

Single location

In the template the location is one variable away:

{exp:channel:entries channel="stores"}
    <h2>{title}</h2>
    <p>{store_location:address}</p>

    {exp:reinos_maps:map center:latlng="{store_location:latlng}" zoom="15"}
        {maps:add_marker latlng="{store_location:latlng}" title="{title:attr_safe}"}
    {/exp:reinos_maps:map}
{/exp:channel:entries}

See the location variables. The field keeps the same data as a field with multiple layers, so you can switch the mode of an existing field: the first marker is the location.

The editor ​

On the Publish page the field is a map with a search and tools on it, and a panel next to it with everything on the map. (the editor is new in v5.0.0)

The editor

Search an address ​

Type an address (or paste a latitude, longitude) in the search on the map: the places appear while you type. Pick one with the mouse or with the arrow keys and Enter, and a marker is placed there with the address as its name. My location in the panel places a marker on your location.

Search an address

Draw ​

The tools below the search add a marker, a line, an area, a circle or a rectangle. Click on the map to place the points, and finish a line or an area with a double click, Enter or Finish. The tools follow the permissions of the field.

Draw an area

Edit ​

Click on something on the map, or on its row in the panel, to edit it. The panel shows its name (shown when you hover it), the icon of a marker, the color, opacity and width of a line and the fill of an area, and its popup. A change is shown right away. You can drag the selected marker, or move the points of the selected shape.

Edit an area

Undo and the keys ​

Every change can be undone with the undo button or Ctrl/Cmd + Z (and redone with Ctrl/Cmd + Shift + Z), also a deleted item. Delete removes the selected item, Escape stops drawing.

Map settings ​

The settings button in the panel shows the settings that are saved with the map of the entry: the style of the map and the styles in the style switcher, the scroll wheel, the zoom and scale controls and their position, the max zoom level and an overlay (HTML and position). The map shows the view (center and zoom) it has when you save the entry.

Map settings

Reset the map ​

The reset button in the panel puts the map back as it was when you opened the entry.

Logs ​

What the fieldtype logs (e.g. unreadable field data or a failed validation) is in the log of Maps, see CP overview. The What to log setting of Maps applies to it.