Add code to include single map and multiple maps
This commit is contained in:
parent
fa86b1c431
commit
5cf9d92fca
1 changed files with 25 additions and 4 deletions
29
single.php
29
single.php
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue