Distorted polygon

63 views
Skip to first unread message

Wachunga

unread,
Jul 6, 2008, 1:31:57 AM7/6/08
to KML Developer Support - Google Earth Browser Plugin
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.

ManoM

unread,
Jul 7, 2008, 12:20:23 AM7/7/08
to KML Developer Support - Google Earth Browser Plugin
Hi Wachunga,

Can you post a link to your code, so we can see it in action?

Mano

On Jul 5, 10:31 pm, Wachunga wrote:
> I adapted the sample code athttp://code.google.com/apis/earth/documentation/introduction.html#pol...

Wachunga

unread,
Jul 10, 2008, 8:25:00 PM7/10/08
to KML Developer Support - Google Earth Browser Plugin
Hi Mano,

Sorry about the delay. The original problem has been resolved but when
I recently tested my app (http://s88387243.onlinehome.us/visualizer)
on other machines my polygons disappear and distort in strange ways,
depending on mouse movement and/or window position:

http://s88387243.onlinehome.us/visualizer/distortion/polygon-buch.gif

Most disturbing is that this polygon problem also happens for the
"Create Polygon" and "Create Polygon (circle)" samples at
http://www.google.com/earth/plugin/examples/samples/ :

http://s88387243.onlinehome.us/visualizer/distortion/polygon-sample-square.gif
http://s88387243.onlinehome.us/visualizer/distortion/polygon-sample-circle.gif

So it would appear as though this is not specific to my code... Any
ideas?

Wachunga

Wachunga

unread,
Jul 10, 2008, 8:39:19 PM7/10/08
to KML Developer Support - Google Earth Browser Plugin

Sorry, forgot some relevant details.

The screenshots were taken on Firefox 2.0.0.15, but the distortion
also happened on IE 7.0.5730.11. When I use the exact same versions of
Firefox and IE on my original machine, the polygons look fine in the
app...


On Jul 10, 8:25 pm, Wachunga wrote:
> Hi Mano,
>
> Sorry about the delay. The original problem has been resolved but when
> I recently tested my app (http://s88387243.onlinehome.us/visualizer)
> on other machines my polygons disappear and distort in strange ways,
> depending on mouse movement and/or window position:
>
> http://s88387243.onlinehome.us/visualizer/distortion/polygon-buch.gif
>
> Most disturbing is that this polygon problem also happens for the
> "Create Polygon" and "Create Polygon (circle)" samples athttp://www.google.com/earth/plugin/examples/samples/:
>
> http://s88387243.onlinehome.us/visualizer/distortion/polygon-sample-s...http://s88387243.onlinehome.us/visualizer/distortion/polygon-sample-c...

Wachunga

unread,
Jul 12, 2008, 3:00:16 AM7/12/08
to KML Developer Support - Google Earth Browser Plugin
I had a friend (who works at Google, incidentally) try it out and he
got no distortion at all.

So it seems to be a video card issue of some kind... Not sure how
widespread the issue might be.

Wachunga

On Jul 10, 8:39 pm, Wachunga wrote:
> Sorry, forgot some relevant details.
>
> The screenshots were taken on Firefox 2.0.0.15, but the distortion
> also happened on IE 7.0.5730.11. When I use the exact same versions of
> Firefox and IE on my original machine, the polygons look fine in the
> app...
>
> On Jul 10, 8:25 pm, Wachunga wrote:
>
> > Hi Mano,
>
> > Sorry about the delay. The original problem has been resolved but when
> > I recently tested my app (http://s88387243.onlinehome.us/visualizer)
> > on other machines my polygons disappear and distort in strange ways,
> > depending on mouse movement and/or window position:
>
> >http://s88387243.onlinehome.us/visualizer/distortion/polygon-buch.gif
>
> > Most disturbing is that thispolygonproblem also happens for the
> > "CreatePolygon" and "CreatePolygon(circle)" samples athttp://www.google.com/earth/plugin/examples/samples/:
>
> >http://s88387243.onlinehome.us/visualizer/distortion/polygon-sample-s......
>
> > So it would appear as though this is not specific to my code... Any
> > ideas?
>
> > Wachunga
>
> > On Jul 7, 12:20 am, ManoM wrote:
>
> > > Hi Wachunga,
>
> > > Can you post a link to your code, so we can see it in action?
>
> > > Mano
>
> > > On Jul 5, 10:31 pm, Wachunga wrote:
>
> > > > I adapted the sample code athttp://code.google.com/apis/earth/documentation/introduction.html#pol...
> > > > to create apolygon, but it is showing up quite distorted, especially

Roman N

unread,
Jul 14, 2008, 5:00:17 PM7/14/08
to KML Developer Support - Google Earth Browser Plugin
Try giving your polygons some sort of minimal altitude, i.e. 1 meter.
You can accomplish this by calling pushLatLngAlt with a 3rd parameter
of something > 0. Also ensure that your polygons have an altitude mode
of ge.ALTITUDE_RELATIVE_TO_GROUND. This can be done using the
setAltitudeMode on the placemark's geometry.

If that doesn't work, please provide some details about your video
card so that we can look into it further.

- Roman

Wachunga

unread,
Jul 15, 2008, 3:57:37 PM7/15/08
to KML Developer Support - Google Earth Browser Plugin
Thanks for the reply, Roman.

I've tested the app on about 6 machines by now and the problem only
happens on a couple of them. As I mentioned earlier, on machines where
the problem occurs for my app it also happens on the Google samples at
http://www.google.com/earth/plugin/examples/samples/ . In other words,
I don't think changing the altitude etc. as you
suggested will help.

I made a copy of my app anyway (at http://s88387243.onlinehome.us/visualizer/2)
and made the changes. I don't have access to the problematic machines
right now, but when I tested the copy of my app on this machine (which
has never experienced the distortion), I started getting distortion on
some polygons and loss of color on others. Specifically, this happened
when I added the following line:

polygons[property].getGeometry().setAltitudeMode(ge.ALTITUDE_RELATIVE_TO_GROUND);

No idea why this would happen...

I'll try to access to one of the problematic machines soon and get you
some video card details.

Wachunga
> > > > > > to create apolygon, but it is showing up quitedistorted, especially
Reply all
Reply to author
Forward
0 new messages