I adapted the sample code at
http://code.google.com/apis/earth/documentation/introduction.html#polygon
to create a polygon, but it is showing up quite distorted, especially
when zoomed in and/or moving the camera.
I thought setTessellate() might help, but it seems not to:
var polygonPlacemark = ge.createPlacemark("");
polygonPlacemark.setGeometry(ge.createPolygon(""));
var outer = ge.createLinearRing("");
outer.setTessellate(1);
polygonPlacemark.getGeometry().setOuterBoundary(outer);
ge.getFeatures().appendChild(polygonPlacemark);
var coords = outer.getCoordinates();
coords.pushLatLngAlt(49.268543,-123.253830,0);
coords.pushLatLngAlt(49.268688,-123.253418,0);
coords.pushLatLngAlt(49.268635,-123.253372,0);
coords.pushLatLngAlt(49.268646,-123.253349,0);
coords.pushLatLngAlt(49.268562,-123.253281,0);
coords.pushLatLngAlt(49.268555,-123.253311,0);
coords.pushLatLngAlt(49.268505,-123.253265,0);
coords.pushLatLngAlt(49.268364,-123.253677,0);
coords.pushLatLngAlt(49.268414,-123.253723,0);
coords.pushLatLngAlt(49.268394,-123.253777,0);
coords.pushLatLngAlt(49.268467,-123.253830,0);
coords.pushLatLngAlt(49.268490,-123.253784,0);
coords.pushLatLngAlt(49.268543,-123.253830,0);
polygonPlacemark.setStyleSelector(ge.createStyle(""));
var lineStyle = polygonPlacemark.getStyleSelector().getLineStyle();
lineStyle.setWidth(2);
lineStyle.getColor().set(OUTLINE_COLOUR);
var polyStyle = polygonPlacemark.getStyleSelector().getPolyStyle();
polyStyle.getColor().set(INITIAL_ALPHA + ENERGY_COLOUR);
polyStyle.setFill(1);
polyStyle.setOutline(1);
The strangest part is that I also have this in a kml file, and this
doesn't happen when loading it that way. (I would just stick with the
kml except dynamically modifying styles seems harder that way.)
Any help is greatly appreciated.