<?php
header("Content-type:image/png");
$image1 = imagecreatefrompng('cylindrical_map.png');
$image2 = imagecreatefrompng('pin.png');
$long = 18.96;
$lat = 72.82;
$scale_x = imagesx($image1);
$scale_y = imagesy($image1);
$pt = getlocationcoords($lat, $long, $scale_x, $scale_y);
imagecopymerge($image1, $image2, $pt["x"],$pt["y"], 0, 0, 80, 80, 98); //// place a second image on top of image 1
imagepng($image1);
function getlocationcoords($lat, $lon, $width, $height)
{
$x = (($lon + 180) * ($width / 360));
$y = ((-1 * $lat)+90) * ($height / 180);
return array("x"=>round($x),"y"=>round($y));
}
?>
I have this code that convert the lat and long to coordinates but for example i put and lat and long of New york city it wont point on the right location, having trouble with the converting the lat and long to coordinates.
please help me out with this.
Any help is appreciated.