fix filters not working because index null

This commit is contained in:
lenovo
2022-11-12 18:27:45 +01:00
parent 5497ceea0f
commit c140187aa9
5 changed files with 32 additions and 19 deletions

View File

@@ -172,6 +172,7 @@ function mp_get_published_events() {
$event = mp_fill_fields_value($post->ID);
$event->id = $post->ID;
$event->title = trim($post->post_title, " ");
$event->index = null;
array_push($events, $event);
}
return $events;
@@ -190,7 +191,7 @@ function mp_get_published_events() {
- nom : "";
- irl : bool;
- id : x;
(- index : x;) // not there for now
- index : x (default null);
- title : "";
- location : {}
- street : "";

View File

@@ -71,12 +71,20 @@ function mp_get_filters(&$events) {
$filters = (object)[];
foreach ($events as $event) {
// no index means no coordinates
$index = $event->index;
if ($index === null)
continue;
// create array of menus
$fields = array(
"pays" => $event->location->country,
"categories" => $event->categorie,
"mode" => ($event->irl)? "En présentiel" : "En ligne",
);
$index = $event->index;
// fill all menu with other menus without doubles
foreach ($fields as $key => $value) {
if (! isset($filters->$key))
$filters->$key = [];

View File

@@ -3,15 +3,18 @@
// add true for noDraw
// bounds : https://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-visible-markers/19304625#19304625
/**
* if zoom_in is true:
* zoom to new selection,
* even if already visible in current view
*/
function filter_show_only_selection(indexes, zoom_in = false) {
console.log("indexes:");
console.log(indexes);
console.log(" ");
console.log("indexes:");
console.log(indexes);
let indexes_count = indexes.length;
if (indexes_count === 0)
@@ -22,11 +25,11 @@ function filter_show_only_selection(indexes, zoom_in = false) {
let marker = g_markers[0];
let position = marker.getPosition();
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);
console.log("bounds:");
console.log(bounds);
console.log("bounds:");
console.log(bounds);
let outside_bounds = false;
for (let index of indexes) {
@@ -56,3 +59,4 @@ function filter_show_all() {
g_map.setCenter(coordinates_default);
g_map.setZoom(2);
}

View File

@@ -43,11 +43,6 @@ function mp_init_map() {
* - let max_zoom = x
*/
console.log("locations:");
console.log(locations);
console.log("filters:");
console.log(filters);
let map_div = document.getElementById("ljdp_map");
//let filters_div = document.getElementById("ljdp_map_filters");
let infowindow = new google.maps.InfoWindow();
@@ -59,10 +54,15 @@ function mp_init_map() {
g_map = create_map(map_div);
g_markers = create_markers(g_map, locations, infowindow);
console.log("markers:");
console.log(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
g_map.addListener('click', function() {

View File

@@ -17,10 +17,10 @@
}
/* TMP */
.et_pb_module.et_pb_image.et_pb_image_0_tb_header {
display: none;
}
.et-l.et-l--header {
.et_pb_module.et_pb_image.et_pb_image_0_tb_header,
.et-l.et-l--header,
#wp-admin-bar-top-secondary.ab-top-secondary.ab-top-menu
{
display: none;
}