Filled Polygon with clampToGround in KML Google Earth - polygon

I'm trying to put a filled polygon on the ground, following the surface, but up to now none of my trials succeeded. I always get either a filled polygon hovering at some specific height (sometimes cutting through the terrain surface, depending on that height) or a mere outline of the polygon without any filling. I tried
setting the height information to 0 (in coordinates and with tag altitude),
setting the altitudeMode to clampToGround (and clampToSeaFloor),
using the namespace extension gx, but all to no avail.
using tag tessellate (0 and 1),
using tag extrude (0 and 1 and even higher values),
turning the order of the polygon points around (to switch from clockwise to counterclockwise),
but nothing worked.
Here is an example which I think is correct but doesn't work (this one shows no filling for the polygon, just the outline):
<?xml version="1.0" encoding="UTF-8"?>
<kml>
<Placemark>
<name>Filled Polygon Example</name>
<visibility>1</visibility>
<Style>
<LineStyle>
<color>FF00FFFF</color>
<width>1</width>
</LineStyle>
<PolyStyle>
<fill>1</fill>
<outline>1</outline>
<color>FF0000FF</color>
</PolyStyle>
</Style>
<Polygon>
<extrude>1</extrude>
<altitudeMode>clampToGround</altitudeMode>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
13.213,52.793,0
13.202,52.803,0
13.218,52.829,0
13.226,52.807,0
13.213,52.793,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</kml>
If you replace clampToGround by e. g. relativeToGround, you get the filling of the polygon, but it isn't following the surface but cutting flat through it.
I'm using Google Earth version 7.1.8 on Ubuntu 16.04.
What's curious is that I found some (quite old) forum posts which stated that this worked once (around 2006), unfortunately without a complete example. Is this a dropped feature?
I would be happy if anybody could provide an example KML which displays a filled polygon on the surface of the earth in Google Earth.

As #jasonm1 pointed out in a comment, the problem doesn't exist in the Windows version. I tried out switching graphic options but nothing helped. Then I tried the Windows version in an emulator (Wine). There the code above and my real code worked without a problem. Overlaying filled polygons with clampToGround worked also as expected. Google Earth in general seems to be very well supported by Wine, so for now this fixes my issue.
Would be nicer to have a decent native Google Earth on Linux, though.

Related

Why isn't Google Maps API obeying CSS formatting in KML file for balloon content

I have created a KML file with CSS formatting for the contents of the balloon. The CSS is read and displays fine in Google Earth, but not when using the Google Maps API. Can anyone tell me why and how to overcome this please?
Here's the relevant snippets from the KML file...
<Style id="Summit_Target">
<IconStyle>
<Icon><href>http://www.virtualmountains.co.uk/shared/Summit_Target.png</href></Icon>
</IconStyle>
<BalloonStyle>
<text>$[description]</text>
<bgColor>white</bgColor>
<text><![CDATA[
<font color="#674A32" face="arial" align="justify">$[description]</font>
]]></text>
</BalloonStyle>
<LabelStyle>
<color>FF14B450</color>
<scale>0.8</scale>
</LabelStyle>
</Style>
<Placemark>
<name>High Street</name>
<description>
<![CDATA[
<style>
H1{text-align:left; font-size:12pt; font-weight:bold;} P{font-size:10pt;}
img{width:96px; height:120px; float:left; border:0; margin-right:8px}
</style>
<H1>High Street</H1>
<P>
<IMG SRC="High_Street_Summit.jpg" title="High Street" alt="High Street">
At 828m, with a 373m drop, High Street appears in many a hill bagger's list includings a Nuttell, Marilyn, Simm, Hewitt, Wainwright, Birkett, and Trail 100.<BR><BR>Roman engineers built a road across the summit linking their forts at Brougham and Ambleside, thus giving the hill its name.<BR><BR>A second name <i>’Racecourse Hill’</i> is derived from the summer fairs and horseraces that were held here unp until 1835.<BR><BR>The mountain's summit is crowned by an Ordnance Survey triangulation pillar.
</P>
]]>
</description>
<styleUrl>#Summit_Target</styleUrl>
<Point><coordinates>-2.864838,54.491697,0</coordinates></Point>
</Placemark>
Here's how the balloon appears in Google Earth, i.e. as I'm expecting it too...
But here is how it appears on the web when read by the Google Maps API...
The title is centred, not left justified.
The title is not in 12pt Arial bold .
The main text starts near the bottom of the image, not to the right at the top.
The line spacing (though not specified) looks great in Google Earth, but not in Google Maps.
If anyone can help me correct this, it will be much appreciated.
For the benefit of others I found solution to achieve the formatting I wanted.
There are two rules to consider.
a) The KML will use some of the CSS styling found in the webpage hosting the Google Map. So that the balloon contents is consistent across different webpages I removed the H1 and P tags.
b) CSS shorthand is not supported. For example you might have {font:Arial 10pt bold} in the style sheet or direct in the KML tag. This has to be written longhand as in the code snippet below.
<Placemark>
<name>High Street</name>
<description>
<![CDATA[
<DIV style="max-width:400px; margin-right:10px; margin-bottom:10px; color:#674A32; font-family:Arial">
<DIV style="font-size:11pt; font-weight:bold; text-align:left">High Street<BR></DIV>
<DIV style="font-size:10pt; text-align:justify"><BR>
<IMG SRC="High_Street_Summit.jpg" title="High Street" alt="High Street" width="96px" height="120px" align="left" style="margin-right:10px; margin-bottom:10px">
At 828m, with a 373m drop, High Street appears in many a hill bagger's list includings a Nuttell, Marilyn, Simm, Hewitt, Wainwright, Birkett, and Trail 100.<BR><BR>Roman engineers built a road across the summit linking their forts at Brougham and Ambleside, thus giving the hill its name.<BR><BR>A second name <i>’Racecourse Hill’</i> is derived from the summer fairs and horseraces that were held here up until 1835.<BR><BR>The mountain's summit is crowned by an Ordnance Survey triangulation pillar.
</DIV>
</DIV>
]]>
</description>
<styleUrl>#Summit_Target</styleUrl>
<Point><coordinates>-2.864838,54.491697,0</coordinates></Point>
</Placemark>
Putting the visible contents of the balloon inside a DIV enabled the left justification of the title text.
The additional styling to the DIV prevents the balloon from becoming too wide, and the margin (the only formating I could get to work) moves the text away from the right hand side when displayed on an iPhone and being covered by a vertical scroll bar.
The float:left I replaced with align:left and then a margin-right in a style tag.

Bing Maps placemark drift when using an icon href for a placemark

My placemark icon, used via HREF from google mapfiles, seems to "drift" when I zoom out. In this example the placemark can make it all the way up to Norway.
It seems that Bing maps V8 doesn't support the kml which supposedly could help the icon to understand where its center is so that it would stay anchored in the map during zooming out. Additionally, the placemark is ignoring the color style. If I remove the everything between the tags and just use the default placemark from Bing, the colors and zoom work correctly. Do any of you know of a way to get this Google icon to stay anchored via KML in Bingmaps? My current workaround is simply not to use the Google icon, and instead use the default Bing maps icon, which works. Using code to do it on the bingmaps object would require too much refactoring at this time.
You can use the Bing "drag and drop" here with my code to see the problem - just paste the KML below into the "XML Panel" and click "Read XML". Then zoom out to see the placemark go traveling. If you remove the whole node, the zoom and colors work (but with the default icon).
https://bingmapsv8samples.azurewebsites.net/#GeoXml%20-%20Drag%20and%20Drop
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Style id="model_normal">
<IconStyle>
<color>FF00FF00</color>
<scale>1</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png</href>
</Icon>
<hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction" />
</IconStyle>
<LabelStyle>
<color>0000FF00</color>
</LabelStyle>
<LineStyle>
<color>7F00FF00</color>
<width>3</width>
</LineStyle>
<PolyStyle>
<fill>1</fill>
<color>7F00FF00</color>
</PolyStyle>
</Style>
<Placemark>
<name>Example placemark</name>
<description></description>
<visibility>1</visibility>
<styleUrl>#model_normal</styleUrl>
<MultiGeometry>
<Point>
<coordinates>7.003930,53.361905</coordinates>
</Point>
</MultiGeometry>
</Placemark>
</kml>
The anchor format that Bing Maps expect is in pixels, so you can update the hotSpot in IconStyle to:
<hotSpot x="32" y="32" xunits="pixels" yunits="pixels" />
By default custom pushpins on Bing Maps are anchored at bottom center - that's why the "shifting" is observed.

Aframe - Setting opacity to `a-sky` element does not work

I have two overlapping a-sky elements. Second one is positioned at z=-1000 (not visible to camera). In this setup if I set opacity of first a-sky element to 0.5, I should see second a-sky element.
Following code does not work. (Need to make this work.)
skyEl.getObject3D("mesh").material= new THREE.MeshBasicMaterial({
map: new THREE.TextureLoader().load("image url"),
transparent: true,
opacity: 0.5
});
But this method works.
skyEl.setAttribute('src','image url');
skyEl.getObject3D("mesh").material.transparent = true;
skyEl.getObject3D("mesh").material.opacity= 0.5;
In my project I can't set src attribute because textures are already loaded and I can only create material from preloaded texture. I need to know what's wrong with first method and how to fix it. Is there some other parameter I need to set
Also tried using a-sphere instead of a-sky but same result.
DEMO: https://codesandbox.io/s/qx6zj247l6 (Covers both cases and please ignore all react & tween stuff.)
PS: Creating a crossfade + zoom scene transition effect.
Getting the correct render order for transparency to work as intended is difficult. From the material component documentation page:
Transparency Issues
Transparency and alpha channels are tricky in 3D graphics. If you are having issues where transparent materials in the foreground do not composite correctly over materials in the background, the issues are probably due to underlying design of the OpenGL compositor (which WebGL is an API for).
In an ideal scenario, transparency in A-Frame would “just work”, regardless of where the developer places an entity in 3D space, or in which order they define the elements in markup. We can often run into scenarios where foreground entities occlude background entities. This creates confusion and unwanted visual defects.
To work around this issue, try changing the order of the entities in the HTML.
To resolve your case, simply place #sky1 after #sky2 in the HTML:
render() {
return (
<Scene>
<Entity id="sky2-wrapper" rotation="0 90 0">
<Entity id="sky2" primitive="a-sky" position="0 0 -1000" />
</Entity>
<Entity id="sky1" primitive="a-sky" opacity="1" />
<Entity
camera={{
far: 10000,
fov: 80,
near: 0.05,
active: true
}}
id="cam"
rotation="0 90 0"
mouse-cursor
look-controls="reverseMouseDrag:true"
/>
</Scene>
);
}

Points in KML with custom icon suddenly not displaying in KMLLayer (but Linestrings do)

This code worked perfectly until a short time ago. The KML and the Javascript certainly haven't changed so I'm imagining I have some issue in the KML which a Google update now doesn't like.
I have a Google Maps API implementation which simply loads a KML file into a KMLLayer on a map. Now, I get the Linestrings displaying but not the points.
Here is the relevant snippets from the KML.
<Style id="start">
<IconStyle>
<scale>0.0</scale>
<heading>0.0</heading>
<Icon>
<href>http://d1b3rm3ifop01h.cloudfront.net/mapicons/start-race-2.png</href>
<refreshInterval>0.0</refreshInterval>
<viewRefreshTime>0.0</viewRefreshTime>
<viewBoundScale>0.0</viewBoundScale>
</Icon>
</IconStyle>
</Style>
...
<Placemark>
<name>Baden Powell Horseshoe Bay Trailhead</name>
<description>Elevation: 54.9 m (180.2 ft)<br />Very small carpark only accessible travelling north.<br /><a href="http://www.trailhunger.com/junction/820">Junction Information</a></description>
<styleUrl>#start</styleUrl>
<Point>
<coordinates>-123.2749314141,49.3669179082,54.93</coordinates>
</Point>
</Placemark>
The problem was that the scale element was set to 0.0 and Google very recently changed their Google Maps KML parser to honour the scale element. Setting it to 1.0 made the icons appear.
0.0 is the default for the de.micromata.opengis.kml libary I'm using.
The next problem was that the icons were appearing in the wrong position. This was because I needed the hotSpot element to be specified.
This answer was provided by geocodezip#gmail.com on the Google Maps API issue I raised.

Should I use PurePDF or AlivePdf

My company has only two flex pdf libraries available, AlivePDF and PurePDF.
I am having trouble finding very good documentation related to what I need to do so I hope to get some feedback from people who have used these libs.
The primary thing I need to do is paste a group of DisplayObjects into a pdf, with decent quality of the image. I had used org.alivepdf.pdf.PDF.addImage(..) function before but the image quality was very poor and somehow the process cropped off parts of the image, making it unusable.
Here is an example of something that might need to be pasted into a pdf:
<s:HGroup id="imageGroup">
<s:Label text="Chart Title" />
<mx:Legend dataProvider="myChart" />
<mx:LineChart id="myChart">
<!-- do chart stuff here -->
</mx:LineChart>
</s:HGroup>
PDF.addImage() generates low resolution graphics. For higher quality, use this instead:
take a snapshot of the image group using ImageSnapshot.captureImage(), setting the dpi to 300
add the resulting bytearray to the PDF using addImageStream()
I have used AlivePDF for a while. There are a few quirks and the documentation is sparse, but this is workable and the results are great.

Resources