[英]Laravel store latitude and longitude
I'm storing latitude and longitude and the problem I'm having is when it is being stored it gets rounded up, which isn't what I want.我正在存储纬度和经度,我遇到的问题是当它被存储时它会被四舍五入,这不是我想要的。 Otherwise those field values become incorrect when using the latitude and longitude on the map.否则,在 map 上使用纬度和经度时,这些字段值会变得不正确。
This is what I'm using:这就是我正在使用的:
$table->decimal('lat', 10, 8)->nullable();
$table->decimal('lng', 11, 8)->nullable();
this value -40.95560269999999 gets turned into this -40.9556027000 when I just want -40.9556026999当我只想要 -40.9556026999 时,这个值 -40.95560269999999 变成了这个 -40.9556027000
Use double in your migrations instead of decimals, see below在迁移中使用double而不是小数,见下文
$table->double('lat')->nullable();
$table->double('lng')->nullable();
The best way to use double in your migrations instead of decimals, is see below:在迁移中使用 double 而不是 decimals 的最佳方法如下所示:
$table->decimal('long', 10, 7)->nullable();
$table->decimal('lat', 10, 7)->nullable();
您字段的数据类型可能不是十进制,请确保您的经纬度字段也是十进制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.