fix filters not working because index null
This commit is contained in:
@@ -172,6 +172,7 @@ function mp_get_published_events() {
|
|||||||
$event = mp_fill_fields_value($post->ID);
|
$event = mp_fill_fields_value($post->ID);
|
||||||
$event->id = $post->ID;
|
$event->id = $post->ID;
|
||||||
$event->title = trim($post->post_title, " ");
|
$event->title = trim($post->post_title, " ");
|
||||||
|
$event->index = null;
|
||||||
array_push($events, $event);
|
array_push($events, $event);
|
||||||
}
|
}
|
||||||
return $events;
|
return $events;
|
||||||
@@ -190,7 +191,7 @@ function mp_get_published_events() {
|
|||||||
- nom : "";
|
- nom : "";
|
||||||
- irl : bool;
|
- irl : bool;
|
||||||
- id : x;
|
- id : x;
|
||||||
(- index : x;) // not there for now
|
- index : x (default null);
|
||||||
- title : "";
|
- title : "";
|
||||||
- location : {}
|
- location : {}
|
||||||
- street : "";
|
- street : "";
|
||||||
|
|||||||
@@ -71,12 +71,20 @@ function mp_get_filters(&$events) {
|
|||||||
$filters = (object)[];
|
$filters = (object)[];
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
|
|
||||||
|
// no index means no coordinates
|
||||||
|
$index = $event->index;
|
||||||
|
if ($index === null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// create array of menus
|
||||||
$fields = array(
|
$fields = array(
|
||||||
"pays" => $event->location->country,
|
"pays" => $event->location->country,
|
||||||
"categories" => $event->categorie,
|
"categories" => $event->categorie,
|
||||||
"mode" => ($event->irl)? "En présentiel" : "En ligne",
|
"mode" => ($event->irl)? "En présentiel" : "En ligne",
|
||||||
);
|
);
|
||||||
$index = $event->index;
|
|
||||||
|
// fill all menu with other menus without doubles
|
||||||
foreach ($fields as $key => $value) {
|
foreach ($fields as $key => $value) {
|
||||||
if (! isset($filters->$key))
|
if (! isset($filters->$key))
|
||||||
$filters->$key = [];
|
$filters->$key = [];
|
||||||
|
|||||||
@@ -3,15 +3,18 @@
|
|||||||
// add true for noDraw
|
// add true for noDraw
|
||||||
// bounds : https://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-visible-markers/19304625#19304625
|
// bounds : https://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-visible-markers/19304625#19304625
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if zoom_in is true:
|
* if zoom_in is true:
|
||||||
* zoom to new selection,
|
* zoom to new selection,
|
||||||
* even if already visible in current view
|
* even if already visible in current view
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function filter_show_only_selection(indexes, zoom_in = false) {
|
function filter_show_only_selection(indexes, zoom_in = false) {
|
||||||
|
|
||||||
console.log("indexes:");
|
console.log(" ");
|
||||||
console.log(indexes);
|
console.log("indexes:");
|
||||||
|
console.log(indexes);
|
||||||
|
|
||||||
let indexes_count = indexes.length;
|
let indexes_count = indexes.length;
|
||||||
if (indexes_count === 0)
|
if (indexes_count === 0)
|
||||||
@@ -22,11 +25,11 @@ function filter_show_only_selection(indexes, zoom_in = false) {
|
|||||||
let marker = g_markers[0];
|
let marker = g_markers[0];
|
||||||
let position = marker.getPosition();
|
let position = marker.getPosition();
|
||||||
let current_bounds = g_map.getBounds();
|
let current_bounds = g_map.getBounds();
|
||||||
console.log("current_bounds:");
|
console.log("current_bounds:");
|
||||||
console.log(current_bounds);
|
console.log(current_bounds);
|
||||||
let bounds = new google.maps.LatLngBounds(position);
|
let bounds = new google.maps.LatLngBounds(position);
|
||||||
console.log("bounds:");
|
console.log("bounds:");
|
||||||
console.log(bounds);
|
console.log(bounds);
|
||||||
|
|
||||||
let outside_bounds = false;
|
let outside_bounds = false;
|
||||||
for (let index of indexes) {
|
for (let index of indexes) {
|
||||||
@@ -56,3 +59,4 @@ function filter_show_all() {
|
|||||||
g_map.setCenter(coordinates_default);
|
g_map.setCenter(coordinates_default);
|
||||||
g_map.setZoom(2);
|
g_map.setZoom(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,6 @@ function mp_init_map() {
|
|||||||
* - let max_zoom = x
|
* - let max_zoom = x
|
||||||
*/
|
*/
|
||||||
|
|
||||||
console.log("locations:");
|
|
||||||
console.log(locations);
|
|
||||||
console.log("filters:");
|
|
||||||
console.log(filters);
|
|
||||||
|
|
||||||
let map_div = document.getElementById("ljdp_map");
|
let map_div = document.getElementById("ljdp_map");
|
||||||
//let filters_div = document.getElementById("ljdp_map_filters");
|
//let filters_div = document.getElementById("ljdp_map_filters");
|
||||||
let infowindow = new google.maps.InfoWindow();
|
let infowindow = new google.maps.InfoWindow();
|
||||||
@@ -59,10 +54,15 @@ function mp_init_map() {
|
|||||||
|
|
||||||
g_map = create_map(map_div);
|
g_map = create_map(map_div);
|
||||||
g_markers = create_markers(g_map, locations, infowindow);
|
g_markers = create_markers(g_map, locations, infowindow);
|
||||||
console.log("markers:");
|
|
||||||
console.log(g_markers);
|
|
||||||
g_marker_cluster = draw_clusters(g_map, g_markers);
|
g_marker_cluster = draw_clusters(g_map, g_markers);
|
||||||
|
|
||||||
|
//console.log("locations:");
|
||||||
|
//console.log(locations);
|
||||||
|
//console.log("filters:");
|
||||||
|
//console.log(filters);
|
||||||
|
//console.log("markers:");
|
||||||
|
//console.log(g_markers);
|
||||||
|
|
||||||
|
|
||||||
// add listener to close infowindow at any click on map
|
// add listener to close infowindow at any click on map
|
||||||
g_map.addListener('click', function() {
|
g_map.addListener('click', function() {
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TMP */
|
/* TMP */
|
||||||
.et_pb_module.et_pb_image.et_pb_image_0_tb_header {
|
.et_pb_module.et_pb_image.et_pb_image_0_tb_header,
|
||||||
display: none;
|
.et-l.et-l--header,
|
||||||
}
|
#wp-admin-bar-top-secondary.ab-top-secondary.ab-top-menu
|
||||||
.et-l.et-l--header {
|
{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user