Location: PHPKode > scripts > googlemapsForWP > googlemapsforp/business/googlemapsForWPMap.php
<?php
/**
 * Documents the file following
 * @package googlemapsForWP
 * @author webcat
 */
//#################################################################
if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
//#################################################################
if (!class_exists('gmfwpMap')){
/**
 * googlemapsForWP maps
 * The class provides access to
 */
	 abstract class gmfwpMap {
            
         }
}
if (!class_exists('googlemapsForWPMap')){
/**
 * googlemapsForWP maps
 * The class provides access to
 */
	 class googlemapsForWPMap extends gmfwpMap {
            protected static $URLlimit = 2048;
            protected static $HTTP = 'http://maps.googleapis.com/maps/api/staticmap?';
            protected static $HTTPS = 'https://maps.googleapis.com/maps/api/staticmap?';

            protected $ID;
            protected $mapParams;
            protected $url;
            protected $flags;
            protected $cacheexists;
            protected $cache;
/**
 *
 * @param <type> $id
 * @param <type> $args
 */
            function __construct($id,$args){
                try{
                    $url=googlemapsForWP::pluginDir() . DIRECTORY_SEPARATOR;
                if (!file_exists($url.'business' . DIRECTORY_SEPARATOR . 'googlemapsForWPMapImage.php' )&& !file_exists($url. DIRECTORY_SEPARATOR .'cache')){
                        throw new Exception ('Cannot find the required files');
                    }else{
                        $this->cacheexists=true;
                        require_once(googlemapsForWP::pluginDir() .DIRECTORY_SEPARATOR . 'business' . DIRECTORY_SEPARATOR . 'googlemapsForWPMapImage.php');
                        $this->cache=new googlemapsForWPMapImage();
                    }
                }catch(Exception $e){
                    $this->cacheexists=false;
                    $this->cache=null;
                }
                $this->ID=$id;
                $this->mapParams= $args;
                $this->url="";
                $this->flags="";
                //'mapname','mapdescription','longitude','latitude','zoom','sizewidth','sizeheight','type','format','sensor'
            }
/**
 * Creates a url of all the map's parameters urlencoded where necessary
 * @param string $security
 * @return string 
 */
            function createURL($security){
                switch ($security) {
                    case '1':
                        $this->url=googlemapsForWPMap::$HTTP;
                        break;
                    case '2':
                        $this->url=googlemapsForWPMap::$HTTPS;
                        break;
                    default:
                        $this->url=googlemapsForWPMap::$HTTP;
                        break;
                }
                $params.='center='.$this->mapParams['latitude'].','.$this->mapParams['longitude'];
                $params.='&zoom='.$this->mapParams['zoom'];
                $params.='&size='.$this->mapParams['sizewidth']."x".$this->mapParams['sizeheight'];
                $params.='&maptype='.$this->mapParams['type'];
                $params.='&format='.$this->mapParams['format'];
                $params.=$this->flags;
                $params.='&sensor='.$this->mapParams['sensor'];
                $this->url.= $params;
                return $this->url;
            }
/**
 *
 * @param array $flags An array of the stored flags for this map
 */
            function addFlags($flags){
                if(!empty ($flags)){
                $flagparams="";
                    foreach($flags as $flag){
                        $flagparams.= "&markers=size:".$flag['size'].urlencode('|')."color:".$flag['colour'].urlencode('|')."".'label:S'.urlencode('|').$flag['latitude'].",".$flag['longitude'];
                    }
                    //$flags.=implode(urlencode('&'), $flag);
                    $this->flags= $flagparams;
                }
            }
/**
 *
 * @return string
 */
            function getShortCode(){
                $code = "<span>".htmlentities("[getmap mapnumber='".$this->ID."']")."</span>";
                return $code;
            }
/**
 * @param <type> $paramname
 * @return <type>
 */
            function getParam($paramname){
                return $this->mapParams[$paramname];
            }
        }
}
if (!class_exists('googlemapsForWPEarthMap')){
/**
 * googlemapsForWP maps
 * The class provides access to
 */
	 class googlemapsForWPEarthMap extends gmfwpMap {
         }
}
?>
Return current item: googlemapsForWP