added location indexes to events
This commit is contained in:
@@ -59,6 +59,7 @@ function mp_ljdp_map() {
|
|||||||
wp_enqueue_script('mp_errors_map', plugins_url('scripts/mp_errors_map.js', __FILE__), '', '', false);
|
wp_enqueue_script('mp_errors_map', plugins_url('scripts/mp_errors_map.js', __FILE__), '', '', false);
|
||||||
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_create_map', plugins_url('scripts/mp_create_map.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);
|
wp_enqueue_script('mp_filter_events', plugins_url('scripts/mp_filter_events.js', __FILE__), '', '', false);
|
||||||
|
|
||||||
@@ -80,6 +81,11 @@ function mp_ljdp_map() {
|
|||||||
//mp_console_log("php locations:");
|
//mp_console_log("php locations:");
|
||||||
//mp_console_log($locations);
|
//mp_console_log($locations);
|
||||||
|
|
||||||
|
mp_console_log("php events:");
|
||||||
|
mp_console_log($events);
|
||||||
|
mp_console_log("php 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);
|
||||||
|
|||||||
@@ -177,4 +177,30 @@ function mp_get_published_events() {
|
|||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
event : {}
|
||||||
|
- heure_de_debut : "";
|
||||||
|
- heure_de_fin : "";
|
||||||
|
- categorie : "";
|
||||||
|
- date : "";
|
||||||
|
- pays : "";
|
||||||
|
- ville : "";
|
||||||
|
- adresse : "";
|
||||||
|
- prenom : "";
|
||||||
|
- nom : "";
|
||||||
|
- irl : bool;
|
||||||
|
- id : x;
|
||||||
|
- title : "";
|
||||||
|
- location : {}
|
||||||
|
- street : "";
|
||||||
|
- city : "";
|
||||||
|
- country : "";
|
||||||
|
- address : "";
|
||||||
|
- approximate : bool;
|
||||||
|
- coordinates : {}
|
||||||
|
- lat : x;
|
||||||
|
- lng : x;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function mp_fill_name($fields, $name, &$menu) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mp_get_filters($events) {
|
function mp_get_filters(&$events) {
|
||||||
$filters = (object)[];
|
$filters = (object)[];
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ function mp_sort_n_insert(&$event, &$locations) {
|
|||||||
|
|
||||||
$already_exist = mp_coord_already_exist($coordinates, $locations);
|
$already_exist = mp_coord_already_exist($coordinates, $locations);
|
||||||
if ($already_exist) {
|
if ($already_exist) {
|
||||||
|
// add index to the event
|
||||||
|
$index = $already_exist->index;
|
||||||
|
$event->index = $index;
|
||||||
// add event to events[]
|
// add event to events[]
|
||||||
array_push($already_exist->events, $event);
|
array_push($already_exist->events, $event);
|
||||||
}
|
}
|
||||||
@@ -22,6 +25,10 @@ function mp_sort_n_insert(&$event, &$locations) {
|
|||||||
$location = (object)[];
|
$location = (object)[];
|
||||||
$location->events = [];
|
$location->events = [];
|
||||||
|
|
||||||
|
// add index to the location and event
|
||||||
|
$index = count($locations);
|
||||||
|
$location->index = $index;
|
||||||
|
$event->index = $index;
|
||||||
// add coordinates to the location
|
// add coordinates to the location
|
||||||
$location->coordinates = $coordinates;
|
$location->coordinates = $coordinates;
|
||||||
// add first event to events[]
|
// add first event to events[]
|
||||||
@@ -31,7 +38,7 @@ function mp_sort_n_insert(&$event, &$locations) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mp_sort_events($events) {
|
function mp_sort_events(&$events) {
|
||||||
$locations = [];
|
$locations = [];
|
||||||
|
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
@@ -41,4 +48,17 @@ function mp_sort_events($events) {
|
|||||||
return $locations;
|
return $locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
locations = [
|
||||||
|
{
|
||||||
|
index : x
|
||||||
|
coordinates: {}
|
||||||
|
events : [{}, ...]
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
30
srcs/plugins/map_prof/scripts/mp_create_map.js
Normal file
30
srcs/plugins/map_prof/scripts/mp_create_map.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
function create_map(map_div) {
|
||||||
|
// default map center to france
|
||||||
|
let map_center = coordinates_default;
|
||||||
|
let world_bound = {
|
||||||
|
north: 80,
|
||||||
|
south: -80,
|
||||||
|
west: -180,
|
||||||
|
east: 180,
|
||||||
|
};
|
||||||
|
let map_options = {
|
||||||
|
/* map options : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions */
|
||||||
|
disableDefaultUI: true,
|
||||||
|
zoomControl: true,
|
||||||
|
scaleControl: true,
|
||||||
|
zoom: 2,
|
||||||
|
gestureHandling: "cooperative",
|
||||||
|
//gestureHandling: "greedy",
|
||||||
|
//gestureHandling: "none",
|
||||||
|
//gestureHandling: "auto",
|
||||||
|
//disableDoubleClickZoom: "false", //deprecated
|
||||||
|
//draggable: "true", //deprecated
|
||||||
|
center: map_center,
|
||||||
|
restriction: {
|
||||||
|
latLngBounds: world_bound,
|
||||||
|
strictBounds: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return new google.maps.Map(map_div, map_options);
|
||||||
|
}
|
||||||
@@ -23,7 +23,6 @@ function mp_init_map() {
|
|||||||
* { - mode : ... }
|
* { - mode : ... }
|
||||||
* { }
|
* { }
|
||||||
*
|
*
|
||||||
* - let filters
|
|
||||||
* - let coordinates_default = {lat: ,lng: }
|
* - let coordinates_default = {lat: ,lng: }
|
||||||
* - let icon_color = ""
|
* - let icon_color = ""
|
||||||
* - let icon_color_back = ""
|
* - let icon_color_back = ""
|
||||||
@@ -36,45 +35,19 @@ function mp_init_map() {
|
|||||||
console.log("filters:");
|
console.log("filters:");
|
||||||
console.log(filters);
|
console.log(filters);
|
||||||
|
|
||||||
// default map center to france
|
|
||||||
let map_center = coordinates_default;
|
|
||||||
let world_bound = {
|
|
||||||
north: 80,
|
|
||||||
south: -80,
|
|
||||||
west: -180,
|
|
||||||
east: 180,
|
|
||||||
};
|
|
||||||
let map_options = {
|
|
||||||
/* map options : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions */
|
|
||||||
disableDefaultUI: true,
|
|
||||||
zoomControl: true,
|
|
||||||
scaleControl: true,
|
|
||||||
zoom: 2,
|
|
||||||
gestureHandling: "cooperative",
|
|
||||||
//gestureHandling: "greedy",
|
|
||||||
//gestureHandling: "none",
|
|
||||||
//gestureHandling: "auto",
|
|
||||||
//disableDoubleClickZoom: "false", //deprecated
|
|
||||||
//draggable: "true", //deprecated
|
|
||||||
center: map_center,
|
|
||||||
restriction: {
|
|
||||||
latLngBounds: world_bound,
|
|
||||||
strictBounds: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
let map_div = document.getElementById("ljdp_map");
|
let map_div = document.getElementById("ljdp_map");
|
||||||
|
//let filters_div = document.getElementById("ljdp_map_filters");
|
||||||
let infowindow = new google.maps.InfoWindow();
|
let infowindow = new google.maps.InfoWindow();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DRAW MAP
|
* DRAW MAP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let map = new google.maps.Map(map_div, map_options);
|
let map = create_map(map_div);
|
||||||
let markers = create_markers(map, locations, infowindow);
|
let markers = create_markers(map, locations, infowindow);
|
||||||
let marker_cluster = 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
|
// add listener to close infowindow at any click on map
|
||||||
let toggle = true;
|
let toggle = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user