
let g_map = {};
let g_markers = [];
let g_marker_cluster = {};
const g_init_bounds = {
	north: 80,
	south: -80,
	west: -180,
	east: 180,
};
let g_indexes = [];

function mp_init_map() {

	/*
	 * following variable are created by mp_add_to_script.php
	 * - let locations =	[
	 *							{
	 *								coordinates: {}
	 *								events     : [{}, ...]
	 *							},
	 *							...
	 *						]
	 *
	 *            {                                            }
	 *            {               [                          ] }
	 * - filters: { - pays      : [ { - _name     : "" }     ] }
	 *            {               [ { - villes    : [] }     ] }
	 *            {               [ { - categories: [] }     ] }
	 *            {               [ { - indexes   : [] }     ] }
	 *            {               [ { - mode      : [] }, ...] }
	 *            {               [                          ] }
	 *            {                                            }
	 *            { - villes    : ...                          }
	 *            { - categories: ...                          }
	 *            { - mode      : ...                          }
	 *            {                                            }
	 *
	 * - let coordinates_default = {lat: ,lng: }
	 * - let icon_color = ""
	 * - let icon_color_back = ""
	 * - let icon_size = [x, y]
	 * - let cluster_size_factor = Number
	 * - let max_zoom = x
	 */

	let map_div = document.getElementById("ljdp_map");
	//let filters_div = document.getElementById("ljdp_map_filters");
	let infowindow = new google.maps.InfoWindow();


	/*
	 * DRAW MAP
	 */

	g_map = create_map(map_div);
	g_markers = create_markers(g_map, locations, infowindow);
	g_marker_cluster = draw_clusters(g_map, g_markers);

	//console.log("locations:");
	//console.log(locations);
	//console.log("filters:");
	//console.log(filters);
	//console.log("markers:");
	//console.log(g_markers);


	// add listener to close infowindow at any click on map
	g_map.addListener('click', function() {
		infowindow.close();
	});

}
