简体   繁体   English

Laravel 店铺经纬度

[英]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.

相关问题 经纬度的Laravel半径 - Laravel Radius of latitude & longitude 使用laravel按经纬度搜索 - searching by latitude and longitude with laravel 编写 Laravel 迁移以创建数据类型为 point 的 postgres 表列,用于存储纬度经度(坐标) - Write Laravel Migration to create postgres table column with data type point for to store latitude longitude (coordinates) 要存储在mysql数据库中的经度和纬度的数据类型? - data type of longitude and latitude to store in mysql database? 如何在php(laravel)中将坐标转换为纬度和经度? - How to convert coordinates into latitude and longitude in php (laravel)? laravel中DMS格式的纬度经度验证 - latitude longitude validation in DMS format in laravel Laravel 按经纬度距离排序 - Laravel order by distance from longitude latitude 使用纬度和经度按距离存储和分类Symfony2学说 - Store and sort by distance using latitude and longitude Symfony2 Doctrine 如何在laravel中搜索给定距离和给定纬度和经度的所有位置 - how to search all the location for given distance and given latitude and longitude in laravel 将用户的经纬度与laravel数据库中的经纬度进行比较 - compare the latitude and longitude of the user's to the one in the database in laravel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM