PluginProbe
WP Directory Kit / 1.2.6
WP Directory Kit v1.2.6
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / elementor-elements / views / wdk-map.php

wdk-map.php in WP Directory Kit 1.2.6, at elementor-elements/views/wdk-map.php

163 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template for Element Listings Results Map.
4 * This is the template that elementor element map with markers of listings, show results
5 *
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 ?>
13 <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>">
14 <div class="wdk-map" class="wdk_map_results">
15 <div id="wdk_map_results_<?php echo esc_html($id_element);?>" style="height:<?php echo esc_attr($settings['conf_custom_map_height']['size']);?>px" class="wdk_map_results <?php echo wmvc_show_data('styles_thmbn_des_type',$settings, '');?> " ></div>
16 </div>
17 </div>
18 <?php
19 $zoom_index = $settings['conf_custom_map_zoom_index']['size'];
20 ?>
21 <?php
22 if($lat == 0)
23 {
24 $lat = wmvc_show_data('conf_custom_map_center_gps_lat', $settings);
25 $lng = wmvc_show_data('conf_custom_map_center_gps_lng', $settings);
26 }
27 ?>
28 <?php
29 $WMVC = &wdk_get_instance();
30 $WMVC->model('category_m');
31 if (!$is_edit_mode)
32 ob_start();
33 ?>
34 <script>
35 var wdk_map ='';
36 var wdk_markers = [];
37 var wdk_clusters ='';
38 var wdk_jpopup_customOptions =
39 {
40 'maxWidth': 'initial',
41 'width': 'initial',
42 'className' : 'popupCustom'
43 };
44 jQuery(document).ready(function($) {
45 if(wdk_clusters=='')
46 wdk_clusters = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true});
47 wdk_map = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', {
48 center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
49 zoom: "<?php echo esc_js($zoom_index);?>",
50 scrollWheelZoom: false,
51 <?php if($settings['conf_custom_dragging'] == 'yes'):?>
52 dragging: true,
53 <?php else:?>
54 dragging: false,
55 <?php endif;?>
56 tap: !L.Browser.mobile,
57 fullscreenControl: true,
58 fullscreenControlOptions: {
59 position: 'topleft'
60 }
61 });
62
63
64 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
65 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
66 }).addTo(wdk_map);
67
68 <?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?>
69 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map);
70 <?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?>
71 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map);
72 <?php endif;?>
73 var auto_marker_size = false;
74 <?php foreach($results as $key=>$listing): ?>
75 <?php if(!is_numeric(wmvc_show_data('lng', $listing)))continue;?>
76 <?php
77 $pin_icon = "";
78 $font_class = "";
79 $font_icon = $this->generate_icon($settings['conf_custom_map_pin_icon']);
80 $pin_icon = $settings['conf_custom_map_pin']['url'];
81
82 if(!empty(wmvc_show_data('category_id', $listing))){
83 $category = $WMVC->category_m->get_data(wmvc_show_data('category_id', $listing));
84 if(wmvc_show_data('marker_image_id', $category, false, TRUE, TRUE)){
85 $pin_icon = wdk_image_src($category, 'full', NULL,'marker_image_id');
86 } else if(!empty(wmvc_show_data('font_icon_code', $category))) {
87 $font_class = wmvc_show_data('font_icon_code', $category);
88 }
89 } else {
90 $font_class = "";
91 }
92
93 ?>
94 <?php if(!empty($settings['custom_marker_fields']) && substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2) == 'first_image'):?>
95 auto_marker_size = true;
96 var innerMarker = '<div class="wdk_marker-container wdk_marker_label wdk_marker_clear category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><img src="<?php echo esc_js(wdk_image_src($listing));?>"></img></div>';
97
98 <?php elseif(!empty($settings['custom_marker_fields']) && wdk_field_value (substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2), $listing)):?>
99 <?php
100 $field_id = substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2);
101
102 $field_value = '';
103 $field_value .= apply_filters( 'wpdirectorykit/listing/field/prefix', wdk_field_option ($field_id, 'prefix'), $field_id);
104
105 /* if price field use like 1l */
106 if(wdk_field_option($field_id, 'is_price_format')) {
107
108 $value = wdk_field_value($field_id, $listing);
109 if($value>=1000) {
110 $value = apply_filters( 'wpdirectorykit/listing/field/value', number_format_i18n(wdk_filter_decimal($value/1000)), $field_id).'k';
111 } else {
112 $value = apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
113 }
114
115 $field_value = $value;
116
117 } else {
118 $field_value .= apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
119 }
120
121 $field_value .= apply_filters( 'wpdirectorykit/listing/field/suffix',wdk_field_option ($field_id, 'suffix'), $field_id);
122 ?>
123 auto_marker_size = true;
124 var innerMarker = '<div class="wdk_marker-container wdk_marker_label category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><?php echo esc_js(strip_tags($field_value));?></div>';
125 <?php elseif($pin_icon):?>
126 var image = '<?php echo esc_html($pin_icon);?>'; var innerMarker = '<div class="wdk_marker-container wdk_marker-container-image"><img src='+image+'></img></div>';
127 <?php elseif($font_icon && empty($font_class)):?>
128 var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><div class="front wdk_face"><?php echo wdk_viewe($font_icon);?></div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
129 <?php else:?>
130 var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wmvc_show_data('category_id', $listing));?>"><div class="front wdk_face"><i class="<?php echo esc_html($font_class);?>"></i></div><div class="wdk_marker-card"><div class="wdk_marker-arrow"></div></div></div>';
131 <?php endif;?>
132 wdk_markers.push(wdk_generate_marker_ajax_popup('<?php echo esc_url(admin_url('admin-ajax.php'));?>','<?php echo esc_html(wmvc_show_data('post_id', $listing));?>','<?php echo esc_html(wmvc_show_data('lat', $listing));?>','<?php echo esc_html(wmvc_show_data('lng', $listing));?>',innerMarker, wdk_jpopup_customOptions, auto_marker_size
133 , <?php if(wmvc_show_data('disable_cluster', $settings) == 'yes'):?> false <?php endif;?>));
134 <?php endforeach; ?>
135 wdk_map.addLayer(wdk_clusters);
136 /* set center */
137 if(wdk_markers.length){
138 var limits_center = [];
139 for (var i in wdk_markers) {
140 var latLngs = [ wdk_markers[i].getLatLng() ];
141 limits_center.push(latLngs)
142 };
143 var bounds = L.latLngBounds(limits_center);
144 <?php if(wdk_get_option('wdk_fixed_map_results_position') && wdk_get_option('wdk_default_lat') && wdk_get_option('wdk_default_lng')): ?>
145 wdk_map.setView(["<?php echo esc_js(wdk_get_option('wdk_default_lat'));?>","<?php echo esc_js(wdk_get_option('wdk_default_lng'));?>"]);
146 <?php elseif($settings['enable_custom_gps_center'] == 'yes'): ?>
147 wdk_map.setView(["<?php echo esc_js($settings['conf_custom_map_center_gps_lat']);?>","<?php echo esc_js($settings['conf_custom_map_center_gps_lng']);?>"]);
148 <?php else: ?>
149 wdk_map.fitBounds(bounds);
150 <?php endif; ?>
151 }
152 })
153 </script>
154 <?php
155
156 if (!$is_edit_mode) {
157 $js_content = ob_get_clean();
158 $js_content = str_replace(array('</script>','<script>'),'',$js_content );
159 wp_add_inline_script( 'wdk-elementor-main', $js_content );
160 }
161 ?>
162
163