diff --git a/srcs/plugins/map_prof/map_prof.php b/srcs/plugins/map_prof/map_prof.php index df6cbac..a717260 100644 --- a/srcs/plugins/map_prof/map_prof.php +++ b/srcs/plugins/map_prof/map_prof.php @@ -13,14 +13,25 @@ require_once(dirname(__FILE__) . '/mp_url_api.php'); add_action( 'wp_enqueue_scripts', 'wpa_enqueue_scripts' ); function wpa_enqueue_scripts() { - wp_enqueue_style( 'mp_style', plugins_url('mp_style.css', __FILE__), '', '', false); + wp_enqueue_style( 'mp_style', plugins_url('mp_style.css', __FILE__), '', '', ''); wp_enqueue_script('mp_init_map', plugins_url('mp_init_map.js', __FILE__), '', '', true); wp_enqueue_script('mp_google_api', mp_url_api(), ['mp_init_map'], '', true); +// wp_register_script('mp_init_map', plugins_url('mp_init_map.js', __FILE__), '', '', true); +// wp_register_script('mp_google_api', mp_url_api(), ['mp_init_map'], '', true); } +//function wpa_defer_scripts($tag, $handle) { +// if ('mp_google_api' === $handle) +// return str_replace(' src="', ' async defer src="', $tag); +// if ('mp_googe_api' === $handle) +// return str_replace(' src="', ' defer src="', $tag); +// return $tag; +//} +//add_filter('script_loader_tag', 'wpa_defer_scripts', 10, 2); + add_shortcode('lejourduprof_map', 'mp_add_div'); function mp_add_div() { - $mp_api_script = '
map here
'; + $mp_api_script = '
map here
'; return $mp_api_script; } diff --git a/srcs/plugins/map_prof/marker.png b/srcs/plugins/map_prof/marker.png new file mode 100644 index 0000000..af0f122 Binary files /dev/null and b/srcs/plugins/map_prof/marker.png differ diff --git a/srcs/plugins/map_prof/mp_init_map.js b/srcs/plugins/map_prof/mp_init_map.js index 3240744..ebd4328 100644 --- a/srcs/plugins/map_prof/mp_init_map.js +++ b/srcs/plugins/map_prof/mp_init_map.js @@ -1,11 +1,28 @@ function mp_init_map() { - var location = {lat: 38.8833, lng: -77.0167}; - var map = new google.maps.Map(document.getElementById("map"), { - zoom: 12, - center: location - }); - var marker = new google.maps.Marker({ - position: location, - map: map - }); + var locations = [ + {lat: 38.8833, lng: -77.0167}, + {lat: 39.8833, lng: -76.0167}, + ]; + var map = new google.maps.Map( + document.getElementById("ljdp_map"), + { + zoom: 5, + disableDefaultUI: true, + center: locations[0], + } + ); + var marker, icon; +// icon = "/wp-content/plugins/map_prof/marker.png"; + icon = { + //url: document.location.href + "marker.png", + url: "/wp-content/plugins/map_prof/marker.png", + scaledSize: new google.maps.Size(35, 50) + }; + for (loc of locations) { + marker = new google.maps.Marker({ + position: loc, + map: map, + icon: icon, + }); + }; } diff --git a/srcs/plugins/map_prof/mp_style.css b/srcs/plugins/map_prof/mp_style.css index 86c7504..9003bdb 100644 --- a/srcs/plugins/map_prof/mp_style.css +++ b/srcs/plugins/map_prof/mp_style.css @@ -1,4 +1,4 @@ -#map { +#ljdp_map { height: 500px; width: 100%; } diff --git a/srcs/plugins/map_prof/mp_url_api.php b/srcs/plugins/map_prof/mp_url_api.php index a871bde..6f2b7c9 100644 --- a/srcs/plugins/map_prof/mp_url_api.php +++ b/srcs/plugins/map_prof/mp_url_api.php @@ -1,10 +1,10 @@ 'https://maps.googleapis.com/maps/api/js', - 'sensor' => 'false', - 'key' => 'AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE', - 'callback' => 'mp_init_map', + 'src' => 'https://maps.googleapis.com/maps/api/js', + 'sensor' => 'false', + 'key' => 'AIzaSyCvdGV2ssD4ov4a9CuIlQhoJyz5gWWiSvE', + 'callback' => 'mp_init_map', ); $mp_src = ""; foreach ($mp_url as $url_key => $url_value) { @@ -17,9 +17,6 @@ function mp_url_api() { $mp_src .= "&" . $url_key . "=" . $url_value; }; - //$mp_api_script = ''; - //return $mp_api_script; return $mp_src; } ?>