【发布时间】:2014-01-07 10:39:51
【问题描述】:
<?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));
}
?>
我有这段代码可以将纬度和经度转换为坐标,但例如我把纽约市的纬度和经度放在正确的位置,在将纬度和经度转换为坐标时遇到问题。
请帮帮我。
感谢任何帮助。
【问题讨论】:
-
您需要它有多准确?行星的大小和形状有不同的基准。
-
看看这个 SO 问题:stackoverflow.com/questions/8175265/… 它是 C#,但接受的答案中的链接显示了如何转换坐标。
-
尽可能准确..地图大小为700 x 500..
-
了解地图的形状非常重要,因为计算方式不同。如果它是等角投影,则非常简单。 bit.ly/19DJATK其他预测:en.wikipedia.org/wiki/List_of_map_projections
-
地图的投影是Equirectangular cylinder_map ..