protection if location list is empty
+ create script and style dir
This commit is contained in:
@@ -39,10 +39,10 @@ function mp_enqueue_scripts() {
|
|||||||
// https://developers.google.com/maps/documentation/javascript/marker-clustering
|
// https://developers.google.com/maps/documentation/javascript/marker-clustering
|
||||||
$marker_clusterer = "https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js";
|
$marker_clusterer = "https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js";
|
||||||
|
|
||||||
wp_enqueue_style( 'mp_style', plugins_url('mp_style.css', __FILE__), '', '', '');
|
wp_enqueue_style( 'mp_style', plugins_url('styles/mp_style.css', __FILE__), '', '', '');
|
||||||
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true);
|
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, '', '', true);
|
||||||
wp_enqueue_script('mp_init_map', plugins_url('mp_init_map.js', __FILE__), ['mp_marker_clusterer'],'', true);
|
wp_enqueue_script('mp_init_map', plugins_url('scripts/mp_init_map.js', __FILE__), ['mp_marker_clusterer'],'', true);
|
||||||
wp_enqueue_script('mp_google_api', mp_url_api(), ['mp_init_map'], '', true);
|
wp_enqueue_script('mp_google_api', mp_url_api(), ['mp_init_map'], '', true);
|
||||||
|
|
||||||
mp_add_to_scripts();
|
mp_add_to_scripts();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,12 @@ function mp_retrieve_address(&$posts_list) {
|
|||||||
foreach ($posts_list as $post_value) {
|
foreach ($posts_list as $post_value) {
|
||||||
$content = $post_value->post_content;
|
$content = $post_value->post_content;
|
||||||
$address = mp_extract_address($content);
|
$address = mp_extract_address($content);
|
||||||
$lat_lng = mp_convert_coordinates($address);
|
if (strlen($address) > 0)
|
||||||
array_push($locs, $lat_lng);
|
{
|
||||||
|
$lat_lng = mp_convert_coordinates($address);
|
||||||
|
if ($lat_lng !== null)
|
||||||
|
array_push($locs, $lat_lng);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return $locs;
|
return $locs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#ljdp_map {
|
|
||||||
height: 500px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
#temoin {
|
|
||||||
color: blue;
|
|
||||||
}
|
|
||||||
@@ -11,14 +11,31 @@ function mp_init_map() {
|
|||||||
let map_center = {lat:46.227638, lng:2.213749};
|
let map_center = {lat:46.227638, lng:2.213749};
|
||||||
if (locations.length > 0)
|
if (locations.length > 0)
|
||||||
map_center = locations[0];
|
map_center = locations[0];
|
||||||
|
|
||||||
let map = new google.maps.Map(
|
let map = new google.maps.Map(
|
||||||
document.getElementById("ljdp_map"),
|
document.getElementById("ljdp_map"),
|
||||||
{
|
{
|
||||||
zoom: 5,
|
// mpa options : https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions
|
||||||
|
|
||||||
|
// maps controls :
|
||||||
disableDefaultUI: true,
|
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,
|
center: map_center,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
//map.addListener("zoom_changed", () => {
|
||||||
|
// // do nothing ?
|
||||||
|
//});
|
||||||
let marker, icon, label;
|
let marker, icon, label;
|
||||||
icon = {
|
icon = {
|
||||||
url: icon_url,
|
url: icon_url,
|
||||||
27
srcs/plugins/map_prof/styles/mp_style.css
Normal file
27
srcs/plugins/map_prof/styles/mp_style.css
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#ljdp_map {
|
||||||
|
height: 500px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
#temoin {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* styling zoom buttons on map
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* hide the rectangular box container */
|
||||||
|
div.gmnoprint div {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
/* shape buttons in circles */
|
||||||
|
button.gm-control-active {
|
||||||
|
visibility: visible;
|
||||||
|
border-radius: 50% !important;
|
||||||
|
background-color: rgb(255, 255, 255) !important;
|
||||||
|
}
|
||||||
|
/* gap between the buttons */
|
||||||
|
button.gm-control-active ~ div {
|
||||||
|
height: 10px !important;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user