Hi
My map marker does not display any data when clicked.
You can see the page here
I thought I had everything in my maps.js file, including:
// show info window when marker is clicked
google.maps.event.addListener(marker, 'click', function() {
infowindow.open( map, marker );
});
I also wanted this functionality: when the user clicks on the map, he gets redirected to the location in google maps.
So far I’ve been unable to retrieve the URL correctly, though.
I’ve tried this code, but it displays ‘undefined’ in the console
console.log($(".acf-map a").attr('href'));
$(".acf-map").click(function() {
window.open($(".acf-map a").attr('href'));
});
Any ideas?
Was looking for something similar and found your post – not sure about the map link out, but on the content not being shown when the marker is clicked, did you include content inside the marker div?
Such as:
<?php
$location = get_field('address');
if( !empty($location) ):
?>
<div class="acf-map">
<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>">
<?php echo $address['address']; ?>
<?php echo $address['lat']; ?>
<?php echo $address['lng']; ?>
</div>
</div>
<?php endif; ?>