PluginProbe
WP Directory Kit / 1.2.8
WP Directory Kit v1.2.8
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-listing-map.php

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

161 lines 7.9 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 Listing Map.
4 * This is the template that elementor element map
5 *
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 ?>
13
14 <?php
15 if(empty($lng) || empty($lat)) {
16 ?>
17 <div class="">
18 <p class="wdk_alert wdk_alert-danger"><?php echo esc_html__('Missing address', 'wpdirectorykit');?></p>
19 </div>
20 <?php
21 return false;
22 }
23 ?>
24
25 <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element);?>">
26 <div class="wdk-map infobox-basic">
27 <div id="wdk_map_results_<?php echo esc_html($id_element);?>" style="height:<?php echo esc_attr($settings['conf_custom_map_height']['size']);?>px" ></div>
28
29 <?php if(wmvc_show_data('enable_router_suggest',$settings) =='yes'): ?>
30 <form class="route_suggestion" action="">
31 <input class="input_text" type="hidden" name="address" value="<?php echo esc_attr(wdk_field_value('address', $wdk_listing_id));?>" />
32 <input class="input_text" type="hidden" name="gps" value="<?php echo esc_attr($lat.','.$lng);?>" />
33 <div class="wdk-field-group">
34 <input class="input_text" type="text" placeholder="<?php echo esc_html__(wmvc_show_data('text_suggestion_route_placeholder', $settings), 'wpdirectorykit');?>" name="route_from" />
35 </div>
36 <div class="wdk-field-group">
37 <button type="submit" class="wdk-btn"><?php echo esc_html__(wmvc_show_data('text_suggestion_route', $settings), 'wpdirectorykit');?></button>
38 </div>
39 </form>
40 <?php endif;?>
41 </div>
42 </div>
43 <?php
44 $zoom_index = $settings['conf_custom_map_zoom_index']['size'];
45 ?>
46
47 <?php
48 $WMVC = &wdk_get_instance();
49 $WMVC->model('category_m');
50 if (!$is_edit_mode)
51 ob_start();
52 ?>
53 <script>
54 var wdk_map_<?php echo esc_html($id_element);?> ='';
55 var wdk_markers_<?php echo esc_html($id_element);?> = [];
56 var wdk_clusters_<?php echo esc_html($id_element);?> ='';
57 var wdk_jpopup_customOptions =
58 {
59 'maxWidth': 'initial',
60 'width': 'initial',
61 'className' : 'popupCustom'
62 };
63 jQuery(document).ready(function($) {
64 if(wdk_clusters_<?php echo esc_html($id_element);?>=='')
65 wdk_clusters_<?php echo esc_html($id_element);?> = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true});
66 wdk_map_<?php echo esc_html($id_element);?> = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', {
67 center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
68 zoom: "<?php echo esc_js($zoom_index);?>",
69 scrollWheelZoom: false,
70 <?php if($settings['conf_custom_dragging'] == 'yes'):?>
71 dragging: true,
72 <?php else:?>
73 dragging: false,
74 <?php endif;?>
75 tap: !L.Browser.mobile,
76 fullscreenControl: true,
77 fullscreenControlOptions: {
78 position: 'topleft'
79 }
80 });
81
82 L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
83 attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
84 }).addTo(wdk_map_<?php echo esc_html($id_element);?>);
85
86 <?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?>
87 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map_<?php echo esc_html($id_element);?>);
88 <?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?>
89 var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map_<?php echo esc_html($id_element);?>);
90 <?php endif;?>
91
92 <?php if(is_numeric($lng)):?>
93 <?php
94 $font_class = "fa fa-home";
95 $font_icon = $this->generate_icon($settings['conf_custom_map_pin_icon']);
96 $pin_icon = $settings['conf_custom_map_pin']['url'];
97
98 if(!empty(wdk_field_value('category_id', $wdk_listing_id))){
99 $category = $WMVC->category_m->get_data(wdk_field_value('category_id', $wdk_listing_id));
100 if(wmvc_show_data('marker_image_id', $category, false, TRUE, TRUE)){
101 $pin_icon = wdk_image_src($category, 'full', NULL,'marker_image_id');
102 } else if(!empty(wmvc_show_data('font_icon_code', $category))) {
103 $font_class = wmvc_show_data('font_icon_code', $category);
104 }
105 } else {
106 $font_class = "";
107 }
108
109 $wdk_popup_content = '<div class="infobox map-box wdk-infobox-basic">'
110 .'<h3 class="title">'.esc_html(wdk_field_value('post_title', $wdk_listing_id)).'</h3>'
111 .'<p>'.esc_html(wdk_field_value('address', $wdk_listing_id)).'</p>'
112 .'</div>';
113
114 if($settings['puopup_custom_content'] == 'yes') {
115 $title_field_id = substr($settings['title_field_id'], strpos($settings['title_field_id'],'__')+2);
116 $content_field_id = substr($settings['content_field_id'], strpos($settings['content_field_id'],'__')+2);
117
118 $wdk_popup_content = '<div class="infobox map-box wdk-infobox-basic">'
119 .'<h3 class="title">'.esc_html(wdk_field_value($title_field_id, $wdk_listing_id)).'</h3>'
120 .'<p>'.esc_html(wdk_field_value($content_field_id, $wdk_listing_id)).'</p>'
121 .'</div>';
122
123 }
124
125
126 $wdk_popup_content = str_replace("'", "\'", $wdk_popup_content);
127 $wdk_popup_content = str_replace("\n", "", $wdk_popup_content);
128 $wdk_popup_content = str_replace("\r", "", $wdk_popup_content);
129 ?>
130 let marker;
131 <?php if($pin_icon):?>
132 var image = '<?php echo esc_html($pin_icon);?>'; var innerMarker = '<div class="wdk_marker-container wdk_marker-container-image category_id_<?php echo esc_js(wdk_field_value('category_id', $wdk_listing_id));?>""><img src='+image+'></img></div>';
133 <?php elseif($font_icon && empty($font_class)):?>
134 var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wdk_field_value('category_id', $wdk_listing_id));?>""><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>';
135 <?php else:?>
136 var innerMarker = '<div class="wdk_marker-container category_id_<?php echo esc_js(wdk_field_value('category_id', $wdk_listing_id));?>""><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>';
137 <?php endif;?>
138
139 <?php if($settings['conf_custom_popup_enable'] == 'yes'):?>
140 marker = wdk_generate_marker_basic_popup('<?php echo esc_html($lat);?>','<?php echo esc_html($lng);?>',innerMarker,'<?php echo $wdk_popup_content;?>', wdk_jpopup_customOptions);
141 <?php else:?>
142 marker = wdk_generate_marker_nopopup('<?php echo esc_html($lat);?>','<?php echo esc_html($lng);?>',innerMarker);
143 <?php endif;?>
144
145 wdk_markers_<?php echo esc_html($id_element);?>.push(marker);
146 wdk_clusters_<?php echo esc_html($id_element);?>.addLayer(marker);
147 wdk_map_<?php echo esc_html($id_element);?>.addLayer(wdk_clusters_<?php echo esc_html($id_element);?>);
148 <?php endif;?>
149 /* set center */
150 })
151 </script>
152
153 <?php
154 if (!$is_edit_mode) {
155 $js_content = ob_get_clean();
156 $js_content = str_replace(array('</script>','<script>'),'',$js_content );
157 wp_add_inline_script( 'wdk-elementor-main', $js_content );
158 }
159 ?>
160
161