protection if location list is empty
+ create script and style dir
This commit is contained in:
61
srcs/plugins/map_prof/scripts/mp_init_map.js
Normal file
61
srcs/plugins/map_prof/scripts/mp_init_map.js
Normal file
@@ -0,0 +1,61 @@
|
||||
function mp_init_map() {
|
||||
|
||||
/*
|
||||
* following variable are created by mp_locations.php
|
||||
* - let locations = [{lat:xxx, lng:xxx}, {}...]
|
||||
* - let icon_url
|
||||
* - let icon_size[x, y]
|
||||
*/
|
||||
|
||||
// default map center to france
|
||||
let map_center = {lat:46.227638, lng:2.213749};
|
||||
if (locations.length > 0)
|
||||
map_center = locations[0];
|
||||
|
||||
let map = new google.maps.Map(
|
||||
document.getElementById("ljdp_map"),
|
||||
{
|
||||
// mpa options : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions
|
||||
|
||||
// maps controls :
|
||||
disableDefaultUI: true,
|
||||
zoomControl: true,
|
||||
scaleControl: true,
|
||||
|
||||
// other controls :
|
||||
zoom: 5,
|
||||
//gestureHandling: "cooperative",
|
||||
//gestureHandling: "greedy",
|
||||
gestureHandling: "none",
|
||||
//gestureHandling: "auto",
|
||||
//disableDoubleClickZoom: "false",
|
||||
//draggable: "true",
|
||||
center: map_center,
|
||||
}
|
||||
);
|
||||
//map.addListener("zoom_changed", () => {
|
||||
// // do nothing ?
|
||||
//});
|
||||
let marker, icon, label;
|
||||
icon = {
|
||||
url: icon_url,
|
||||
scaledSize: new google.maps.Size(icon_size[0], icon_size[1]),
|
||||
};
|
||||
label = {
|
||||
// text: String(count),
|
||||
text: "hello",
|
||||
color: icon_label_color,
|
||||
fontSize: "12px",
|
||||
};
|
||||
let markers = [];
|
||||
for (loc of locations) {
|
||||
marker = new google.maps.Marker({
|
||||
position: loc,
|
||||
map: map,
|
||||
icon: icon,
|
||||
// label: label,
|
||||
});
|
||||
markers.push(marker);
|
||||
};
|
||||
new markerClusterer.MarkerClusterer({ map, markers });
|
||||
}
|
||||
Reference in New Issue
Block a user