<?='<?xml version="1.0" encoding="UTF-8"?>'?>
<kml xmlns="http://www.opengis.net/kml/2.2"> 
<Document>
	<name>Croqui Georreferenciado</name>

    <!-- definicao do estilo do quadra -->
    <Style id="s_ylw-pushpin">
		<IconStyle>
			<scale>1.1</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
		<LineStyle>
			<color>ff00ff00</color>
			<width>3</width>
		</LineStyle>
		<PolyStyle>
			<color>a641aa22</color>
		</PolyStyle>
	</Style>
	
	<StyleMap id="m_ylw-pushpin">
		<Pair>
			<key>normal</key>
			<styleUrl>#s_ylw-pushpin</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#s_ylw-pushpin_hl0</styleUrl>
		</Pair>
	</StyleMap>
	
	<Style id="s_ylw-pushpin_hl0">
		<IconStyle>
			<scale>1.3</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
		<LineStyle>
			<color>ff00ff00</color>
			<width>3</width>
		</LineStyle>
		<PolyStyle>
			<color>a641aa22</color>
		</PolyStyle>
	</Style>

    <!-- definicicao do estilo do label (pin) -->
	<Style id="hl">
		<IconStyle>
			<Icon>
			</Icon>
		</IconStyle>
		<ListStyle>
		</ListStyle>
	</Style>
	<StyleMap id="default">
		<Pair>
			<key>normal</key>
			<styleUrl>#default0</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#hl</styleUrl>
		</Pair>
	</StyleMap>
	<Style id="default0">
		<IconStyle>
			<Icon>
			</Icon>
		</IconStyle>
		<ListStyle>
		</ListStyle>
	</Style>

	<? foreach ($this->croqui as $quadra): ?>
		<Placemark>
			<name><?=$quadra['info']?></name>
			<styleUrl>#default</styleUrl>
			<Point>
				<gx:drawOrder>1</gx:drawOrder>
				<coordinates>
					<?=$quadra['pin'][0]['longitude'].','.$quadra['pin'][0]['latitude']?>
				</coordinates>
			</Point>
		</Placemark>

		<Placemark>
			<styleUrl>#m_ylw-pushpin</styleUrl>
			<Polygon>
				<tessellate>1</tessellate>
				<outerBoundaryIs>
					<LinearRing>
						<coordinates>
							<? foreach ($quadra['coords'] as $coords): ?>
								<?=$coords['longitude'].','.$coords['latitude'].",0\n"?>
							<? endforeach; ?>
							<?=$quadra['coords'][0]['longitude'].','.$quadra['coords'][0]['latitude'].",0\n"?>
						</coordinates>
					</LinearRing>
				</outerBoundaryIs>
			</Polygon>
		</Placemark>
	<? endforeach; ?>
</Document>
</kml>