PluginProbe
WP Directory Kit / 1.2.7
WP Directory Kit v1.2.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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / views / wdk-map.php

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

174 lines 9.3 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 <?php if($settings['conf_custom_dragging_mobile'] == 'yes'):?> <div class="map-hint"><?php echo esc_html__( 'Require 2 finger for map movement', 'wpdirectorykit' );?></div><?php endif;?>
16 <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>
17 </div>
18 </div>
19 <?php
20 $zoom_index = $settings['conf_custom_map_zoom_index']['size'];
21 ?>
22 <?php
23 if($lat == 0)
24 {
25 $lat = wmvc_show_data('conf_custom_map_center_gps_lat', $settings);
26 $lng = wmvc_show_data('conf_custom_map_center_gps_lng', $settings);
27 }
28 ?>
29 <?php
30 $WMVC = &wdk_get_instance();
31 $WMVC->model('category_m');
32 if (!$is_edit_mode)
33 ob_start();
34 ?>
35 <script>
36 var wdk_map ='';
37 var wdk_markers = [];
38 var wdk_clusters ='';
39 var wdk_jpopup_customOptions =
40 {
41 'maxWidth': 'initial',
42 'width': 'initial',
43 'className' : 'popupCustom'
44 };
45 jQuery(document).ready(function($) {
46 if(wdk_clusters=='')
47 wdk_clusters = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true});
48 wdk_map = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', {
49 center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
50 zoom: "<?php echo esc_js($zoom_index);?>",
51 scrollWheelZoom: false,
52 dragging: ((!L.Browser.mobile) ? <?php if($settings['conf_custom_dragging'] == 'yes'):?> true <?php else:?> else <?php endif;?> : <?php if($settings['conf_custom_dragging_mobile'] == 'yes'):?> true <?php else:?> false <?php endif;?>),
53 tap: !L.Browser.mobile,
54 fullscreenControl: true,
55 fullscreenControlOptions: {
56 position: 'topleft'
57 }
58 });
59
60
61 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
62 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
63 }).addTo(wdk_map);
64
65 <?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?>
66 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map);
67 <?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?>
68 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map);
69 <?php endif;?>
70 var auto_marker_size = false;
71 <?php foreach($results as $key=>$listing): ?>
72 <?php if(!is_numeric(wmvc_show_data('lng', $listing)))continue;?>
73 <?php
74 $pin_icon = "";
75 $font_class = "";
76 $font_icon = $this->generate_icon($settings['conf_custom_map_pin_icon']);
77 $pin_icon = $settings['conf_custom_map_pin']['url'];
78
79 if(!empty(wmvc_show_data('category_id', $listing))){
80 $category = $WMVC->category_m->get_data(wmvc_show_data('category_id', $listing));
81 if(wmvc_show_data('marker_image_id', $category, false, TRUE, TRUE)){
82 $pin_icon = wdk_image_src($category, 'full', NULL,'marker_image_id');
83 } else if(!empty(wmvc_show_data('font_icon_code', $category))) {
84 $font_class = wmvc_show_data('font_icon_code', $category);
85 }
86 } else {
87 $font_class = "";
88 }
89
90 $listing_lat = $listing_lng = NULL;
91 $listing_lat = wmvc_show_data('lat', $listing);
92 $listing_lng = wmvc_show_data('lng', $listing);
93
94 if(wmvc_show_data('conf_hide_real_location', $settings) == 'yes') {
95 $gps = wdk_get_near_location($listing_lat, $listing_lng);
96 //$listing_lat = (wmvc_show_data('lat', $gps));
97 //$listing_lng = (wmvc_show_data('lng', $gps));
98
99 $listing_lat = wdk_move_gps($listing_lat);
100 $listing_lng = wdk_move_gps($listing_lng);
101 }
102
103 ?>
104 <?php if(!empty($settings['custom_marker_fields']) && substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2) == 'first_image'):?>
105 auto_marker_size = true;
106 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>';
107
108 <?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)):?>
109 <?php
110 $field_id = substr($this->data['settings']['custom_marker_fields'], strpos($this->data['settings']['custom_marker_fields'],'__')+2);
111
112 $field_value = '';
113 $field_value .= apply_filters( 'wpdirectorykit/listing/field/prefix', wdk_field_option ($field_id, 'prefix'), $field_id);
114
115 /* if price field use like 1l */
116 if(wdk_field_option($field_id, 'is_price_format')) {
117
118 $value = wdk_field_value($field_id, $listing);
119 if($value>=1000) {
120 $value = apply_filters( 'wpdirectorykit/listing/field/value', number_format_i18n(wdk_filter_decimal($value/1000)), $field_id).'k';
121 } else {
122 $value = apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
123 }
124
125 $field_value = $value;
126
127 } else {
128 $field_value .= apply_filters( 'wpdirectorykit/listing/field/value', wdk_field_value_on_type($field_id, $listing), $field_id);
129 }
130
131 $field_value .= apply_filters( 'wpdirectorykit/listing/field/suffix',wdk_field_option ($field_id, 'suffix'), $field_id);
132 ?>
133 auto_marker_size = true;
134 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>';
135 <?php elseif($pin_icon):?>
136 var image = '<?php echo esc_html($pin_icon);?>'; var innerMarker = '<div class="wdk_marker-container wdk_marker-container-image"><img src='+image+'></img></div>';
137 <?php elseif($font_icon && empty($font_class)):?>
138 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>';
139 <?php else:?>
140 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>';
141 <?php endif;?>
142
143 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($listing_lat);?>','<?php echo esc_html($listing_lng);?>',innerMarker, wdk_jpopup_customOptions, auto_marker_size
144 , <?php if(wmvc_show_data('disable_cluster', $settings) == 'yes'):?> false <?php endif;?>));
145 <?php endforeach; ?>
146 wdk_map.addLayer(wdk_clusters);
147 /* set center */
148 if(wdk_markers.length){
149 var limits_center = [];
150 for (var i in wdk_markers) {
151 var latLngs = [ wdk_markers[i].getLatLng() ];
152 limits_center.push(latLngs)
153 };
154 var bounds = L.latLngBounds(limits_center);
155 <?php if(wdk_get_option('wdk_fixed_map_results_position') && wdk_get_option('wdk_default_lat') && wdk_get_option('wdk_default_lng')): ?>
156 wdk_map.setView(["<?php echo esc_js(wdk_get_option('wdk_default_lat'));?>","<?php echo esc_js(wdk_get_option('wdk_default_lng'));?>"]);
157 <?php elseif($settings['enable_custom_gps_center'] == 'yes'): ?>
158 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']);?>"]);
159 <?php else: ?>
160 wdk_map.fitBounds(bounds);
161 <?php endif; ?>
162 }
163 })
164 </script>
165 <?php
166
167 if (!$is_edit_mode) {
168 $js_content = ob_get_clean();
169 $js_content = str_replace(array('</script>','<script>'),'',$js_content );
170 wp_add_inline_script( 'wdk-elementor-main', $js_content );
171 }
172 ?>
173
174