Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So my big question here is how does the Google Maps API determine the "inner" versus the "outer" for a filled polygon?

Playing around with the polygon creator @ there seems to be a preference to:

  1. wrap the north pole;
  2. take the "smallest" polygon possible?

The big reason I want to know is to assist with answering the question "is point (x,y) in multipolygon z?"


share|improve this question
up vote 2 down vote accepted

The big reason I want to know is to assist with answering the question "is point (x,y) in multipolygon z?"

Using a Ray casting algorithm to solve the point in polygon problem, you don't need to know how the Google Code works.

enter image description here

The number of intersections for a ray passing from the exterior of the polygon to any point, if odd, shows the point lies inside the polygon. If even, the point lies outside the polygon. This test also works in three dimensions.

share|improve this answer
This begs the question, though: to get started with ray casting, you need to have a point that is known to be in the "exterior." For planar polygons that's easy: the exterior is unbounded. For spherical polygons there is no definite answer: either component can be taken as the exterior. Therefore there must either be a conventional determination of the exterior (which is usually done by means of the orientations of the polygon's rings) or an explicit indication of the exterior in the polygon's representation. – whuber Jun 8 '11 at 13:04
the 2D methodology is fine, however a 3D surface (such as the earth) requires a more accurate methodology in order to deal with the -180 to 180 of the longitude in addition to the issue of which side of a polygon is filled and which one isn't. – jufemaiz Jun 13 '11 at 7:25
Maybe you could clarify your question by adding that you are working with global datasets in lat/lon. – underdark Jun 13 '11 at 10:16

for v2 it was the GPolygon.contains() method

now v3 supports donut polygons this takes the first set of coordinates as the inner ring.

share|improve this answer
thanks for the reply. I have inspected to the polygon methodology for gmaps v3 however it is not so much as first and second (I believe that it is the second set that is the inner ring) but rather the rotation. While this is acceptable at a small level once I start attempting to ensure all test cases are true I run into trouble (mainly around the definition of the inner v outer of a large polygon projected onto the earths surface as with Gmaps). – jufemaiz Jun 13 '11 at 7:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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