For the complete documentation index, see llms.txt. This page is also available as Markdown.

Displaying Map field

Advanced Views natively supports the following map types:

  1. ACF: any Map field (including Multiple Markers and OpenStreetMap addons)

  2. MetaBox: any Map, OpenStreetMap field

1. How to display a Map field

  1. Add any Map field

  2. Save the Layout, copy its embedding shortcode

  3. Embed Layout: paste the shortcode inside the target place

Advanced Views automatically creates necessary HTML markup for the map and markers, enqueues the map provider's JavaScript, and initializes the map.

Important! For Google Maps, ensure you've defined the API key according to the field provider Docs. For ACF, it's:

// Google Map API key
add_filter('acf/fields/google_map/api', function ($apiSettings) {
    return array_merge($apiSettings, [
        'key' => 'YOUR_KEY_HERE',
    ]);
});

Copy the code snippet below and paste it into your theme’s functions.php file, replacing the ‘YOUR_KEY_HERE’ with your API key. Get Google Maps API key here.

2. Markers customization (Pro)

Switch to the Field Options tab for more control of your map and its display.

Map Marker Icon - Customize the Map Marker by using your own icon or uploading an image from Flaticon (.png, .jpg allowed). Dimensions of 32x32px is recommended.

Map Marker icon title - Shown when mouse hovers on Map Marker.

Hide Map - The Google Map is shown by default. Turn on the switcher to hide the map.

Show address from the map - The address is hidden by default. Turn this on to show the address from the map.

Map address format - By Default the address format is street number, street name, city, state, post code and country. You can change the order or hide some parts by using the provided variables in your Custom Template.

3. Displaying CPT items on a single map

This page focuses on embedding single maps on individual pages or Custom Post Type items. However, there are scenarios where displaying multiple CPT items on a single map is essential.

For example, if you’re managing an "events" CPT, you might need to showcase all events on a single map to provide a comprehensive view of all locations.

The process leverages ACF to store item coordinates as post meta, allowing you to query these CPT items and render them as markers on a unified map.

For a step-by-step guide on this, read the "CPT items map" article.

4. FAQs

How do I change the map height?

Change the height of the Google Map, visit the field group in ACF and define the ‘Height’ in px. Alternatively, define the height using CSS by copying the snippet below into your Layout's CSS Code field in the CSS & JS tab.

Last updated