| 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 |
}); |
| 58 |
|
| 59 |
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 60 |
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
| 61 |
}).addTo(wdk_map); |
| 62 |
|
| 63 |
<?php if(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] =='custom' && !empty($settings['conf_custom_map_style_self'])):?> |
| 64 |
var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style_self']);?>').addTo(wdk_map); |
| 65 |
<?php elseif(!empty($settings['conf_custom_map_style']) && $settings['conf_custom_map_style'] !='custom'):?> |
| 66 |
var positron = L.tileLayer('<?php echo esc_js($settings['conf_custom_map_style']);?>').addTo(wdk_map); |
| 67 |
<?php endif;?> |
| 68 |
|
| 69 |
<?php foreach($results as $key=>$listing): ?> |
| 70 |
<?php if(!is_numeric(wmvc_show_data('lng', $listing)))continue;?> |
| 71 |
<?php |
| 72 |
$pin_icon = ""; |
| 73 |
$font_class = ""; |
| 74 |
$font_icon = $this->generate_icon($settings['conf_custom_map_pin_icon']); |
| 75 |
$pin_icon = $settings['conf_custom_map_pin']['url']; |
| 76 |
|
| 77 |
if(!empty(wmvc_show_data('category_id', $listing))){ |
| 78 |
$category = $WMVC->category_m->get_data(wmvc_show_data('category_id', $listing)); |
| 79 |
if(wmvc_show_data('marker_image_id', $category, false, TRUE, TRUE)){ |
| 80 |
$pin_icon = wdk_image_src($category, 'full', NULL,'marker_image_id'); |
| 81 |
} else if(!empty(wmvc_show_data('font_icon_code', $category))) { |
| 82 |
$font_class = wmvc_show_data('font_icon_code', $category); |
| 83 |
} |
| 84 |
} else { |
| 85 |
$font_class = ""; |
| 86 |
$font_icon = ""; |
| 87 |
} |
| 88 |
|
| 89 |
?> |
| 90 |
<?php if($pin_icon):?> |
| 91 |
var image = '<?php echo esc_html($pin_icon);?>'; var innerMarker = '<div class="wdk_marker-container wdk_marker-container-image"><img src='+image+'></img></div>'; |
| 92 |
<?php elseif($font_icon && empty($font_class)):?> |
| 93 |
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>'; |
| 94 |
<?php else:?> |
| 95 |
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>'; |
| 96 |
<?php endif;?> |
| 97 |
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)); |
| 98 |
<?php endforeach; ?> |
| 99 |
wdk_map.addLayer(wdk_clusters); |
| 100 |
/* set center */ |
| 101 |
if(wdk_markers.length){ |
| 102 |
var limits_center = []; |
| 103 |
for (var i in wdk_markers) { |
| 104 |
var latLngs = [ wdk_markers[i].getLatLng() ]; |
| 105 |
limits_center.push(latLngs) |
| 106 |
}; |
| 107 |
var bounds = L.latLngBounds(limits_center); |
| 108 |
<?php if($settings['conf_custom_map_auto_center'] != 'yes'): ?> |
| 109 |
wdk_map.setView(bounds.getCenter()); |
| 110 |
<?php else: ?> |
| 111 |
wdk_map.fitBounds(bounds); |
| 112 |
<?php endif; ?> |
| 113 |
} |
| 114 |
}) |
| 115 |
</script> |
| 116 |
<?php |
| 117 |
|
| 118 |
if (!$is_edit_mode) { |
| 119 |
$js_content = ob_get_clean(); |
| 120 |
$js_content = str_replace(array('</script>','<script>'),'',$js_content ); |
| 121 |
wp_add_inline_script( 'wdk-elementor-main', $js_content ); |
| 122 |
} |
| 123 |
?> |
| 124 |
|
| 125 |
|