Esempio n. 1
0
    static function handle_shortcode($atts)
    {
        self::$add_script = true;
        extract(shortcode_atts(array('width' => 590, 'height' => 365, 'lat' => 0, 'long' => 0, 'zoom' => 12, 'type' => '', 'address' => '', 'title' => ''), $atts));
        $return = '';
        $rand = rand(600, 700);
        $width = (int) $width;
        $height = (int) $height;
        if (!empty($title)) {
            $return = '<h2 class="shortcode_title">' . $title . '</h2>';
        }
        if ($type == 'map2') {
            $return .= '<script type="text/javascript">
                            jQuery(window).load(function(){
                                jQuery("#map' . $rand . '").gMap({
                                    scrollwheel: false,
                                    markers: [{
                                        latitude: ' . $lat . ',
                                        longitude: ' . $long . '}],
                                    maptype: google.maps.MapTypeId.HYBRID,
                                    zoom: ' . $zoom . '
                                });
                            });
                        </script>';
        } elseif ($type == 'map3') {
            $return .= '<script type="text/javascript">
                            var $j = jQuery.noConflict();
                            $j(window).load(function(){
                                $j("#map' . $rand . '").gMap({
								scrollwheel: false,
                                    markers: [{
                                        latitude: ' . $lat . ',
                                        longitude: ' . $long . ',
                                        html: "' . $address . '",
                                        title: "",
                                        popup: true}],
                                    zoom: ' . $zoom . '
                                    });
                            });
                        </script>';
        } else {
            $return .= '<script type="text/javascript">
                            var $j = jQuery.noConflict();
                            $j(window).load(function(){
                                $j("#map' . $rand . '").gMap({
								scrollwheel: false,
                                    markers: [{
                                        latitude: ' . $lat . ',
                                        longitude: ' . $long . '}],
                                    zoom: ' . $zoom . '
                                    });
                            });
                        </script>';
        }
        $return .= '<div id="map' . $rand . '" class="map sortcode" style="width: ' . $width . 'px; height: ' . $height . 'px; border: 1px solid #ccc; overflow: hidden;"></div>';
        return $return;
    }
Esempio n. 2
0
    static function handle_shortcode($atts)
    {
        global $TFUSE;
        self::$add_script = true;
        extract(shortcode_atts(array('width' => 750, 'height' => 350, 'position' => '0:0', 'zoom' => 12, 'type' => '', 'address' => '', 'title' => ''), $atts));
        $coords = explode(':', $position);
        if (sizeof($coords) < 2) {
            return '';
        }
        $lat = $coords[0];
        $long = $coords[1];
        $return = '';
        $rand = rand(1, 1000);
        $TFUSE->include->js_enq('tf_map_shortcode_' . $rand, $atts);
        $width = (int) $width;
        $height = (int) $height;
        if (!empty($title)) {
            $return = '<h2>' . $title . '</h2>';
        }
        $return .= '<div id="map' . $rand . '" class="map frame_box" style="width: ' . $width . 'px; height: ' . $height . 'px; border: 1px solid #ccc; overflow: hidden;"></div>';
        if ($type == 'map2') {
            $return .= '<script type="text/javascript">
                                function initialize_' . $rand . '()
                                {
                                    if(maps[' . $rand . '] === undefined) {
                                         var gmap_options = {
                                            center: new google.maps.LatLng(' . $lat . ',' . $long . '),
                                            zoom: ' . $zoom . ',
                                            scrollwheel: true,
                                            mapTypeId: google.maps.MapTypeId.HYBRID
                                         }
                                         maps[' . $rand . '] = new google.maps.Map(document.getElementById("map' . $rand . '"), gmap_options);
                                         var marker = new google.maps.Marker({
                                                        map: maps[' . $rand . '],
                                                        draggable: true,
                                                            position: new google.maps.LatLng(' . $lat . ',' . $long . '),
                                                            visible: true
                                                        });';
            if ($address != '') {
                $return .= 'var boxText = document.createElement("div");
                                                        boxText.style.cssText = "border: 1px solid #c4c4c4; margin-top: 8px; margin-left: 8px; background: white; width: 150px; padding: 5px;";
                                                        boxText.innerHTML = "' . $address . '";
                                                        var myOptions = {
                                                             content: boxText
                                                        };
                                                        google.maps.event.addListener(marker, "click", function (e) {
                                                            ib.open(maps[' . $rand . '] , this);
                                                        });
                                                        var ib = new InfoBox(myOptions);
                                                        ib.open(maps[' . $rand . '] , marker);';
            }
            $return .= '
                                    } else {
                                        setTimeout(function(){ google.maps.event.trigger(maps[' . $rand . '], "resize");  maps[' . $rand . '].setCenter(new google.maps.LatLng(' . $lat . ',' . $long . '));}, 30);
                                    }
                                }
                            jQuery(document).ready(function(){
                                google.maps.event.addDomListener(window, "load", initialize_' . $rand . ');
                            });
                        </script>';
        } elseif ($type == 'map3') {
            $return .= '<script type="text/javascript">
                            function initialize_' . $rand . '()
                                {
                                    if(maps[' . $rand . '] === undefined) {
                                            var gmap_options = {
                                                center: new google.maps.LatLng(' . $lat . ',' . $long . '),
                                                title: "' . $title . '",
                                                zoom: ' . $zoom . ',
                                                mapTypeId: google.maps.MapTypeId.ROADMAP
                                                }
                                            maps[' . $rand . '] = new google.maps.Map(document.getElementById("map' . $rand . '"), gmap_options);
		                                    var marker = new google.maps.Marker({
                                                            map: maps[' . $rand . '],
                                                            draggable: true,
                                                            position: new google.maps.LatLng(' . $lat . ',' . $long . '),
                                                            visible: true
                                                        });';
            if ($address != '') {
                $return .= 'var boxText = document.createElement("div");
                                                        boxText.style.cssText = "border: 1px solid #c4c4c4; margin-top: 8px; margin-left: 8px; background: white; width: 180px; padding: 5px;";
                                                        boxText.innerHTML = "' . $address . '";
                                                        var myOptions = {
                                                             content: boxText
                                                        };
                                                        google.maps.event.addListener(marker, "click", function (e) {
                                                            ib.open(maps[' . $rand . '] , this);
                                                        });
                                                        var ib = new InfoBox(myOptions);
                                                        ib.open(maps[' . $rand . '] , marker);';
            }
            $return .= '}else{
                                            setTimeout(function(){ google.maps.event.trigger(maps[' . $rand . '], "resize");  maps[' . $rand . '].setCenter(new google.maps.LatLng(' . $lat . ',' . $long . ')); }, 30);
                                    }
                                }
                            jQuery(document).ready(function(){
                                google.maps.event.addDomListener(window, "load", initialize_' . $rand . ');
                            });
                        </script>';
        } else {
            $return .= '<script type="text/javascript">
                            function initialize_' . $rand . '()
                                {
                                    if(maps[' . $rand . '] === undefined) {
                                        var gmap_options = {
                                            center: new google.maps.LatLng(' . $lat . ',' . $long . '),
                                            zoom: ' . $zoom . ',
                                            mapTypeId: google.maps.MapTypeId.ROADMAP
                                        }
                                        maps[' . $rand . '] = new google.maps.Map(document.getElementById("map' . $rand . '"), gmap_options);
                                        var marker = new google.maps.Marker({
                                                            map: maps[' . $rand . '],
                                                            draggable: true,
                                                            position: new google.maps.LatLng(' . $lat . ',' . $long . '),
                                                            visible: true
                                                        });';
            if ($address != '') {
                $return .= 'var boxText = document.createElement("div");
                                                        boxText.style.cssText = "border: 1px solid #c4c4c4; margin-top: 8px; margin-left: 8px; background: white; width: 150px; padding: 5px;";
                                                        boxText.innerHTML = "' . $address . '";
                                                        var myOptions = {
                                                             content: boxText
                                                        };
                                                        google.maps.event.addListener(marker, "click", function (e) {
                                                            ib.open(maps[' . $rand . '] , this);
                                                        });
                                                        var ib = new InfoBox(myOptions);
                                                        ib.open(maps[' . $rand . '] , marker);';
            }
            $return .= '} else {
                                        setTimeout(function(){ google.maps.event.trigger(maps[' . $rand . '], "resize");  maps[' . $rand . '].setCenter(new google.maps.LatLng(' . $lat . ',' . $long . ')); }, 30);
                                    }
                                }
                            jQuery(document).ready(function(){
                                google.maps.event.addDomListener(window, "load", initialize_' . $rand . ');
                            });
                        </script>';
        }
        return $return;
    }