diff --git a/srcs/plugins/map_prof/map_prof_hooks.php b/srcs/plugins/map_prof/map_prof_hooks.php index 3723bf9..882efef 100644 --- a/srcs/plugins/map_prof/map_prof_hooks.php +++ b/srcs/plugins/map_prof/map_prof_hooks.php @@ -39,10 +39,10 @@ function mp_enqueue_scripts() { // https://developers.google.com/maps/documentation/javascript/marker-clustering $marker_clusterer = "https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"; - wp_enqueue_style( 'mp_style', plugins_url('mp_style.css', __FILE__), '', '', ''); - 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_google_api', mp_url_api(), ['mp_init_map'], '', true); + 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_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); mp_add_to_scripts(); } diff --git a/srcs/plugins/map_prof/mp_coordinates_from_posts.php b/srcs/plugins/map_prof/mp_coordinates_from_posts.php index b18364c..ef2c367 100644 --- a/srcs/plugins/map_prof/mp_coordinates_from_posts.php +++ b/srcs/plugins/map_prof/mp_coordinates_from_posts.php @@ -34,8 +34,12 @@ function mp_retrieve_address(&$posts_list) { foreach ($posts_list as $post_value) { $content = $post_value->post_content; $address = mp_extract_address($content); - $lat_lng = mp_convert_coordinates($address); - array_push($locs, $lat_lng); + if (strlen($address) > 0) + { + $lat_lng = mp_convert_coordinates($address); + if ($lat_lng !== null) + array_push($locs, $lat_lng); + } }; return $locs; } diff --git a/srcs/plugins/map_prof/mp_style.css b/srcs/plugins/map_prof/mp_style.css deleted file mode 100644 index 9003bdb..0000000 --- a/srcs/plugins/map_prof/mp_style.css +++ /dev/null @@ -1,7 +0,0 @@ -#ljdp_map { - height: 500px; - width: 100%; -} -#temoin { - color: blue; -} diff --git a/srcs/plugins/map_prof/mp_init_map.js b/srcs/plugins/map_prof/scripts/mp_init_map.js similarity index 67% rename from srcs/plugins/map_prof/mp_init_map.js rename to srcs/plugins/map_prof/scripts/mp_init_map.js index 0d4c54a..d026a50 100644 --- a/srcs/plugins/map_prof/mp_init_map.js +++ b/srcs/plugins/map_prof/scripts/mp_init_map.js @@ -11,14 +11,31 @@ function mp_init_map() { 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"), { - zoom: 5, + // 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, diff --git a/srcs/plugins/map_prof/styles/mp_style.css b/srcs/plugins/map_prof/styles/mp_style.css new file mode 100644 index 0000000..c3e35e2 --- /dev/null +++ b/srcs/plugins/map_prof/styles/mp_style.css @@ -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; +}