我创建了一个MySQL表,其中一个字段的类型为POINT,用于存储lat,lon坐标(例如:36.6294654 -93.1725982).
我收到错误,提交表单,我认为这是由于数据类型不匹配造成的.
SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field
我的理解是POINT应该有示例的格式(我也尝试过lat,lon).我认为问题是空间将变量转换为STRING.
我错过了什么吗,在这里?
这是我的PHP代码连接到数据库并插入记录.
// use google's geocoding service to transform an address into lat/lon coordinates (https://developers.google.com/maps/documentation/geocoding/)
$json = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($street) . ',+' . urlencode($city) . ',+' . urlencode($state) . ',+' . urlencode($zip) . '&key=YOUR_API_KEY');
$json = json_decode($json, true);
$latlon = $json['results'][0]['geometry']['location']['lat']