I am trying to store Google Map Circle data in MySql Database. I choose text data type to store Center Coordinate and int to store radius of the center. Now I am using below code to fetch data from those column.
$zone = RestaurantZones::whereRaw( "ST_Distance(circle_coordinates, ?) <= radius", [$point] )->pluck( 'id' );
I am getting below error.
Illuminate\Database\QueryException: SQLSTATE[22023]: Invalid parameter value: 3037 Invalid GIS data provided to function st_distance.
How can I store Google Map Circle data in MySql Database ?
It's pretty clear from the error shown, to store and retrieve this kind of data, you should use MySQL's spatial data types and functions.
"(Just for revision) Imagine you have a map with circles on it, like the Google Map circles. Each circle has a center (the middle point) and a radius (how big it is).
Having a table that uses spatial data types
ST_GeomFromTextfunction to create a point from the center coordinates.