Skip to content

Commit

Permalink
Update: add new option to switch map clustering (#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
MahfuzulAlam authored May 29, 2024
1 parent b3a18d6 commit 0638535
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 14 additions & 1 deletion includes/classes/class-settings-panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,19 @@ public function register_setting_fields( $fields = [] ) {
'description' => $description,
];

// Marker Clustering
$fields['marker_clustering'] = [
'type' => 'toggle',
'label' => __('Marker Clustering', 'directorist'),
'value' => true,
'show-if' => [
'where' => "select_listing_map",
'conditions' => [
['key' => 'value', 'compare' => '=', 'value' => 'google'],
],
],
];


// Map Country Restriction Field
$fields['country_restriction'] = [
Expand Down Expand Up @@ -4622,7 +4635,7 @@ public function prepare_settings()
'title' => __('Map', 'directorist'),
'description' => '',
'fields' => [
'select_listing_map', 'map_api_key', 'country_restriction', 'restricted_countries', 'default_latitude', 'default_longitude', 'use_def_lat_long', 'map_zoom_level', 'map_view_zoom_level', 'listings_map_height'
'select_listing_map', 'map_api_key', 'marker_clustering', 'country_restriction', 'restricted_countries', 'default_latitude', 'default_longitude', 'use_def_lat_long', 'map_zoom_level', 'map_view_zoom_level', 'listings_map_height'
],
],
'map_info_window' => [
Expand Down
5 changes: 3 additions & 2 deletions includes/model/Listings.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ public function set_options() {
$this->options['display_publish_date'] = get_directorist_option('display_publish_date', 1) ? true : false;
$this->options['default_latitude'] = get_directorist_option('default_latitude', 40.7127753);
$this->options['default_longitude'] = get_directorist_option('default_longitude', -74.0059728);
$this->options['listing_instant_search'] = ! empty( get_directorist_option( 'listing_instant_search' ) ) ? 'yes' : '';
$this->options['listing_instant_search'] = ! empty( get_directorist_option( 'listing_instant_search' ) ) ? 'yes' : '';
$this->options['marker_clustering'] = get_directorist_option( 'marker_clustering', true ) ? 'markerclusterer' : '';
}

// update_search_options
Expand Down Expand Up @@ -1436,7 +1437,7 @@ public function load_google_map() {
Helper::add_hidden_data_to_dom( 'atbdp_map', $data );
$map_height = !empty( $this->listings_map_height ) ? $this->listings_map_height: '';
?>
<div class="atbdp-body atbdp-map embed-responsive embed-responsive-16by9 atbdp-margin-bottom" data-type="markerclusterer" style="height: <?php echo esc_attr( $map_height );?>px;">
<div class="atbdp-body atbdp-map embed-responsive embed-responsive-16by9 atbdp-margin-bottom" data-type="<?php echo $this->options['marker_clustering']; ?>" style="height: <?php echo esc_attr( $map_height );?>px;">
<?php

$listings = $this->query_results;
Expand Down

0 comments on commit 0638535

Please sign in to comment.