[Tool/Web/Other] PHP - A map that displays a red square at specified 2d coords
#10

Hello I am trying to create the same thing just replacing the red square with image

Thats the code but its not the same location where map.php?x=1450&y=2770

PHP Code:
<?php
$img 
imagecreatefromjpeg("map.jpg");
$sim imagecreatefrompng("pin.png");
if( isset(
$_GET["x"]) && isset($_GET["y"]) ) {
  
// the map is GTA SAn andreas is 6000x6000
  // the image that i use is 800x800 6000/800 = 7.5
  
  
$x $_GET["x"]/7.5;
  
$y $_GET["y"]/7.5;
  
  
// 0.0 0.0 is at the center of the map, in PHP 0.0 0.0 is in the top left corner, so I added / substracted 400. the map is 800x800 px, 400x400 is at the center of the map.
  
       
$x $x 400;
       
$y = -($y 400);
  
        
$sx imagesx($img);
    
    
$sy imagesy($sim);
    
        
$marge_right $_GET["x"]/5.5;
    
    
$marge_bottom $_GET["y"]/5.5;
    
imagecopy($img$simimagesx($img) - $sx $marge_rightimagesy($img) - $sy $marge_bottom00imagesx($sim), imagesy($sim));
}
header ('Content-Type: image/png');
imagepng($img);
imagepng($sim);
imagedestroy($img);
imagedestroy($sim);
?>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)