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;
|
|
|
|
|
|
|
|
$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];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-02 05:44:24 -04:00
|
|
|
if($event_meta['mep_sgm'][0]){ 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'), {
|
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>
|
|
|
|
<?php } } }?>
|