cluster markers works
+ they are personalizable + cluster icon grow without getting fat + js function for errors + scripts dont enqueue on all pages + php array of event function more light without coordinates - coordinates not yet retrieved by js
This commit is contained in:
@@ -26,37 +26,24 @@ require_once(dirname(__FILE__) . '/settings/mp_optionnals.php');
|
||||
* global variables :
|
||||
*/
|
||||
|
||||
$mp_icon_url = '/wp-content/plugins/map_prof/images/' . $mp_icon_file;
|
||||
$mp_icon_size = [50, 50];
|
||||
if (isset($mp_icon_size_setting)) {
|
||||
if (is_array($mp_icon_size_setting)) {
|
||||
if (count($mp_icon_size_setting) === 2) {
|
||||
if ( is_numeric($mp_icon_size_setting[0]) && is_numeric($mp_icon_size_setting[1]) ) {
|
||||
$mp_icon_size = $mp_icon_size_setting;
|
||||
$mp_icon_base_url = '/wp-content/plugins/map_prof/images/';
|
||||
$mp_icon_url = $mp_icon_base_url . $mp_icon_file;
|
||||
$mp_icon_cluster_url = $mp_icon_base_url . $mp_icon_cluster_file;
|
||||
|
||||
$mp_icon_size = [40, 40];
|
||||
if (isset($mp_settings_icon_size)) {
|
||||
if (is_array($mp_settings_icon_size)) {
|
||||
if (count($mp_settings_icon_size) === 2) {
|
||||
if ( is_numeric($mp_settings_icon_size[0]) && is_numeric($mp_settings_icon_size[1]) ) {
|
||||
$mp_icon_size = $mp_settings_icon_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//$mp_icon_label_color = "red";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* add scripts and styles to the header or the footer
|
||||
*/
|
||||
|
||||
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('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();
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'mp_enqueue_scripts' );
|
||||
$mp_icon_color = "#ba197a";
|
||||
if (isset($mp_settings_icon_color))
|
||||
$mp_icon_color = $mp_settings_icon_color;
|
||||
|
||||
|
||||
|
||||
@@ -74,11 +61,25 @@ add_filter('script_loader_tag', 'mp_tag_scripts', 10, 2);
|
||||
|
||||
|
||||
/**
|
||||
* when 'shortcode' found in page, replace by return
|
||||
* when 'shortcode' found in page, enqueue scripts and styles,
|
||||
* run php script, and replace shortcode by return value
|
||||
*/
|
||||
|
||||
function mp_add_div() {
|
||||
$mp_api_script = '<div id="ljdp_map">map here</div>';
|
||||
|
||||
// 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('styles/mp_style.css', __FILE__), '', '', '');
|
||||
wp_enqueue_script('mp_errors_maps', plugins_url('scripts/mp_errors_map.js', __FILE__), '', '', true);
|
||||
wp_enqueue_script('mp_marker_clusterer', $marker_clusterer, ['mp_errors_maps'], '', 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();
|
||||
|
||||
$mp_api_script = '<div id="ljdp_map"></div>';
|
||||
|
||||
return $mp_api_script;
|
||||
}
|
||||
add_shortcode('lejourduprof_map', 'mp_add_div');
|
||||
|
||||
Reference in New Issue
Block a user