/**
 * Displays the map
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function pw_map_shortcode($atts)
{
    $atts = shortcode_atts(array('address' => false, 'width' => '100%', 'height' => '400px', 'enablescrollwheel' => 'true', 'zoom' => 15, 'disablecontrols' => 'false'), $atts);
    $address = $atts['address'];
    if ($address) {
        if ($address && wp_script_is('google-maps-api', 'registered')) {
            wp_print_scripts('google-maps-api');
            $coordinates = pw_map_get_coordinates($address);
            if (!is_array($coordinates)) {
                return;
            }
            $map_id = uniqid('pw_map_');
            // generate a unique ID for this map
            ob_start();
            ?>
		<div class="pw_map_canvas" id="<?php 
            echo esc_attr($map_id);
            ?>
" style="height: <?php 
            echo esc_attr($atts['height']);
            ?>
; width: <?php 
            echo esc_attr($atts['width']);
            ?>
"></div>
	    <script type="text/javascript">
			var map_<?php 
            echo $map_id;
            ?>
;
			function pw_run_map_<?php 
            echo $map_id;
            ?>
(){
				var location = new google.maps.LatLng("<?php 
            echo $coordinates['lat'];
            ?>
", "<?php 
            echo $coordinates['lng'];
            ?>
");
				var map_options = {
					zoom: <?php 
            echo $atts['zoom'];
            ?>
,
					center: location,
					scrollwheel: <?php 
            echo 'true' === strtolower($atts['enablescrollwheel']) ? '1' : '0';
            ?>
,
					disableDefaultUI: <?php 
            echo 'true' === strtolower($atts['disablecontrols']) ? '1' : '0';
            ?>
,
					mapTypeId: google.maps.MapTypeId.ROADMAP
				}
				map_<?php 
            echo $map_id;
            ?>
 = new google.maps.Map(document.getElementById("<?php 
            echo $map_id;
            ?>
"), map_options);
				var marker = new google.maps.Marker({
				position: location,
				map: map_<?php 
            echo $map_id;
            ?>
				});
			}
			pw_run_map_<?php 
            echo $map_id;
            ?>
();
		</script>
		<?php 
            return ob_get_clean();
        } else {
            return __('This Google Map cannot be loaded because the maps API does not appear to be loaded', 'simple-google-maps-short-code');
        }
    }
}
/**
 * Displays the map
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function pw_map_shortcode($atts)
{
    $atts = shortcode_atts(array('address' => false, 'width' => '100%', 'height' => '400px'), $atts);
    $address = $atts['address'];
    if ($address) {
        wp_print_scripts('google-maps-api');
        $coordinates = pw_map_get_coordinates($address);
        if (!is_array($coordinates)) {
            return;
        }
        $map_id = uniqid('pw_map_');
        // generate a unique ID for this map
        ob_start();
        ?>
		<div class="pw_map_canvas" id="<?php 
        echo esc_attr($map_id);
        ?>
" style="height: <?php 
        echo esc_attr($atts['height']);
        ?>
; width: <?php 
        echo esc_attr($atts['width']);
        ?>
"></div>
	    <script type="text/javascript">
			var map_<?php 
        echo $map_id;
        ?>
;
			function pw_run_map_<?php 
        echo $map_id;
        ?>
(){
				var location = new google.maps.LatLng("<?php 
        echo $coordinates['lat'];
        ?>
", "<?php 
        echo $coordinates['lng'];
        ?>
");
				var map_options = {
					zoom: 15,
					center: location,
					mapTypeId: google.maps.MapTypeId.ROADMAP
				}
				map_<?php 
        echo $map_id;
        ?>
 = new google.maps.Map(document.getElementById("<?php 
        echo $map_id;
        ?>
"), map_options);
				var marker = new google.maps.Marker({
				position: location,
				map: map_<?php 
        echo $map_id;
        ?>
				});
			}
			pw_run_map_<?php 
        echo $map_id;
        ?>
();
		</script>
		<?php 
    }
    return ob_get_clean();
}