removing and adding markers in cluster works
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
- [maps api in php](http://www.learningaboutelectronics.com/Articles/Google-maps-API-JSON-PHP.php)
|
- [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 url parameters](https://developers.google.com/maps/documentation/javascript/url-params)
|
||||||
- [google maps api references](https://developers.google.com/maps/documentation/javascript/reference)
|
- [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)
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -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_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_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_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
|
// enqueue footer
|
||||||
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true);
|
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function mp_create_div(&$filters) {
|
|||||||
';
|
';
|
||||||
foreach ($filter as $value) {
|
foreach ($filter as $value) {
|
||||||
$mp_map_div .= '
|
$mp_map_div .= '
|
||||||
<p>'.$value->_name.'</p>
|
<p onclick="mp_filter_selection({lat:43.563, lng:76.4325})">'.$value->_name.'</p>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
$mp_map_div .= '
|
$mp_map_div .= '
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ function draw_clusters(map, markers) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new markerClusterer.MarkerClusterer({ map, markers, renderer });
|
return new markerClusterer.MarkerClusterer({ map, markers, renderer });
|
||||||
}
|
}
|
||||||
|
|||||||
11
srcs/plugins/map_prof/scripts/mp_filter_events.js
Normal file
11
srcs/plugins/map_prof/scripts/mp_filter_events.js
Normal file
@@ -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);
|
||||||
|
}
|
||||||
@@ -26,6 +26,9 @@ function attach_info_window(map, marker, events, infowindow) {
|
|||||||
|
|
||||||
marker.addListener('click', () => {
|
marker.addListener('click', () => {
|
||||||
|
|
||||||
|
// test :
|
||||||
|
//marker.setMap(null);
|
||||||
|
|
||||||
let view_center = map.getCenter();
|
let view_center = map.getCenter();
|
||||||
let marker_position = marker.getPosition();
|
let marker_position = marker.getPosition();
|
||||||
console.log("marker position: " + marker_position);
|
console.log("marker position: " + marker_position);
|
||||||
|
|||||||
@@ -18,27 +18,9 @@ function mp_init_map() {
|
|||||||
* { [ { - mode : [] }, ...] }
|
* { [ { - mode : [] }, ...] }
|
||||||
* { [ ] }
|
* { [ ] }
|
||||||
* { }
|
* { }
|
||||||
* { [ ] }
|
* { - villes : ... }
|
||||||
* { - villes : [ { - _name : "" } ] }
|
* { - categories: ... }
|
||||||
* { [ { - pays : [] } ] }
|
* { - mode : ... }
|
||||||
* { [ { - categories: [] } ] }
|
|
||||||
* { [ { - mode : [] }, ...] }
|
|
||||||
* { [ ] }
|
|
||||||
* { }
|
|
||||||
* { [ ] }
|
|
||||||
* { - categories: [ { - _name : "" } ] }
|
|
||||||
* { [ { - pays : [] } ] }
|
|
||||||
* { [ { - villes : [] } ] }
|
|
||||||
* { [ { - mode : [] }, ...] }
|
|
||||||
* { [ ] }
|
|
||||||
* { }
|
|
||||||
* { }
|
|
||||||
* { [ ] }
|
|
||||||
* { - mode : [ { - _name : "" } ] }
|
|
||||||
* { [ { - pays : [] } ] }
|
|
||||||
* { [ { - villes : [] } ] }
|
|
||||||
* { [ { - categories: [] }, ...] }
|
|
||||||
* { [ ] }
|
|
||||||
* { }
|
* { }
|
||||||
*
|
*
|
||||||
* - let filters
|
* - let filters
|
||||||
@@ -89,14 +71,22 @@ function mp_init_map() {
|
|||||||
|
|
||||||
let map = new google.maps.Map(map_div, map_options);
|
let map = new google.maps.Map(map_div, map_options);
|
||||||
let markers = create_markers(map, locations, infowindow);
|
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");
|
let filters_div = document.getElementById("ljdp_map_filters");
|
||||||
//fill_filters(filters_div);
|
//fill_filters(filters_div);
|
||||||
|
|
||||||
// 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);
|
||||||
|
//markers[index].setMap(null);
|
||||||
|
if (toggle === true)
|
||||||
|
marker_cluster.removeMarker(markers[25]);
|
||||||
|
else
|
||||||
|
marker_cluster.addMarker(markers[25]);
|
||||||
|
toggle = (toggle === true)? false : true ;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user