I'm using Google Places API to get a list of establishment near a geo location, and I'm trying to figure out how to move 1km north and get geo coordinates there and then do another Google API call.
Ideally I'd like to be able to go into any direction for any distance and get the geo coordinates. Where do i start? If this is not possible then please let me know.
I'm not getting anything. Please have a look. How exactly do i use the direction. How do i go north?
$lat = "40.712714";
$lon = "-74.005997";
$direction = "80";
$length="2000";
move($lon, $lat, $direction, $length);
function move($cx,$cy,$direction,$length){
$x=$cx*cos($direction*M_PI/180)+$length;
$y=$cy*sin($direction*M_PI/180)+$length;
return array($x,$y);
echo $x;
echo $y;
}
EDIT I just tried changing the coordinates number manually and it seems to do what I want. For example I take these coordinates
40.717828,-73.998672
and changed the 3rd decimal number. That moved my location north.
40.710828,-73.998672
So I have conducted a little investigation. This is the corrected code for this function:
function move($ylat,$xlng,$direction_degree,$length_degree){
$x=$xlng+$length_degree*cos($direction_degree*M_PI/180);
$y=$ylat+$length_degree*sin($direction_degree*M_PI/180);
return array($x,$y);
}
var_dump(move(52.1,11.2,0,1)); //North 1 degree.
However, there are a few minor problems to fix before you can use it as you would like.
Quoting from this wikipedia article GCS Wiki Article:
On the GRS80 or WGS84 spheroid at sea level at the equator, one latitudinal second measures 30.715 metres, one latitudinal minute is 1843 metres and one latitudinal degree is 110.6 kilometres. The circles of longitude, meridians, meet at the geographical poles, with the west-east width of a second naturally decreasing as latitude increases. On the equator at sea level, one longitudinal second measures 30.92 metres, a longitudinal minute is 1855 metres and a longitudinal degree is 111.3 kilometres. At 30° a longitudinal second is 26.76 metres, at Greenwich (51° 28' 38" N) 19.22 metres, and at 60° it is 15.42 metres.