Reputation: 31
I need to display areas on the globe using rectangular polygons. However, as some of them are small, and when the globe is zoomed out they are nearly impossible to see. As a potential solution, I was thinking of putting an icon in the center of it as icons always stay the same size when zooming in and out.
I also have information that pops up in a balloon when I click on the polygon which I would want to carry over to clicking the icon too. I have everything working using two separate placemark objects (one is the polygon, the other is a point with the icon), but this requires making two copies of the balloon text. As there will be a large number of regions displayed and a lot of information in the balloons, having that appear twice in the file would make the files too big.
Is there any way to combine these into one object with the icon at the center of the polygon?
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2">
<Document>
<name>Area Box</name>
<open>1</open>
<Placemark>
<name>Area</name>
<Style>
<LineStyle>
<color>fff5f5f5</color>
<width>3</width>
</LineStyle>
<PolyStyle>
<color>aa00ffff</color>
</PolyStyle>
<BalloonStyle>
<text>
<![CDATA[Information Here]]>
</text>
</BalloonStyle>
</Style>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-105,40,0 -104.8,40,0 -104.8,39.8,0 -105,39.8,0 -105,40,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
<Placemark>
<name>Icon</name>
<Style>
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal5/icon11.png</href>
</Icon>
</IconStyle>
<BalloonStyle>
<text>
<![CDATA[Information Here]]>
</text>
</BalloonStyle>
</Style>
<Point>
<coordinates>
-104.9,39.9,0
</coordinates>
</Point>
</Placemark>
</Document>
Upvotes: 3
Views: 1780
Reputation: 161334
Use a MultiGeometry
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2">
<Document>
<name>Area Box</name>
<open>1</open>
<Placemark>
<name>Area</name>
<Style>
<LineStyle>
<color>fff5f5f5</color>
<width>3</width>
</LineStyle>
<PolyStyle>
<color>aa00ffff</color>
</PolyStyle>
<BalloonStyle>
<text>
<![CDATA[Information Here]]>
</text>
</BalloonStyle>
</Style>
<MultiGeometry>
<Point>
<coordinates>
-104.9,39.9,0
</coordinates>
</Point>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-105,40,0 -104.8,40,0 -104.8,39.8,0 -105,39.8,0 -105,40,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</MultiGeometry>
</Placemark>
Upvotes: 3