Add code to include single map and multiple maps

This commit is contained in:
Markus Ankenbrand 2016-11-05 20:27:12 +01:00
parent fa86b1c431
commit 5cf9d92fca

View file

@ -76,12 +76,12 @@
<?php $location = get_field( 'ort' ); ?>
<?php if ( $location ) : ?>
<div class="post-meta">
<div class='map' style='height:300px; margin-bottom: 1.6842em' id='map-<?php echo $id ?>'></div>
<div class='map' style='height:300px; margin-bottom: 1.6842em' id='map-<?php echo $id ?>-single'></div>
<script type='text/javascript'>
var map;
var map_center = {lat: <?php echo $location['lat'] ?>, lng: <?php echo $location['lng'] ?> };
function initMap() {
map = new google.maps.Map(document.getElementById('map-<?php echo $id ?>'), {
map = new google.maps.Map(document.getElementById('map-<?php echo $id ?>-single'), {
center: map_center,
zoom: 15
});
@ -92,8 +92,29 @@
}
</script>
</div>
<?php endif; ?>
<?php $locations = get_field( 'orte' ); ?>
<?php if ( $location ) : ?>
<div class="post-meta">
<div class='map' style='height:300px; margin-bottom: 1.6842em' id='map-<?php echo $id ?>-multiple'></div>
<script type='text/javascript'>
var places = <?php echo json_decode($location); ?>;
var map;
var map_center = {lat: places[0]['lat'], lng: places[0]['lng'] };
function initMap() {
map = new google.maps.Map(document.getElementById('map-<?php echo $id ?>-multiple'), {
center: map_center,
zoom: 15
});
for(var i = 0; i < places; i++){
var marker = new google.maps.Marker({
position: {lat: places[i]['lat'], lng: places[i]['lng'] },
map: map
});
}
}
</script>
</div>
<?php endif; ?>
<?php