Reputation: 2527
How can I test that point is properly created if I cannot control that lat and lon are valid values? Is there a method that can test that point is valid?
var point = new google.maps.LatLng(lat, lon);
Upvotes: 0
Views: 87
Reputation: 117314
lat
and lon
must be numbers, valid ranges are:
latitude
(approximately): -85 to 85longitude:
-180 to 180So you may check the values e.g. via:
if(!isNaN(lat) && Math.abs(lat)<=85){/*valid latitude*/}
if(!isNaN(lon) && Math.abs(lon)<=180){/*valid longitude*/}
Upvotes: 1