title: How can some LatLng be used to place markers on a Google map, but not to draw a Polygon?
body: <p>Roughly a week ago, I ran into a problem: on a custom google-powered map, my Polygons would not show up, while Markers for the same coordinates are totally ok. Despite my efforts with the Google Maps API, it seems I cannot find why.</p>
  
  <p><a href="http://www.nullpaperexception.com/sandbox/googlemaps/polygon.png" rel="nofollow">Here is a link to a screenshot of the map.</a> Purple arrows and numbers are my addition, they show:</p>
  
  <ol>
  <li>The <code>google.maps.Marker</code> I could place at the edges of my "region".</li>
  <li>The artifact generated by the <code>google.maps.Polygon</code> code. It is red as expected, but completely out of place and weirdly flat.</li>
  </ol>
  
  <p>Here is the part of the code where Markers and Polygons are generated: </p>
  
  <pre><code>var regionData = tecMap.regions[r];
  var regionMapMarkers = new google.maps.MVCArray();
  
  for (c in regionData.coords) {
      var point = projection.worldToMap(regionData.coords[c]);
      debugRegionPoints.push(point);
      var thisLatLng = projection.fromPointToLatLng(point);
      debugRegionLatLngs.push(thisLatLng);
      regionMapMarkers.push(thisLatLng);
  }
  
  regionMapMarkers.forEach(function(latLng, m){
      var marker = new google.maps.Marker({       
          position: latLng,
          map: map, 
          title: '',
          optimized: false
      });
      regionCorners.push(marker);
  });
  
  var paths = new google.maps.MVCArray();
  paths.push(regionMapMarkers);
  
  var region = new google.maps.Polygon({
      fillColor: "#FF0000",
      fillOpacity: 0.35,
      map: map,
      paths: paths,
      strokeColor: "#FF0000",
      strokeOpacity: 0.8,
      strokeWeight: 2     
  });
  regionPolys.push(region);
  </code></pre>
  
  <p>If you're wondering about the array of arrays, it's all on par with the <a href="http://code.google.com/intl/en/apis/maps/documentation/javascript/reference.html#Polygon" rel="nofollow">Google Maps Javascript API</a>.</p>
  
  <p>If you want to have a look at the map and related scripts, you can <a href="http://www.nullpaperexception.com/sandbox/googlemaps/map.html" rel="nofollow">find it here</a>.
  The code snippet is in <code>Scripts/tectonicus.js</code>, starting at line 659.</p>
  
  <p><strong>[Edit] Some debugging information:</strong></p>
  
  <p>It seems to be a rendering problem, not a "calculating" one. 
  From firebug console, in the map I linked, both </p>
  
  <pre><code>regionPolys[0].getPath().getArray();
  </code></pre>
  
  <p>and </p>
  
  <pre><code>for (i in regionCorners) {console.log(regionCorners[i].getPosition())};
  </code></pre>
  
  <p>will return</p>
  
  <pre><code>P { Na=0.20123958504464223, Oa=-22.5249097921875}
  P { Na=-0.21702715474330336, Oa=-32.7277467}
  P { Na=0.19466306397879407, Oa=-37.51230686484375}
  P { Na=0.12889785332031245, Oa=-49.04594858671875}
  </code></pre>
  
  <p>If I'm right, it means they have the same coordinates, which is on par with the code. </p>
  
  <p><strong>[Edit2] New advances !</strong></p>
  
  <p>It seems that vectors have rendering problems when dealing with a custom projection, such as the one used to display this isometric Minecraft map. (Generated with Tectonicus)</p>
  
  <p>After the last comments, I'm adding to the live code linked above two new debug Arrays,
  <code>debugRegionLatLngs</code> and <code>debugRegionPoints</code>. Above code is updated so you can see what they contain.</p>
  
  <p><strong>[Edit3] Projection and coordinates</strong></p>
  
  <p>Crossing BicycleDude's research with mine, it's now almost certain that it's the custom projection that wrecks polygons. In fact, there is <a href="http://code.google.com/p/gmaps-api-issues/issues/detail?id=2951" rel="nofollow">a possibly related bug in Google Maps' API</a>.</p>
  
  <p>This projection is used because Minecraft maps can be virtually infinite, and yet have to use a gmap, which wraps around after 360° longitude. Also related is the fact that ingame coordinates are rendered in an isometric way, while gmaps expects something more like the Mercator projection.</p>
  
  <p>I tried tweaking the projection a bit, but had no interesting results so far.</p>