使用Meteor-react框架为汽车租赁停车场创建了一个应用程序(iOS)。我想跟踪使用GPS移动的司机。这样我就能发现他的结账状态。我需要在办理登机手续后计算停车位和司机位置之间的距离,以便我可以向驾驶员发送推送消息,看他是否即将结账。在进行基于GPS的结账的实际开发之前,需要一个建议是否真的可行?什么是利弊?
现在我正在通过npm包" gps-tracking"这是一个GPS听众。
我在/server/gps.js
中添加了代码var gps = require("gps-tracking");
var options = {
'debug' : true, //We don't want to debug info
automatically. We are going to log everything manually so you can
check what happens everywhere
'port' : 8000,
'device_adapter' : "TK103"
}
var server = gps.server(options,function(device,connection){
console.log(options);
console.log(device);
console.log(connection);
device.on("connected",function(data){
console.log("I'm a new device connected");
return data;
});
device.on("login_request",function(device_id,msg_parts){
console.log('Hey! I want to start transmiting my position. Please accept me. My name is '+device_id);
this.login_authorized(true);
console.log("Ok, "+device_id+", you're accepted!");
});
device.on("ping",function(data){
//this = device
console.log("I'm here: "+data.latitude+", "+data.longitude+" ("+this.getUID()+")");
//Look what informations the device sends to you (maybe velocity, gas level, etc)
//console.log(data);
return data;
});
device.on("alarm",function(alarm_code,alarm_data,msg_data){
console.log("Help! Something happend: "+alarm_code+"
("+alarm_data.msg+")");
});
//Also, you can listen on the native connection object
connection.on('data',function(data){
//echo raw data package
//console.log(data.toString());
})
});
提前致谢!