pass indexes array to js function

This commit is contained in:
lenovo
2022-11-11 18:36:04 +01:00
parent e255a36b29
commit 65df3e630d
4 changed files with 14 additions and 13 deletions

View File

@@ -82,8 +82,8 @@ function mp_ljdp_map() {
//mp_console_log($locations); //mp_console_log($locations);
$filters = mp_get_filters($events); $filters = mp_get_filters($events);
mp_console_log("php filters:"); //mp_console_log("php filters:");
mp_console_log($filters); //mp_console_log($filters);
$to_add = array( $to_add = array(
"locations" => $locations, "locations" => $locations,

View File

@@ -17,7 +17,7 @@ function mp_create_div(&$filters) {
'; ';
foreach ($filter as $value) { foreach ($filter as $value) {
$mp_map_div .= ' $mp_map_div .= '
<p onclick="mp_filter_selection({lat:43.563, lng:76.4325})">'.$value->_name.'</p> <p onclick="mp_filter_selection('.json_encode($value->indexes).')">'.$value->_name.'</p>
'; ';
} }
$mp_map_div .= ' $mp_map_div .= '

View File

@@ -1,4 +1,4 @@
function mp_filter_selection(coordinates) { function mp_filter_selection(indexes) {
/* /*
* following variable are created by mp_add_to_script.php * following variable are created by mp_add_to_script.php
@@ -6,6 +6,6 @@ function mp_filter_selection(coordinates) {
* *
*/ */
console.log(coordinates); console.log(indexes);
// coordinates.setMap(map); // coordinates.setMap(map);
} }

View File

@@ -15,6 +15,7 @@ function mp_init_map() {
* - filters: { - pays : [ { - _name : "" } ] } * - filters: { - pays : [ { - _name : "" } ] }
* { [ { - villes : [] } ] } * { [ { - villes : [] } ] }
* { [ { - categories: [] } ] } * { [ { - categories: [] } ] }
* { [ { - indexes : [] } ] }
* { [ { - mode : [] }, ...] } * { [ { - mode : [] }, ...] }
* { [ ] } * { [ ] }
* { } * { }
@@ -49,17 +50,17 @@ function mp_init_map() {
let marker_cluster = draw_clusters(map, markers); let marker_cluster = draw_clusters(map, markers);
//let toggle = true;
// add listener to close infowindow at any click on map // add listener to close infowindow at any click on map
let toggle = true;
map.addListener('click', function() { map.addListener('click', function() {
infowindow.close(); infowindow.close();
console.log(toggle); //console.log(toggle);
//markers[index].setMap(null); ////markers[index].setMap(null);
if (toggle === true) //if (toggle === true)
marker_cluster.removeMarker(markers[25]); // marker_cluster.removeMarker(markers[25]);
else //else
marker_cluster.addMarker(markers[25]); // marker_cluster.addMarker(markers[25]);
toggle = (toggle === true)? false : true ; //toggle = (toggle === true)? false : true ;
}); });
} }