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

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 map_zoom = x
	 * - let max_zoom = x
	 */


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

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

	// add listener to close infowindow
	//   https://developers.google.com/maps/documentation/javascript/events
	g_map.addListener('click', function() {
		g_infowindow.close();
	});
	g_map.addListener('drag', function() {
		g_infowindow.close();
	});
	g_map.addListener('zoom_changed', function() {
		g_infowindow.close();
	});

	//g_map.addListener('clusteringbegin', restrict_map(false));

}
