我想将LatlngBounds对象从客户端传递到nodejs服务器。如何使用javascript将LatlngBounds对象传递给nodejs服务器
var bounds = map.getBounds();
socket.emit('sendbounds', bounds);
在服务器:
socket.on('sendbounds',function(data){
console.log(data);
data.getNorthEast();// undefined method getNorthEast()
}
服务器可以从客户端发送的数据。但是我无法使用方法getNorthEast()。
我的解决方案是创建一个对象的LatLngBounds:
bounds = new google.maps.LatLng(data.Ea.k, data.va.j),
new google.maps.LatLng(data.Ea.j, data.va.k));
但是不建议这样做,因为我们不能确定这些按键的名称总是“EA”和“VA”。 我注意到,有时这些按键的名称是“FA”和WA”,他们是‘无证属性’。他们改变与API版本。
任何解决方案来解决这个问题呢?
您的客户的边界是否包含有效值?在你的服务器中,console.log()打印什么? – Koh 2014-12-16 17:33:56