define("DEFAULT_WIDTH", 480); define("DEFAULT_HEIGHT", 360); // iframeを出力 function iframe($url, $w, $h){ echo ""; } // サイズの異なる地図へのリンクを出力 function link_to_map($w, $h){ global $width, $height; $current = ($w == $width && $h == $height); echo "["; if($current){ echo ""; }else{ echo ""; } echo "$w x $h"; if($current){ echo ""; }else{ echo ""; } echo "]\n"; } // 入力された数値が問題ないか検証 function validate_number($str){ if(preg_match("/\\A\\d+\\z/", $str) !== false){ return $str; }else{ return -1; } } // パラメータをチェック $width = validate_number($_GET['w']); $height = validate_number($_GET['h']); if($width <= 0 || $height <= 0){ $width = DEFAULT_WIDTH; $height = DEFAULT_HEIGHT; } ?>
私が「今ココなう!」を立ち上げている場合には、地図が自動的に追従します。そうでない場合、東京タワーのあたりが表示されます。
iframe("http://imakoko-gps.appspot.com/view?w=$width&h=$height&group=mitsugobot&trace=maraigue&plotmode=0&hide_userlist=1", $width, $height); ?>
地図のサイズ link_to_map(320, 240); ?> link_to_map(480, 360); ?> link_to_map(640, 480); ?> link_to_map(800, 600); ?>