I'm interested in pulling street view data at random within a country.

I can only figure out how to generate a point within a bounding box. Often it pulls data from nearby nations. I'm using a GIS server right now, but I'm interested in removing it from the workflow since it's a pain.

Anybody know of any javascript mapping API that can randomly generate a point within a complex polygon, such as a country boundary?

  • 1
    Is the Geoserver tag correct here?
    – underdark
    Oct 26, 2010 at 22:09

2 Answers 2


"Random Google Street View. Teleport to a random point on the globe. Filter by country or continent. Share weird and wonderful places with your friends. Now with Antarctica, Brazil"


featured recently on http://googlemapsmania.blogspot.com/2010/10/random-google-maps.html

  • Thanks, I was already using an algorithm, that is mostly identical. Just trying to see if there was a faster way. Oct 26, 2010 at 1:54

There is a nice javascript implementation of the Ray casting algorithm on CloudDev

Using this it should be quite easy to:

  {create pt as a random point within the envelope}
until (pt is in poly)

An alternative approach if you are working with Google Maps might be the PointInPolygon test from AppDelegate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.