added settings for map on post
This commit is contained in:
@@ -32,9 +32,38 @@ require_once(dirname(__FILE__) . '/mp_address_errors.php');
|
|||||||
require_once(dirname(__FILE__) . '/mp_create_div.php');
|
require_once(dirname(__FILE__) . '/mp_create_div.php');
|
||||||
|
|
||||||
|
|
||||||
|
// // temp test
|
||||||
|
//
|
||||||
|
// add_action( 'wp', 'my_front_end_function');
|
||||||
|
// function my_front_end_function() {
|
||||||
|
// if ( is_admin() )
|
||||||
|
// return;
|
||||||
|
// if ( get_post_type() != "post" )
|
||||||
|
// return;
|
||||||
|
// if ( get_post_status() != "publish" )
|
||||||
|
// return;
|
||||||
|
//
|
||||||
|
// $location = get_field(location);
|
||||||
|
// mp_console_log("location:");
|
||||||
|
// mp_console_log($location);
|
||||||
|
//
|
||||||
|
// $coordinates = $location->coordinates;
|
||||||
|
// mp_console_log("coordinates:");
|
||||||
|
// mp_console_log($coordinates);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function is_event_post() {
|
||||||
|
if ( is_admin() )
|
||||||
|
return false;
|
||||||
|
if ( get_post_type() != "post" )
|
||||||
|
return 0;
|
||||||
|
if ( get_post_status() != "publish" )
|
||||||
|
return 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,6 +118,18 @@ function mp_ljdp_map() {
|
|||||||
"locations" => $locations,
|
"locations" => $locations,
|
||||||
"filters" => $filters,
|
"filters" => $filters,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// if post event instead of map page, change ccoordinate and zoom
|
||||||
|
global $mp_zoom;
|
||||||
|
if (is_event_post()) {
|
||||||
|
$mp_zoom = $mp_zoom_set[1];
|
||||||
|
|
||||||
|
$location = get_field(location);
|
||||||
|
$coordinates = $location->coordinates;
|
||||||
|
|
||||||
|
$mp_coordinates_default = $coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
mp_add_to_scripts($to_add);
|
mp_add_to_scripts($to_add);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ function mp_add_to_scripts($to_add) {
|
|||||||
global $mp_icon_color;
|
global $mp_icon_color;
|
||||||
global $mp_icon_color_back;
|
global $mp_icon_color_back;
|
||||||
global $mp_icon_size_factor;
|
global $mp_icon_size_factor;
|
||||||
|
global $mp_zoom;
|
||||||
global $mp_coordinates_default;
|
global $mp_coordinates_default;
|
||||||
global $mp_icon_stroke_width;
|
global $mp_icon_stroke_width;
|
||||||
global $mp_max_zoom;
|
global $mp_max_zoom;
|
||||||
@@ -20,6 +21,7 @@ function mp_add_to_scripts($to_add) {
|
|||||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color, 'icon_color'), 'before');
|
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color, 'icon_color'), 'before');
|
||||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color_back, 'icon_color_back'), 'before');
|
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_color_back, 'icon_color_back'), 'before');
|
||||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_size_factor, 'icon_size_factor'), 'before');
|
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_size_factor, 'icon_size_factor'), 'before');
|
||||||
|
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_zoom, 'map_zoom'), 'before');
|
||||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_coordinates_default, 'coordinates_default'), 'before');
|
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_coordinates_default, 'coordinates_default'), 'before');
|
||||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_stroke_width, 'icon_stroke_width'), 'before');
|
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_icon_stroke_width, 'icon_stroke_width'), 'before');
|
||||||
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_max_zoom, 'max_zoom'), 'before');
|
wp_add_inline_script('mp_init_map', mp_php_to_js($mp_max_zoom, 'max_zoom'), 'before');
|
||||||
|
|||||||
@@ -66,4 +66,5 @@ function mp_get_coordinates($id) {
|
|||||||
return $location;
|
return $location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ function create_map(map_div) {
|
|||||||
disableDefaultUI: true,
|
disableDefaultUI: true,
|
||||||
zoomControl: true,
|
zoomControl: true,
|
||||||
scaleControl: true,
|
scaleControl: true,
|
||||||
zoom: 2,
|
zoom: map_zoom,
|
||||||
gestureHandling: "cooperative",
|
gestureHandling: "cooperative",
|
||||||
//gestureHandling: "greedy",
|
//gestureHandling: "greedy",
|
||||||
//gestureHandling: "none",
|
//gestureHandling: "none",
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ function mp_init_map() {
|
|||||||
* - let icon_color_back = ""
|
* - let icon_color_back = ""
|
||||||
* - let icon_size = [x, y]
|
* - let icon_size = [x, y]
|
||||||
* - let cluster_size_factor = Number
|
* - let cluster_size_factor = Number
|
||||||
|
* - let map_zoom = x
|
||||||
* - let max_zoom = x
|
* - let max_zoom = x
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,15 @@ if (isset($mp_settings_icon_size_factor))
|
|||||||
$mp_icon_size_factor = $mp_settings_icon_size_factor;
|
$mp_icon_size_factor = $mp_settings_icon_size_factor;
|
||||||
|
|
||||||
|
|
||||||
|
/* DEFAULT ZOOM
|
||||||
|
*/
|
||||||
|
$mp_zoom_set = [2, 5];
|
||||||
|
if (isset($mp_settings_zoom_set))
|
||||||
|
$mp_zoom_set = $mp_settings_zoom_set;
|
||||||
|
// also create the variable, and set to map page by default
|
||||||
|
$mp_zoom = $mp_zoom_set[0];
|
||||||
|
|
||||||
|
|
||||||
/* DEFAULT COORDINATES
|
/* DEFAULT COORDINATES
|
||||||
*/
|
*/
|
||||||
$mp_coordinates_default = (object)["lat" => 46.227638, "lng" => 2.213749]; // france
|
$mp_coordinates_default = (object)["lat" => 46.227638, "lng" => 2.213749]; // france
|
||||||
|
|||||||
@@ -9,15 +9,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ************************************
|
|
||||||
dimensions de l'icone des marqueurs
|
|
||||||
_
|
|
||||||
valeur par defaut [40, 40]
|
|
||||||
************************************ */
|
|
||||||
//$mp_settings_icon_size = [50, 50];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ************************************
|
/* ************************************
|
||||||
facteur de taille des clusters
|
facteur de taille des clusters
|
||||||
_
|
_
|
||||||
@@ -27,6 +18,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ************************************
|
||||||
|
zoom initial
|
||||||
|
- pour les pages
|
||||||
|
- pour les posts
|
||||||
|
_
|
||||||
|
valeur par defaut [2, 5]
|
||||||
|
************************************ */
|
||||||
|
//$mp_settings_zoom_set = [1, 6];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ************************************
|
/* ************************************
|
||||||
coordonnees par defaut
|
coordonnees par defaut
|
||||||
(pour centrer la carte globale,
|
(pour centrer la carte globale,
|
||||||
|
|||||||
Reference in New Issue
Block a user