I am using package of Laravel spatial grimzy for creating polygons but when select polygon on map and try to save points as polygon it save NULL value but when I use points which in package it works well why this occurred with me ?? my code:
Points data got it from map:
[{“lat”:29.041064429176753,”lng”:26.5731069946289},{“lat”:26.847865370317415,”lng”:30.6819937133789},{“lat”:27.2001892385733,”lng”:24.3099234008789},{“lat”:30.604133976720366,”lng”:26.7269155883789}]
creating polygon:
$polygon = json_decode($request->polygon_area);
if(isset($polygon) && count($polygon) > 0) {
foreach($polygon as $linestring) {
array_push($polygonLines, new Point($linestring->lat, $linestring->lng));
}
}
$request['polygon_area'] = new Polygon([new LineString($polygonLines)]);
Above not working but when add static points it works well:
$request['polygon_area'] = new Polygon([new LineString([
new Point(40.74894149554006, -73.98615270853043),
new Point(40.74848633046773, -73.98648262023926),
new Point(40.747925497790725, -73.9851602911949),
new Point(40.74837050671544, -73.98482501506805),
new Point(40.74894149554006, -73.98615270853043)
])]);
And when use my data as above (static data) also doen’t work, I am using laravel 8
try to save polygon points in database
Aya Mohamed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.