Add locations to map
This commit is contained in:
parent
544d31a478
commit
2619b450b5
1 changed files with 32 additions and 1 deletions
|
|
@ -41,6 +41,10 @@
|
||||||
<?php edit_post_link(__('Edit Page','hitchcock'), '<div class="post-meta"><p class="post-edit">', '</p></div>'); ?>
|
<?php edit_post_link(__('Edit Page','hitchcock'), '<div class="post-meta"><p class="post-edit">', '</p></div>'); ?>
|
||||||
|
|
||||||
</div> <!-- /post-inner -->
|
</div> <!-- /post-inner -->
|
||||||
|
|
||||||
|
<div class="post-meta">
|
||||||
|
<div class='map' style='height:300px; margin-bottom: 1.6842em' id='map-stats'></div>
|
||||||
|
</div> <!-- /post-meta -->
|
||||||
|
|
||||||
<?php comments_template( '', true ); ?>
|
<?php comments_template( '', true ); ?>
|
||||||
|
|
||||||
|
|
@ -65,12 +69,39 @@
|
||||||
$places = get_field('orte');
|
$places = get_field('orte');
|
||||||
if($places){
|
if($places){
|
||||||
foreach ($places as $place){
|
foreach ($places as $place){
|
||||||
$locations[] = array("post" => $post->ID, "place" => $place);
|
$locations[] = array_merge(array("post" => $post->ID), $place);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endwhile;
|
endwhile;
|
||||||
var_dump($locations);
|
var_dump($locations);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var places = <?php echo json_encode($locations); ?>;
|
||||||
|
var map;
|
||||||
|
var map_center = {lat: parseFloat(places[0]['lat']), lng: parseFloat(places[0]['lng']) };
|
||||||
|
function initMap() {
|
||||||
|
map = new google.maps.Map(document.getElementById('map-stats'), {
|
||||||
|
center: map_center,
|
||||||
|
zoom: 15
|
||||||
|
});
|
||||||
|
var bounds = new google.maps.LatLngBounds();
|
||||||
|
for(var i = 0; i < places.length; i++){
|
||||||
|
var marker = new google.maps.Marker({
|
||||||
|
position: {lat: parseFloat(places[i]['lat']), lng: parseFloat(places[i]['lng']) },
|
||||||
|
map: map
|
||||||
|
});
|
||||||
|
marker.setVisible(true);
|
||||||
|
bounds.extend(marker.getPosition());
|
||||||
|
}
|
||||||
|
map.fitBounds(bounds);
|
||||||
|
window.setTimeout(function(){
|
||||||
|
if(map.getZoom() > 15){
|
||||||
|
map.setZoom(15);
|
||||||
|
}
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<?php get_footer(); ?>
|
<?php get_footer(); ?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue