<?php 
header("content-type: application/x-javascript"); ?> 

<?php
define('WP_DEBUG', false);
@ini_set('log_errors','On'); 
@ini_set('display_errors','Off'); 
require_once( '../../../../wp-load.php' );
?>

<?php
$map_data = unserialize(stripslashes($_GET['data']));

$marker = '{';

if((!empty($map_data['lat']) && !empty($map_data['long'])) OR (!empty($map_data['address'])))
{
    if(!empty($map_data['lat']) && !empty($map_data['long']))
    {
    	$marker.= 'markers: [ { latitude: '.$map_data['lat'].', longitude: '.$map_data['long'];
    }
    elseif(!empty($map_data['address']))
    {
    	$marker.= 'markers: [ { address: "'.$map_data['address'].'"';
    }

    if(!empty($map_data['popup']))
    {
    	$marker.= ', html: "'.$map_data['popup'].'", popup: false';
    }
    $marker.= '} ], ';
}

if(!empty($map_data['type']))
{
    $marker.= 'maptype: google.maps.'.$map_data['type'].',';
}

$marker.= 'zoom: '.$map_data['zoom'];
$marker.= '}';

?>
jQuery(document).ready(function(){ jQuery("#<?php echo $map_data['id']; ?>").gMap(<?php echo $marker; ?>); });