2020-05-24 04:17:41 -04:00
|
|
|
<?php
|
|
|
|
if (!defined('ABSPATH')) {
|
|
|
|
die;
|
|
|
|
} // Cannot access pages directly.
|
|
|
|
|
|
|
|
add_action('mep_event_map', 'mep_event_google_map');
|
|
|
|
if (!function_exists('mep_event_google_map')) {
|
|
|
|
function mep_event_google_map($event_id)
|
|
|
|
{
|
2021-09-03 06:25:05 -04:00
|
|
|
global $post, $event_meta, $user_api;
|
2020-05-24 04:17:41 -04:00
|
|
|
$map_type = mep_get_option('mep_google_map_type', 'general_setting_sec', 'iframe');
|
2023-03-20 01:07:11 -04:00
|
|
|
$map_zoom = mep_get_option('mep_google_map_zoom_level', 'general_setting_sec', '17');
|
2020-05-24 04:17:41 -04:00
|
|
|
$location_sts = get_post_meta($event_id, 'mep_org_address', true) ? get_post_meta($event_id, 'mep_org_address', true) : '';
|
2021-09-03 06:25:05 -04:00
|
|
|
$status = get_post_meta($event_id, 'mep_sgm', true) ? get_post_meta($event_id, 'mep_sgm', true) : '';
|
2020-05-24 04:17:41 -04:00
|
|
|
ob_start();
|
|
|
|
do_action('mep_event_before_google_map');
|
|
|
|
if ($location_sts) {
|
|
|
|
$org_arr = get_the_terms($event_id, 'mep_org');
|
|
|
|
$org_id = $org_arr[0]->term_id;
|
2020-07-12 06:42:13 -04:00
|
|
|
$lat = get_term_meta($org_id, 'latitude', true) ? get_term_meta($org_id, 'latitude', true) : 0;
|
|
|
|
$lon = get_term_meta($org_id, 'longitude', true) ? get_term_meta($org_id, 'longitude', true) : 0;
|
2020-05-24 04:17:41 -04:00
|
|
|
} else {
|
2021-09-03 06:25:05 -04:00
|
|
|
$lat = get_post_meta($event_id, 'latitude', true) ? get_post_meta($event_id, 'latitude', true) : 0;
|
|
|
|
$lon = get_post_meta($event_id, 'longitude', true) ? get_post_meta($event_id, 'longitude', true) : 0;
|
2020-05-24 04:17:41 -04:00
|
|
|
}
|
2021-09-03 06:25:05 -04:00
|
|
|
if ($status) {
|
2020-05-24 04:17:41 -04:00
|
|
|
if ($map_type == 'iframe') {
|
2020-01-22 07:15:24 -05:00
|
|
|
?>
|
2020-05-24 04:17:41 -04:00
|
|
|
<div class="mep-gmap-sec">
|
|
|
|
<iframe id="gmap_canvas" src="https://maps.google.com/maps?q=<?php echo mep_get_event_locaion_item($event_id, 'mep_location_venue'); ?>&t=&z=19&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" style='width: 100%;min-height: 250px;'></iframe>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
} else {
|
|
|
|
if ($user_api) {
|
|
|
|
?>
|
|
|
|
<div class="mep-gmap-sec">
|
|
|
|
<div id="map" class='mep_google_map'></div>
|
|
|
|
</div>
|
|
|
|
<script>
|
|
|
|
var map;
|
|
|
|
function initMap() {
|
|
|
|
map = new google.maps.Map(document.getElementById('map'), {
|
|
|
|
center: {
|
2021-10-29 17:14:29 -04:00
|
|
|
lat: <?php echo esc_attr($lat); ?>,
|
|
|
|
lng: <?php echo esc_attr($lon); ?>
|
2020-05-24 04:17:41 -04:00
|
|
|
},
|
2023-03-20 01:07:11 -04:00
|
|
|
zoom: <?php echo $map_zoom; ?>
|
2020-05-24 04:17:41 -04:00
|
|
|
});
|
|
|
|
marker = new google.maps.Marker({
|
|
|
|
map: map,
|
|
|
|
draggable: false,
|
|
|
|
animation: google.maps.Animation.DROP,
|
|
|
|
position: {
|
2021-10-29 17:14:29 -04:00
|
|
|
lat: <?php echo esc_attr($lat); ?>,
|
|
|
|
lng: <?php echo esc_attr($lon); ?>
|
2020-05-24 04:17:41 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
marker.addListener('click', toggleBounce);
|
|
|
|
}
|
2020-01-22 07:15:24 -05:00
|
|
|
|
2020-05-24 04:17:41 -04:00
|
|
|
function toggleBounce() {
|
|
|
|
if (marker.getAnimation() !== null) {
|
|
|
|
marker.setAnimation(null);
|
|
|
|
} else {
|
|
|
|
marker.setAnimation(google.maps.Animation.BOUNCE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2021-10-31 07:01:04 -04:00
|
|
|
<script src="https://maps.googleapis.com/maps/api/js?key=<?php echo esc_attr($user_api); ?>&callback=initMap" async defer></script>
|
2021-09-03 06:25:05 -04:00
|
|
|
<?php }
|
2020-05-24 04:17:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
do_action('mep_event_after_google_map');
|
|
|
|
$content = ob_get_clean();
|
|
|
|
echo apply_filters('mage_event_google_map', $content, $event_id);
|
|
|
|
}
|
|
|
|
}
|