I'm trying to integrate a google map that displays the location of my posts. I managed to integrate the Google map thanks to the API. But I need to add a script just above the div where I insert my map which doesn't work because of a "SyntaxError: syntax error". Here is the code :
<script type="text/javascript"> var locations = [ <?php $i = 1; while ( have_posts() ) : the_post(); ?> <?php if ( get_post_meta($post->ID, 'latlng', true) !== '' ) : ?> { latlng : new google.maps.LatLng<?php echo get_post_meta($post->ID, 'latlng', true); ?>, }, <?php endif; ?> <?php $i++; endwhile; ?> ]; </script>
Where is it wrong ?
Thanks in advance !
Aucun commentaire:
Enregistrer un commentaire