Hello good people. I have a site showing the private airstrips in the UK and have a map of them all. However, I can’t get a “pop up” to show the name of the airfield when you click on a marker, with a link to that airfield card.
Here is my code.
<?php
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<!--My New Just Map Stuff-->
<h1>Map</h1>
<div class="acf-map">
<div id="airfiled_map" style="width: 100%; height: 1000px;"></div>
<?php
$justMap = new WP_Query(array(
'posts_per_page'=> -1,
'post_type' => 'airfield_card'
));
echo the_field('main_map');
$airfieldMap = array();
$i = 0;
while($justMap->have_posts()){
$justMap->the_post();
$mapLat = get_field('latitude');
$mapLng = get_field('longitude');
$airfieldMap[$i]['lat'] = $mapLat;
$airfieldMap[$i]['long'] = $mapLng;
$i++;
?>
<!-- <div class="marker" data-lat="<?php echo $mapLat ?>" data-lng="<?php echo $mapLng; ?>"></div> -->
<?php echo the_title(); ?>
<?php
echo paginate_links();
}
?>
<script type="text/javascript">
var airfieldMap = <?php echo json_encode($airfieldMap); ?>;
var airfieldMap_zoom = 6;
var airfieldMap_TypeId = 'terrain'; //satellite
</script>
<?php
wp_enqueue_script( 'app_js', get_stylesheet_directory_uri(). '/assets/js/airfiled_map.js', array( 'jquery'), '1.0', true );
?>
</div>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_sidebar();
get_footer();