Putting random latitude and longitude in google maps geolocation? -


I have latitude and longitude of some cities and I want to input it geometry randomly Can anyone tell me How can I do this value both negative and float are for an example Mexico Latitude / long 23.634501, -102.552784

myLatlng = new google.maps.LatLng (1.352083,103.819836);

You do not specify your programming language, so I will answer the language agnostic.

I think you have a point type, which can take double dual values, like

  square point {double latitude; Double longitude; }   

and you have a list or example of points representing the set of latitude / underlined pairs.

  list & lt; Point & gt; Points;   

Generate a random integer between 0 and (set size -1). Use that random integer as an index in the list.

  int index = random (0, number-long-1); Point myRandomPoint = points [index];   

Now use Google in your call

  myLatlng = new google.maps.LatLng (myRandomPoint.latitude, myRandomPoint.Longitude);    

Comments