Add function to filter markers by Traveler
This commit is contained in:
parent
ec1865e9e8
commit
1e9b9ab987
1 changed files with 14 additions and 2 deletions
|
|
@ -63,13 +63,13 @@
|
||||||
</div> <!-- /content -->
|
</div> <!-- /content -->
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
query_posts( 'category_name=urlaub&posts_per_page=1000' );
|
query_posts( 'category_name=urlaub&posts_per_page=10000' );
|
||||||
$locations = array();
|
$locations = array();
|
||||||
while ( have_posts() ) : the_post();
|
while ( have_posts() ) : the_post();
|
||||||
$places = get_field('orte');
|
$places = get_field('orte');
|
||||||
if($places){
|
if($places){
|
||||||
foreach ($places as $place){
|
foreach ($places as $place){
|
||||||
$locations[] = array_merge(array("post" => $post->ID, "title" => $post->post_title), $place);
|
$locations[] = array_merge(array("post" => $post->ID, "title" => $post->post_title, "traveler" => get_field('mitreisende')), $place);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endwhile;
|
endwhile;
|
||||||
|
|
@ -80,7 +80,9 @@
|
||||||
var places = <?php echo json_encode($locations); ?>;
|
var places = <?php echo json_encode($locations); ?>;
|
||||||
var map;
|
var map;
|
||||||
var map_center = {lat: parseFloat(places[0]['lat']), lng: parseFloat(places[0]['lng']) };
|
var map_center = {lat: parseFloat(places[0]['lat']), lng: parseFloat(places[0]['lng']) };
|
||||||
|
var markers = [];
|
||||||
function initMap() {
|
function initMap() {
|
||||||
|
markers = [];
|
||||||
map = new google.maps.Map(document.getElementById('map-stats'), {
|
map = new google.maps.Map(document.getElementById('map-stats'), {
|
||||||
center: map_center,
|
center: map_center,
|
||||||
zoom: 15
|
zoom: 15
|
||||||
|
|
@ -94,6 +96,7 @@
|
||||||
map: map
|
map: map
|
||||||
});
|
});
|
||||||
marker.setVisible(true);
|
marker.setVisible(true);
|
||||||
|
markers.push(marker);
|
||||||
google.maps.event.addListener(marker, 'click', function() {
|
google.maps.event.addListener(marker, 'click', function() {
|
||||||
window.location.href = this.url;
|
window.location.href = this.url;
|
||||||
});
|
});
|
||||||
|
|
@ -106,6 +109,15 @@
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
function filterMarkersByTraveler(traveler){
|
||||||
|
for(var i=0; i<markers.length; i++){
|
||||||
|
if(markers[i]['traveler'].index(traveler) > -1){
|
||||||
|
markers[i].setVisible(true);
|
||||||
|
} else {
|
||||||
|
markers[i].setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue