如何用PHP获取GPS设备的经纬度?而不是通过javascript。谢谢。
最佳答案
如果您使用的是 Linux,则通过串行端口与 GPS 通信相当简单...只需使用串行电缆连接 GPS 并激活 GPS 中的 NMEA 协议(protocol)即可。
exec("stty -F /dev/ttyS0 9600 raw"); // Set the serial port parameters
if ( !$t = fopen('/dev/ttyS0','r+b') ) // Open for read
die(" - Failed to open\n");
// Send some command...
fwrite($t,"Command\n");
while(true) {
echo "recived: ".fgets($t,1024);
}
NMEA 数据如下所示:$GPGLL,4916.45,N,12311.12,W,225444,A,*1D
有很多网站描述了 NMEA 协议(protocol)如何工作,例如 http://www.gpsinformation.org/dale/nmea.htm
关于php - 使用php从gps设备获取纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3540597/