javascript - Google Maps Api using Math.random to get random location - JS -
i having trouble getting map go random location. want go random location between bounds (lat -85 85, lng -180 180). whenever button clicked function makes map grey.
function random(lat, lng){ var random = new google.maps.latlng((math.random()-85)*85+, (math.random()-180)*180)); map.panto(random); }
var random = new google.maps.latlng( (math.random()*(85*2)-85), (math.random()*(180*2)-180) );
try this, or more generally:
function randombetween(min, max) { if (min < 0) { return min + math.random() * (math.abs(min)+max); }else { return min + math.random() * max; }}
Comments
Post a Comment