diff --git a/README.md b/README.md index f1c774d..29e66d4 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ - [maps api in php](http://www.learningaboutelectronics.com/Articles/Google-maps-API-JSON-PHP.php) - [google maps api url parameters](https://developers.google.com/maps/documentation/javascript/url-params) - [google maps api references](https://developers.google.com/maps/documentation/javascript/reference) +- [remove marker cluster](https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html#removeMarker) --- diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index f699b04..16ca840 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -60,6 +60,7 @@ function mp_ljdp_map() { wp_enqueue_script('mp_create_filters', plugins_url('scripts/mp_create_filters.js', __FILE__), '', '', false); wp_enqueue_script('mp_create_markers', plugins_url('scripts/mp_create_markers.js', __FILE__), '', '', false); wp_enqueue_script('mp_draw_clusters', plugins_url('scripts/mp_draw_clusters.js', __FILE__), '', '', false); + wp_enqueue_script('mp_filter_events', plugins_url('scripts/mp_filter_events.js', __FILE__), '', '', false); // enqueue footer wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true); diff --git a/srcs/plugins/map_prof/mp_create_div.php b/srcs/plugins/map_prof/mp_create_div.php index 9260d4f..32c7a34 100644 --- a/srcs/plugins/map_prof/mp_create_div.php +++ b/srcs/plugins/map_prof/mp_create_div.php @@ -17,7 +17,7 @@ function mp_create_div(&$filters) { '; foreach ($filter as $value) { $mp_map_div .= ' -

'.$value->_name.'

+

'.$value->_name.'

'; } $mp_map_div .= ' diff --git a/srcs/plugins/map_prof/scripts/mp_draw_clusters.js b/srcs/plugins/map_prof/scripts/mp_draw_clusters.js index ed260b4..5f2a74a 100644 --- a/srcs/plugins/map_prof/scripts/mp_draw_clusters.js +++ b/srcs/plugins/map_prof/scripts/mp_draw_clusters.js @@ -48,5 +48,5 @@ function draw_clusters(map, markers) { } } - new markerClusterer.MarkerClusterer({ map, markers, renderer }); + return new markerClusterer.MarkerClusterer({ map, markers, renderer }); } diff --git a/srcs/plugins/map_prof/scripts/mp_filter_events.js b/srcs/plugins/map_prof/scripts/mp_filter_events.js new file mode 100644 index 0000000..8108329 --- /dev/null +++ b/srcs/plugins/map_prof/scripts/mp_filter_events.js @@ -0,0 +1,11 @@ +function mp_filter_selection(coordinates) { + + /* + * following variable are created by mp_add_to_script.php + * + * + */ + + console.log(coordinates); +// coordinates.setMap(map); +} diff --git a/srcs/plugins/map_prof/scripts/mp_info_window.js b/srcs/plugins/map_prof/scripts/mp_info_window.js index f42dc1f..b8b9034 100644 --- a/srcs/plugins/map_prof/scripts/mp_info_window.js +++ b/srcs/plugins/map_prof/scripts/mp_info_window.js @@ -26,6 +26,9 @@ function attach_info_window(map, marker, events, infowindow) { marker.addListener('click', () => { + // test : + //marker.setMap(null); + let view_center = map.getCenter(); let marker_position = marker.getPosition(); console.log("marker position: " + marker_position); diff --git a/srcs/plugins/map_prof/scripts/mp_init_map.js b/srcs/plugins/map_prof/scripts/mp_init_map.js index 1cb602a..16a7634 100644 --- a/srcs/plugins/map_prof/scripts/mp_init_map.js +++ b/srcs/plugins/map_prof/scripts/mp_init_map.js @@ -18,27 +18,9 @@ function mp_init_map() { * { [ { - mode : [] }, ...] } * { [ ] } * { } - * { [ ] } - * { - villes : [ { - _name : "" } ] } - * { [ { - pays : [] } ] } - * { [ { - categories: [] } ] } - * { [ { - mode : [] }, ...] } - * { [ ] } - * { } - * { [ ] } - * { - categories: [ { - _name : "" } ] } - * { [ { - pays : [] } ] } - * { [ { - villes : [] } ] } - * { [ { - mode : [] }, ...] } - * { [ ] } - * { } - * { } - * { [ ] } - * { - mode : [ { - _name : "" } ] } - * { [ { - pays : [] } ] } - * { [ { - villes : [] } ] } - * { [ { - categories: [] }, ...] } - * { [ ] } + * { - villes : ... } + * { - categories: ... } + * { - mode : ... } * { } * * - let filters @@ -89,14 +71,22 @@ function mp_init_map() { let map = new google.maps.Map(map_div, map_options); let markers = create_markers(map, locations, infowindow); - draw_clusters(map, markers); + let marker_cluster = draw_clusters(map, markers); let filters_div = document.getElementById("ljdp_map_filters"); //fill_filters(filters_div); // add listener to close infowindow at any click on map + let toggle = true; map.addListener('click', function() { infowindow.close(); + console.log(toggle); + //markers[index].setMap(null); + if (toggle === true) + marker_cluster.removeMarker(markers[25]); + else + marker_cluster.addMarker(markers[25]); + toggle = (toggle === true)? false : true ; }); }