Make multiple maps on one post possible by changing ids

This commit is contained in:
Markus Ankenbrand 2016-11-05 20:38:08 +01:00
parent c67c57effa
commit d26917096a

View file

@ -78,16 +78,16 @@
<div class="post-meta"> <div class="post-meta">
<div class='map' style='height:300px; margin-bottom: 1.6842em' id='map-<?php echo $id ?>-single'></div> <div class='map' style='height:300px; margin-bottom: 1.6842em' id='map-<?php echo $id ?>-single'></div>
<script type='text/javascript'> <script type='text/javascript'>
var map; var single_map;
var map_center = {lat: <?php echo $location['lat'] ?>, lng: <?php echo $location['lng'] ?> }; var single_map_center = {lat: <?php echo $location['lat'] ?>, lng: <?php echo $location['lng'] ?> };
function initMap() { function initMap() {
map = new google.maps.Map(document.getElementById('map-<?php echo $id ?>-single'), { map = new google.maps.Map(document.getElementById('map-<?php echo $id ?>-single'), {
center: map_center, center: single_map_center,
zoom: 15 zoom: 15
}); });
var marker = new google.maps.Marker({ var marker = new google.maps.Marker({
position: map_center, position: single_map_center,
map: map map: single_map
}); });
} }
</script> </script>