mapID = $mapID; $sml = $this -> create_small_user_map($smallMapStyle); $lge = $this -> create_large_user_map(); if ( $lge == true || $sml == true ){ //plot the owners location! $this ->prep_draw(); $this -> plot ( $owner_lat , $owner_long , $owner_large_icon, $owner_small_icon ); //plot the key $this -> plot ( -55 , -170 , $owner_large_icon, $owner_small_icon ); $this -> write ( -55 , -160 , $text_owner ); $this -> plot ( -45 , -170 , $visitor_large_icon, $visitor_small_icon ); $this -> write ( -45 , -160 , $text_visitor ); } return true; } function create_large_user_map (){ if ( is_file ( "large_user_maps/" . $this -> mapID . ".jpg" ) != true ){ copy ( "raw_map_images/_fullsize.jpg" , "large_user_maps/" . $this -> mapID . ".jpg" ); return true; } return false; } function create_small_user_map ($smallMapStyle){ if ( is_file ( "raw_map_images/" . $smallMapStyle ) != true ){ $smallMapStyle = "default.jpg"; } if ( is_file ( "small_user_maps/" . $this -> mapID . ".jpg" ) != true ){ copy ( "raw_map_images/" . $smallMapStyle , "small_user_maps/" . $this -> mapID . ".jpg" ); return true; } return false; } function prep_draw(){ if ($this -> draw_prepd != true ){ $this -> small_image = imagecreatefromjpeg( "small_user_maps/" . $this -> mapID . ".jpg" ); $this -> small_info['size_x'] = imagesx($this -> small_image); $this -> small_info['size_y'] = imagesy($this -> small_image); $this -> small_image_color['red'] = imagecolorallocate ($this -> small_image,255,0,0); $this -> small_image_color['text'] = imagecolorallocate ($this -> small_image,255,255,255); $this -> large_image = imagecreatefromjpeg( "large_user_maps/" . $this -> mapID . ".jpg" ); $this -> large_info['size_x'] = imagesx($this -> large_image); $this -> large_info['size_y'] = imagesy($this -> large_image); $this -> large_image_color['red'] = imagecolorallocate ($this -> large_image,255,0,0); $this -> large_image_color['text'] = imagecolorallocate ($this -> large_image,255,255,255); $this -> draw_prepd = true; } } function prep_draw_temp($smallMapStyle=""){ if ( is_file ( "raw_map_images/" . $smallMapStyle ) != true ){ $smallMapStyle = "default.jpg"; } $this -> small_image = imagecreatefromjpeg( "raw_map_images/" . $smallMapStyle ); $this -> small_info['size_x'] = imagesx($this -> small_image); $this -> small_info['size_y'] = imagesy($this -> small_image); $this -> small_image_color['red'] = imagecolorallocate ($this -> small_image,255,0,0); $this -> small_image_color['text'] = imagecolorallocate ($this -> small_image,255,255,255); $this -> small_image_color['antartic_text'] = imagecolorallocate ($this -> small_image,0,0,0); $this -> large_image = imagecreatefromjpeg( "raw_map_images/_fullsize.jpg" ); $this -> large_info['size_x'] = imagesx($this -> large_image); $this -> large_info['size_y'] = imagesy($this -> large_image); $this -> large_image_color['red'] = imagecolorallocate ($this -> large_image,255,0,0); $this -> large_image_color['text'] = imagecolorallocate ($this -> large_image,255,255,255); $this -> large_image_color['antartic_text'] = imagecolorallocate ($this -> large_image,0,0,0); } function write($lat,$long,$text,$color="text"){ /* SMALL image */ $small_pt = getlocationcoords($lat,$long,$this->small_info['size_x'],$this->small_info['size_y']); imagettftext ( $this->small_image, "8", 0,$small_pt["x"], $small_pt["y"]+2, $this -> small_image_color[$color] , "font.ttf", $text); /* LARGE image */ $large_pt = getlocationcoords($lat,$long,$this->large_info['size_x'],$this->large_info['size_y']); imagettftext ( $this->large_image, "12", 0,$large_pt["x"], $large_pt["y"]+8, $this -> large_image_color[$color] , "font.ttf", $text); } function plot($lat,$long,$large_icon="",$small_icon=""){ /* SMALL image */ $small_pt = getlocationcoords($lat,$long,$this->small_info['size_x'],$this->small_info['size_y']); if ( is_file ( $small_icon ) == true ){ $icon = imagecreatefromgif($small_icon); $x = imagesx($icon); $y = imagesy($icon); imagecopymerge($this->small_image, $icon, $small_pt["x"]-($x/2), $small_pt["y"]-($y/2), 0, 0, $x, $y, 100); }else{ imagefilledrectangle($this->small_image,$small_pt["x"]-2,$small_pt["y"]-2,$small_pt["x"]+2,$small_pt["y"]+2,$this -> small_image_color['red']); } /* LARGE image */ $large_pt = getlocationcoords($lat,$long,$this->large_info['size_x'],$this->large_info['size_y']); if ( is_file ( $large_icon ) == true ){ $icon = imagecreatefromgif($large_icon); $x = imagesx($icon); $y = imagesy($icon); imagecopymerge($this->large_image, $icon, $large_pt["x"]-($x/2), $large_pt["y"]-($y/2), 0, 0, $x, $y, 100); }else{ imagefilledrectangle($this->large_image,$large_pt["x"]-2,$large_pt["y"]-2,$large_pt["x"]+2,$large_pt["y"]+2,$this -> large_image_color['red']); } } function add_count($total_count,$small_style="default.jpg"){ //make the bottom 20 px of fullsize map original $orig = imagecreatefromjpeg("raw_map_images/_fullsize.jpg"); $x = imagesx($orig); $y = imagesy($orig); imagecopymerge ( $this->large_image, $orig, 0, ($y-50), 0, ($y-50), $x, 50, 99 ); $orig = imagecreatefromjpeg("raw_map_images/".$small_style); $x = imagesx($orig); $y = imagesy($orig); imagecopymerge ( $this->small_image, $orig, 0, ($y-30), 0, ($y-30), $x, 30, 99 ); $this -> write ( -85 , 70 , "Visitor count: $total_count" , 'antartic_text' ); } function finish_draw(){ imagejpeg($this->small_image,"small_user_maps/" . $this -> mapID . ".jpg" , 99 ); imagedestroy($this->small_image); imagejpeg($this->large_image,"large_user_maps/" . $this -> mapID . ".jpg" , 99 ); imagedestroy($this->large_image); $this -> draw_prepd = false; } } ?>