PluginProbe
WP Directory Kit / 1.3.4
WP Directory Kit v1.3.4
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 / dash-widgets / views / dash-widgets-map-listings.php

dash-widgets-map-listings.php in WP Directory Kit 1.3.4, at dash-widgets/views/dash-widgets-map-listings.php

131 lines 5.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 Shortcode Listings list
4 * This is the template that Shortcode listings list
5 *
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 ?>
13 <div class="wdk-dashwidget-element" id="wdk_dashwidget_<?php echo esc_attr($id_element);?>">
14 <div class="wdk-map">
15 <div id="wdk_map_results_<?php echo esc_html($id_element);?>" style="height:<?php echo esc_attr($settings['conf_custom_map_height']);?>px" class="wdk_map_results <?php echo wmvc_show_data('styles_thmbn_des_type',$settings, '');?> " ></div>
16 </div>
17 <?php
18 $zoom_index = 10;
19 ?>
20
21 <?php
22 $zoom_index = $settings['conf_custom_map_zoom_index'];
23 ?>
24 <?php
25 if($lat == 0)
26 {
27 $lat = wmvc_show_data('conf_custom_map_center_gps_lat', $settings);
28 $lng = wmvc_show_data('conf_custom_map_center_gps_lng', $settings);
29 }
30 ?>
31 <?php
32 $WMVC = &wdk_get_instance();
33 $WMVC->model('category_m');
34 ob_start();
35 ?>
36 <script>
37 var wdk_map ='';
38 var wdk_markers = [];
39 var wdk_clusters ='';
40 var wdk_jpopup_customOptions =
41 {
42 'maxWidth': 'initial',
43 'width': 'initial',
44 'className' : 'popupCustom'
45 };
46 jQuery(document).ready(function($) {
47 if(wdk_clusters=='')
48 wdk_clusters = L.markerClusterGroup({spiderfyOnMaxZoom: true, showCoverageOnHover: false, zoomToBoundsOnClick: true});
49 wdk_map = L.map('wdk_map_results_<?php echo esc_html($id_element);?>', {
50 center: ["<?php echo esc_js($lat);?>","<?php echo esc_js($lng);?>"],
51 zoom: "<?php echo esc_js($zoom_index);?>",
52 scrollWheelZoom: false,
53 <?php if($settings['conf_custom_dragging'] == 'yes'):?>
54 dragging: true,
55 <?php else:?>
56 dragging: false,
57 <?php endif;?>
58 tap: !L.Browser.mobile
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
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 = "dashicons dashicons-admin-home";
76 $font_icon = "";
77
78 $pin_icon = wmvc_show_data('conf_custom_map_pin',$settings, false);
79
80 if(!empty(wmvc_show_data('category_id', $listing))){
81 $category = $WMVC->category_m->get_data(wmvc_show_data('category_id', $listing));
82 if(wmvc_show_data('marker_image_id', $category, false, TRUE, TRUE)){
83 $pin_icon = wdk_image_src($category, 'full', NULL,'marker_image_id');
84 } else if(defined('ELEMENTOR_ASSETS_URL') && !empty(wmvc_show_data('font_icon_code', $category))) {
85 $font_class = wmvc_show_data('font_icon_code', $category);
86 }
87 } else {
88 $font_class = "";
89 $font_icon = "";
90 }
91
92 ?>
93 <?php if($pin_icon):?>
94 var image = '<?php echo esc_html($pin_icon);?>'; var innerMarker = '<div class="wdk_marker-container wdk_marker-container-image"><img src='+image+'></img></div>';
95 <?php elseif($font_icon && empty($font_class)):?>
96 var innerMarker = '<div class="wdk_marker-container"><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>';
97 <?php else:?>
98 var innerMarker = '<div class="wdk_marker-container"><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>';
99 <?php endif;?>
100 wdk_markers.push(wdk_dash_widget_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));
101 <?php endforeach; ?>
102 wdk_map.addLayer(wdk_clusters);
103 /* set center */
104 if(wdk_markers.length){
105 var limits_center = [];
106 for (var i in wdk_markers) {
107 var latLngs = [ wdk_markers[i].getLatLng() ];
108 limits_center.push(latLngs)
109 };
110 var bounds = L.latLngBounds(limits_center);
111 <?php if(wdk_get_option('wdk_fixed_map_results_position') && wdk_get_option('wdk_default_lat') && wdk_get_option('wdk_default_lng')): ?>
112 wdk_map.setView(["<?php echo esc_js(wdk_get_option('wdk_default_lat'));?>","<?php echo esc_js(wdk_get_option('wdk_default_lng'));?>"]);
113 <?php elseif($settings['enable_custom_gps_center'] == 'yes'): ?>
114 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']);?>"]);
115 <?php else: ?>
116 wdk_map.fitBounds(bounds);
117 <?php endif; ?>
118 }
119 })
120 </script>
121 <?php
122
123 $js_content = ob_get_clean();
124 $js_content = str_replace(array('</script>','<script>'),'',$js_content );
125 wp_add_inline_script( 'wdk-dash-widgets-main', $js_content );
126 ?>
127
128
129 </div>
130
131