@adamsuper were you able to figure this out? I have the same issue.
@charlesr @lucius0101 @klapaucius4 Did you any of you find a solution for this?
@alan-brown @mastababa this should help out as a reference and working solution / starting point (and finish there as well most likely). Either with the WP_Query or the rest api Reference link
@frabiacca @mastababa You can use this a starting point (and finish there as well most likely). Either with the WP_Query
or the rest api
Reference link
@alitscha You can use this a starting point. Either with the WP_Query
or the rest api
Reference link
@weareduo did you ever get this figured out?
Rolling backed for me also.
@uptownbrent thanks! Yes that section is all acf. Its a repeater on their site, 4 repeaters, 4 maps.
It could be done with 1 repeater technically/post type and you use options to toggle markers and update map styling. That’s how I would do it now with what I know now.
I have other examples of ‘search’ etc, can be done with acf and getting into google maps.
@RenaissanceDesign did you get this working?
Do you have a possible example of the code you used to query the posts as you mentioned above?
I actually did that here: http://energycoalition.org/energy-architects-in-action/
in the add_marker portion I updated it to this:
/*
* add_marker
*/
function add_marker( $marker, map ) {
// var
var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
// create marker
var marker = new google.maps.Marker({
position : latlng,
map : map,
icon: '...'
});
// add to array
map.markers.push( marker );
// if marker contains HTML, add it to an infoWindow
if( $marker.html() )
{
// create info window
liTag=$("body ul.utilities").find("[data-lat='" + $marker.attr('data-lat') + "']");
// console.log(liTag);
// show info window when marker is clicked
$(liTag).click(function() {
infowindow.setContent($marker.html());
infowindow.open(map, marker);
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent($marker.html());
infowindow.open(map, marker);
});
// close info window when map is clicked
google.maps.event.addListener(map, 'click', function(event) {
if (infowindow) {
infowindow.close(); }
});
}
}
I use to separate loops, one to output the list items, and one for the map. In the list items I add the latitude to the LI itself
This will do it:
<?php
while(has_sub_field('diaporama')):
$image = get_sub_field('photos');
$image_full = $image['sizes']['large'];
$alt = $image['title']; ?>
<div class="col-split">
<a class="fancybox" rel="gallery1" href="<?php echo $image_full; ?>">
<img class="img_cen" src="<?php echo $image_thumb; ?>" alt="<?php echo $alt; ?>" title="<?php echo $alt; ?>" />
</a>
</div>
<?php endwhile; ?>
<?php endif; ?>
what I currently have, but doesn’t work is:
<div class="acf-map">
<?php
$featured_projects = get_field('locations_all');//relationship
if( $featured_projects ): ?>
<?php foreach( $featured_projects as $featured_project ):
$featured_project_id = $featured_project->ID;
$location = get_field('location');//field
?>
<div class="marker" data-lat="<?php echo $location['lat'], $featured_project_id; ?>" data-lng="<?php echo $location['lng'], $featured_project_id; ?>">
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.