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

What is this?

This can be used in a web panel to show a red square at given coordinates. I use it to be able to show where a specific car is in game.
This uses a 800x800 .jpg map. I also included a higher resolution of the image in case you want to create a bigger map, change the quality of the image or whatever.

This may not work if your hosting doesn't have GD.. something enabled.

Usage
Code:
<img src="map.php?x=1450&y=2770" />
The above code will display this image (red square in top-right):


Download


http://www.solidfiles.com/d/b3bf15403e/
https://dl.dropboxusercontent.com/u/.../php%20map.zip

http://pastebin.com/9UGrE50R (you can find the .jpg image in the zip above)
Reply
#2

Good job..
Reply
#3

Hello,

when i use it i got an error,

Max
Reply
#4

instead if u had posted image sepratly it would be easier to get a preview , any ways it seem simple but Nice
Reply
#5

Awesome work, I could get some use out of this.
Reply
#6

If anyone wanna use the map_full.jpg just edit this:

pawn Code:
$img = imagecreatefromjpeg("map_full.jpg");

$x = $_GET["x"]/3.90;
$y = $_GET["y"]/3.90;

$x = $x + 768;
$y = -($y - 768);
Reply
#7

Hey, at least cast the variable to integer!
PHP Code:
$x = (int) $_GET["x"] / 3.90;
$y = (int) $_GET["y"] / 3.90
Why?

Quote:

map.php?x=PEOPLEARE&y=EVIL
map.php?x[]=sometimes&x[]=alittletoomuch&y=-100000

Oh, and well, I don't think negative dimensions are a good input too, so absolute value maybe?

Have a nice day!
Reply
#8

You don't know anything about sa:mp coordinates then.
http://rse-samp.com/map/map.php?x=-1988.43&y=-1988.43
Reply
#9

I meant that values passed to imagefilledrectangle should be checked first if they are valid coords (and in this case - positive values).
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)