wip try to modify zoom level with filters
This commit is contained in:
@@ -13,11 +13,11 @@ function mp_create_div(&$filters) {
|
|||||||
<p>'.$key.'</p>
|
<p>'.$key.'</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="filter_menu_drop" tabindex=0>
|
<div class="filter_menu_drop" tabindex=0>
|
||||||
<p>TOUT DESELECTIONNER</p>
|
<p onclick="filter_show_all()">TOUT DESELECTIONNER</p>
|
||||||
';
|
';
|
||||||
foreach ($filter as $value) {
|
foreach ($filter as $value) {
|
||||||
$mp_map_div .= '
|
$mp_map_div .= '
|
||||||
<p onclick="mp_filter_selection('.json_encode($value->indexes).')">'.$value->_name.'</p>
|
<p onclick="filter_show_only_selection('.json_encode($value->indexes).')">'.$value->_name.'</p>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
$mp_map_div .= '
|
$mp_map_div .= '
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
function create_map(map_div) {
|
function create_map(map_div) {
|
||||||
// default map center to france
|
// default map center to france
|
||||||
let map_center = coordinates_default;
|
let map_center = coordinates_default;
|
||||||
|
// map_center = {lat:-2.515748362923059, lng:32.93366215464864};
|
||||||
let world_bound = {
|
let world_bound = {
|
||||||
north: 80,
|
north: 80,
|
||||||
south: -80,
|
south: -80,
|
||||||
|
|||||||
@@ -1,4 +1,38 @@
|
|||||||
function mp_filter_selection(indexes) {
|
|
||||||
|
|
||||||
console.log(indexes);
|
// https://googlemaps.github.io/js-markerclusterer/classes/MarkerClusterer.html
|
||||||
|
// add true for noDraw
|
||||||
|
// bounds : https://stackoverflow.com/questions/19304574/center-set-zoom-of-map-to-cover-all-visible-markers/19304625#19304625
|
||||||
|
|
||||||
|
function filter_show_only_selection(indexes) {
|
||||||
|
console.log("filter_show_only_selection");
|
||||||
|
|
||||||
|
marker_cluster.clearMarkers(true);
|
||||||
|
//marker_cluster.removeMarkers(markers, true);
|
||||||
|
|
||||||
|
let current_bounds = map.getBounds();
|
||||||
|
console.log("current_bounds:");
|
||||||
|
console.log(current_bounds);
|
||||||
|
let bounds = new google.maps.LatLngBounds(current_bounds);
|
||||||
|
console.log("bounds:");
|
||||||
|
console.log(bounds);
|
||||||
|
//for (let index of indexes)
|
||||||
|
|
||||||
|
for (let index of indexes) {
|
||||||
|
let marker = markers[index];
|
||||||
|
let position = marker.getPosition();
|
||||||
|
console.log(position);
|
||||||
|
console.log(bounds.contains(position));
|
||||||
|
|
||||||
|
marker_cluster.addMarker(marker, true);
|
||||||
|
}
|
||||||
|
marker_cluster.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
function filter_show_all() {
|
||||||
|
console.log("filter_show_all");
|
||||||
|
marker_cluster.addMarkers(markers);
|
||||||
|
}
|
||||||
|
|
||||||
|
function filter_zoom_on_selection(indexes) {
|
||||||
|
marker_cluster.addMarkers(markers);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
|
||||||
|
let map = {};
|
||||||
|
let markers = [];
|
||||||
|
let marker_cluster = {};
|
||||||
|
//let bounds = {};
|
||||||
|
|
||||||
function mp_init_map() {
|
function mp_init_map() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -39,28 +45,21 @@ function mp_init_map() {
|
|||||||
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();
|
||||||
|
//bounds = new google.maps.LatLngBounds();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DRAW MAP
|
* DRAW MAP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let map = create_map(map_div);
|
map = create_map(map_div);
|
||||||
let markers = create_markers(map, locations, infowindow);
|
markers = create_markers(map, locations, infowindow);
|
||||||
let marker_cluster = draw_clusters(map, markers);
|
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
|
||||||
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 ;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,12 @@
|
|||||||
color: blue;
|
color: blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TMP */
|
||||||
|
.et_pb_module.et_pb_image.et_pb_image_0_tb_header {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.et-l.et-l--header {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user