Latest

Tuesday, July 11, 2017

Get coordinate of marker and limit the values Google Maps

Asked by: Ali


I'm using google maps on my laravel 5.4 project .

I need to to save coordinate ( lat and long) of markers on map, I can do it but when I save it to database it saves too long number like : (35.690833660667444, 51.39251243323088)

now I want to limit this number to 6 characters like this : (35.690833, 51.392512)

but I don't know how , please help me. thanks for any help ;) .


Answers

Answered by: Jamesking56 at 2017-07-11 05:52PM Accepted



You could use PHP's round() function to round your lat / long, you will, however, lose a bit of precision in this way. It's better to store the whole thing if you can.

$latitude = round($latitude, 6);

The 6 means 6 decimal places.




Source

No comments:

Post a Comment

Adbox