Skip to content
Advertisement

Rounding the place.geometry.location value in Google Maps API

I am using Google Maps API to do Reverse Geocoding (Address Lookup). My code result a extremely detail Lat Long as:

(-7.799250499999999, 110.40451239999993)

How to round the place.geometry.location result into a certain digit decimals?

e.g. (-7.7992505, 110.4045124)

This is the scheme of my code:

In my HTML

JavaScript

In my Javascript

JavaScript

I had tried to use:

JavaScript

or

JavaScript

and result some crash.

Any helps would be highly appreciated. Thanks

Advertisement

Answer

The precision?:number code must be replaced by an integer.

JavaScript

in this question, it sould be:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement