149 lines
No EOL
4.6 KiB
PHP
149 lines
No EOL
4.6 KiB
PHP
<?php get_header(); ?>
|
|
|
|
<div class="content section-inner">
|
|
|
|
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
|
|
|
|
<div <?php post_class('post single'); ?>>
|
|
|
|
<div class="post-container">
|
|
|
|
<?php if ( has_post_thumbnail() ) : ?>
|
|
|
|
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' ); $thumb_url = $thumb['0']; ?>
|
|
|
|
<div class="featured-media">
|
|
|
|
<?php the_post_thumbnail('post-image'); ?>
|
|
|
|
</div> <!-- /featured-media -->
|
|
|
|
<?php endif; ?>
|
|
|
|
<div class="post-header">
|
|
|
|
<h1 class="post-title"><?php the_title(); ?></h1>
|
|
|
|
</div>
|
|
|
|
<div class="post-inner">
|
|
|
|
<div class="post-content">
|
|
|
|
<?php the_content(); ?>
|
|
|
|
<select name="travelers" id="travelers-select" multiple></select>
|
|
<div class="button" style="color:white" id="travelers-filter-button">Filter</div>
|
|
|
|
<?php wp_link_pages('before=<div class="clear"></div><p class="page-links">' . __( 'Pages:', 'hitchcock' ) . ' &after=</p>&seperator= <span class="sep">/</span> '); ?>
|
|
|
|
</div> <!-- /post-content -->
|
|
|
|
<div class="clear"></div>
|
|
|
|
<?php edit_post_link(__('Edit Page','hitchcock'), '<div class="post-meta"><p class="post-edit">', '</p></div>'); ?>
|
|
|
|
</div> <!-- /post-inner -->
|
|
|
|
<div class="post-meta">
|
|
<div class='map' style='height:600px; margin-bottom: 1.6842em' id='map-stats'></div>
|
|
</div> <!-- /post-meta -->
|
|
|
|
<?php comments_template( '', true ); ?>
|
|
|
|
</div> <!-- /post-container -->
|
|
|
|
</div> <!-- /post -->
|
|
|
|
<?php endwhile; else: ?>
|
|
|
|
<p><?php _e("We couldn't find any posts that matched your query. Please try again.", "hitchcock"); ?></p>
|
|
|
|
<?php endif; ?>
|
|
|
|
<div class="clear"></div>
|
|
|
|
</div> <!-- /content -->
|
|
|
|
<?php
|
|
query_posts( 'category_name=urlaub&posts_per_page=10000' );
|
|
$locations = array();
|
|
$traveler = array();
|
|
while ( have_posts() ) : the_post();
|
|
$places = get_field('orte');
|
|
if($places){
|
|
$traveler = array_unique(array_merge($traveler, get_field('mitreisende')));
|
|
foreach ($places as $place){
|
|
$locations[] = array_merge(array("post" => $post->ID, "title" => $post->post_title, "traveler" => get_field('mitreisende')), $place);
|
|
}
|
|
}
|
|
endwhile;
|
|
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']) };
|
|
var traveler = <?php echo json_encode(array_values($traveler)); ?>;
|
|
for(var i=0; i<traveler.length; i++){
|
|
var opt = document.createElement('OPTION');
|
|
var optTxt = document.createTextNode(traveler[i]);
|
|
opt.appendChild(optTxt);
|
|
document.getElementById('travelers-select').appendChild(opt);
|
|
}
|
|
var markers = [];
|
|
function initMap() {
|
|
markers = [];
|
|
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']) },
|
|
title: places[i]['title'],
|
|
url: "/?p="+places[i]['post'],
|
|
traveler: places[i]['traveler'],
|
|
map: map
|
|
});
|
|
marker.setVisible(true);
|
|
markers.push(marker);
|
|
google.maps.event.addListener(marker, 'click', function() {
|
|
window.location.href = this.url;
|
|
});
|
|
bounds.extend(marker.getPosition());
|
|
}
|
|
map.fitBounds(bounds);
|
|
window.setTimeout(function(){
|
|
if(map.getZoom() > 15){
|
|
map.setZoom(15);
|
|
}
|
|
}, 500);
|
|
}
|
|
|
|
function filterByTravelerClick(){
|
|
var val = document.getElementById('travelers-select').value;
|
|
filterMarkersByTravelers([val]);
|
|
}
|
|
|
|
function filterMarkersByTravelers(travelers){
|
|
for(var i=0; i<markers.length; i++){
|
|
markers[i].setVisible(false);
|
|
var all_there = true;
|
|
for(var j=0; j<travelers.length; j++){
|
|
if(markers[i]['traveler'].indexOf(travelers[j]) == -1){
|
|
all_there = false;
|
|
break;
|
|
}
|
|
}
|
|
if(all_there){
|
|
markers[i].setVisible(true);
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
|
|
<?php get_footer(); ?>
|