I'm creating a Google map with many polygons. The problem is that when my polygons render, they are inconsistently colored (different colors across the polygon body) and they don't render fully. Included are 2 images where you can see the amount of a given polygon that renders is not consistent.
The desired behavior is that the polygons render fully (there is not a straight line where the polygon is unrendered going down the middle of the polygon body) and the color of the polygon fill is consistent throughout the polygon.
I assume this is a tiling issue. Here is the code I'm using to govern the "getTile" and "releaseTile" logic for my custom map type:
GMICMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
var c = Math.pow(2, zoom);
var c = Math.pow(2, zoom);
var tilex=coord.x,tiley=coord.y;
if (imageWraps) {
if (tilex<0) tilex=c+tilex%c;
if (tilex>=c) tilex=tilex%c;
if (tiley<0) tiley=c+tiley%c;
if (tiley>=c) tiley=tiley%c;
}
else {
if ((tilex<0)||(tilex>=c)||(tiley<0)||(tiley>=c)) {
var blank = ownerDocument.createElement('DIV');
blank.style.width = this.tileSize.width + 'px';
blank.style.height = this.tileSize.height + 'px';
return blank;
}
}
var img = ownerDocument.createElement('IMG');
var d = tilex;
var e = tiley;
var f = "t";
for (var g = 0; g < zoom; g++) {
c /= 2;
if (e < c) {
if (d < c) { f += "q" }
else { f += "r"; d -= c }
}
else {
if (d < c) { f += "t"; e -= c }
else { f += "s"; d -= c; e -= c }
}
}
GMICMapType.prototype.realeaseTile = function(tile) {
var idx = this.Cache.indexOf(tile);
if(idx!=-1) this.Cache.splice(idx, 1);
tile=null;
}
Additionally, I'm using this code to push the polygons to the map:
// Construct the sector outline.
window[sectorName] = new google.maps.Polygon({
name: sectorTitle,
infoWindowPointX: sectorCenterPointX,
infoWindowPointY: sectorCenterPointY,
knownSystems: knownSystems,
factionColor: factionColor,
paths: sectorCoords,
sectorDataNum: s,
strokeColor: sectorColor,
strokeOpacity: 1,
strokeWeight: 0.8,
zIndex: 1,
fillColor: sectorColor,
fillOpacity: 1
});
polygons.push(window[sectorName]);
window[sectorName].setMap(map);
I'm guessing this is the code relevant to the issue, but I'm not sure what is causing the issue so I'm not sure what code to include. If I should include other sections of the code (or all of the code) please let me know.