mage-eventpress/templates/template-prts/google_map.php

65 lines
2.0 KiB
PHP
Raw Normal View History

2018-07-02 05:44:24 -04:00
<?php
add_action('mep_event_map','ggmap');
function ggmap(){
2019-01-23 05:43:47 -05:00
global $post,$event_meta,$user_api;
2019-03-09 02:17:31 -05:00
$map_type = mep_get_option( 'mep_google_map_type', 'general_setting_sec', 'iframe');
2019-01-23 05:43:47 -05:00
$location_sts = get_post_meta($post->ID,'mep_org_address',true);
if($location_sts){
$org_arr = get_the_terms( $post->ID, 'mep_org' );
$org_id = $org_arr[0]->term_id;
$lat = get_term_meta( $org_id, 'latitude', true );
$lon = get_term_meta( $org_id, 'longitude', true );
}else{
$lat = $event_meta['latitude'][0];
$lon = $event_meta['longitude'][0];
}
2019-03-09 02:17:31 -05:00
if($map_type=='iframe'){
?>
<div class="mep-gmap-sec">
<iframe id="gmap_canvas" src="https://maps.google.com/maps?q=<?php echo mep_get_event_locaion_item($post->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($event_meta['mep_sgm'][0]){ if($user_api){ ?>
2018-07-02 05:44:24 -04:00
<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'), {
2019-01-23 05:43:47 -05:00
center: {lat: <?php echo $lat; ?>, lng: <?php echo $lon; ?>},
2018-07-02 05:44:24 -04:00
zoom: 17
});
marker = new google.maps.Marker({
map: map,
draggable: false,
animation: google.maps.Animation.DROP,
2019-01-23 05:43:47 -05:00
position: {lat: <?php echo $lat; ?>, lng: <?php echo $lon; ?>}
2018-07-02 05:44:24 -04:00
});
marker.addListener('click', toggleBounce);
}
function toggleBounce() {
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=<?php echo $user_api; ?>&callback=initMap"
async defer></script>
2019-03-09 02:17:31 -05:00
<?php } } } }?>