-
Notifications
You must be signed in to change notification settings - Fork 22
Theme Overrides
Jörn Lund edited this page May 14, 2022
·
1 revision
Theme Overrides allow you to add custom map templates to your theme.
Add a subdirectory osm-maps
to your theme root.
Place a template file like this:
<?php
/**
* Map Template Name: Not a Map at all
*/
/**
* @var array $args
* array(
* 'field' => (array) ACF Field,
* 'map' => (array) Map Data. @see https://github.com/mcguffin/acf-openstreetmap-field/wiki/Usage#raw-data-structure
* )
*/
?><div class="not-a-map">
<h3><?php
printf( 'Non-Map @ %F / %F', $args['map']['lat'], $args['map']['lng'] );
?></h3>
<?php
if ( count( $args['map']['markers'] ) ) {
?>
<p>Markers</p>
<ol>
<?php
foreach ( $args['map']['markers'] as $marker ) {
?>
<li><?php
printf( '%s @ %F / %F', $marker['label'], $marker['lat'], $marker['lng'] );
?></li
<?php
}
?>
</ol>
<?php
} else {
?>
<p>– no markers –</p>
<?php
}
?>
</div>
<?php
Create a new Field Group and add an OpenStreetMap field. The new template will be one of the Return format options:
Create a post and add some markers.
You can use the [acf]
shortcode to display the map in your post.
Enjoy the output!