Home Forums General Issues ACF Maps — Link marker to post?


ACF Maps — Link marker to post?

  • I’m playing around with a feature request for a client.

    I have added a ACF Map field.

    I’m then querying a custom post type and displaying ALL the markers on the same map.

    How can I have a info box (you click the marker and it would show some post data of some sort) and / or a just link directly to the post the marker refers to.

    This is the code I’m using to display the multiple markers:

    	$the_query_map = new WP_Query( array( 'post_type' => 'corps-directory', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ) );
    	if($the_query_map->have_posts()) :
    	$the_ID = get_the_ID();
    	$get_google_map = get_field('location', $value);
    	$output_map[$the_ID]['map'] = '<div class="marker" data-lat="'.$get_google_map['lat'].'" data-lng="'.$get_google_map['lng'].'"></div>';
    	endwhile; endif;
    	?><div class="acf-map"><?php
    	foreach( $output_map as $key => $map_marker ):
    		echo $map_marker['map'];
  • Hi @dtomasch

    I’m afraid this topic is more related to Google Maps than to ACF. ACF is used to get the location data (latitude, longitude, and address). If you need to add an infobox, please check this documentation:

    If you need further support, please check Google Maps Community.

    I hope this makes sense. Thanks 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘ACF Maps — Link marker to post?’ is closed to new replies.