<?php use_javascript('https://maps.google.com/maps?file=api&amp;v=2&amp;key=' . sfConfig::get('app_gmap') . '&sensor=true'); ?>
<div class="content-add01">
	<br /><div class="heading01"><h1><?php echo $node->getTitle($culture); ?></h1></div>

<?php

$criteria = new Criteria();
$criteria->addAscendingOrderByColumn(KataoNodePeer::CITY);
$nodes = KataoNodePeer::doSelect($criteria);

?>

	<div id="map_canvas" style="width: 385px; height: 300px"></div>

	<br />
	<div class="filter">
		<div class="filter-left">&nbsp;</div>
		<div class="filter-middle">
			<u>Légende</u> :
			&nbsp;<?php echo image_tag('https://maps.google.com/mapfiles/ms/micons/red-dot.png', array('alt' => '', 'align' => 'top', 'width' => 20, 'height' => 20)) ?> Adhérents
			&nbsp;-&nbsp;<?php echo image_tag('https://maps.google.com/mapfiles/ms/micons/blue-dot.png', array('alt' => '', 'align' => 'top', 'width' => 20, 'height' => 20)) ?> Délégués
			&nbsp;-&nbsp;<?php echo image_tag('https://maps.google.com/mapfiles/ms/micons/green-dot.png', array('alt' => '', 'align' => 'top', 'width' => 20, 'height' => 20)) ?> Partenaires
		</div>
		<div class="filter-right">&nbsp;</div>
	</div>

	<p><a href="javascript://" onclick="javascript:window.open('<?php echo $ContentTree->getCurrentNode()->getUrl() ?>?popup', 'NetworkPopup', 'status=0,toolbar=0,height=720,width=750,scrollbars=yes')">Voir le réseau en détail &raquo;</a></p>

	<?php echo CatalyzTextFilter::renderLinksToNodes($page->getIntroduction($culture)); ?>

<script type="text/javascript" language="JavaScript">
/* <![CDATA[ */

window.onload = function(){
 if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
		map.setCenter(new GLatLng(45, 3), 6);
        map.setUIToDefault();

		var myIconRed = new GIcon(G_DEFAULT_ICON);
		myIconRed.iconSize = new GSize(32, 32);
		myIconRed.image = 'https://maps.google.com/mapfiles/ms/micons/red-dot.png';
		var markerOptionsRed = { icon: myIconRed};

		var myIconGreen = new GIcon(G_DEFAULT_ICON);
		myIconGreen.iconSize = new GSize(32, 32);
		myIconGreen.image = 'https://maps.google.com/mapfiles/ms/micons/green-dot.png';
		var markerOptionsGreen = { icon: myIconGreen};

		var myIconBlue = new GIcon(G_DEFAULT_ICON);
		myIconBlue.iconSize = new GSize(32, 32);
		myIconBlue.image = 'https://maps.google.com/mapfiles/ms/micons/blue-dot.png';
		var markerOptionsBlue = { icon: myIconBlue};

<?php

$criteria = new Criteria();
$criteria->add(KataoUserPeer::GMAP_LAT, '', Criteria::NOT_EQUAL);
$criteria->add(KataoUserPeer::GMAP_LNG, '', Criteria::NOT_EQUAL);
$criteria->addJoin(KataoUserPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
if (null != $katao_node = $sf_user->getActiveNode()) {
	$criteria->add(KataoMemberPeer::KATAO_NODE_ID, $katao_node->getId());
}
$members = KataoUserPeer::doSelectJoinKataoMember($criteria);
// var_dump($members);
foreach($members as/*(KataoUser)*/ $member):
?>
	var markerM<?php echo $member->getId(); ?> = new GMarker(new GLatLng(<?php printf('%f,%f', $member->getGmapLat(), $member->getGmapLng()); ?>), <?php echo (0 < $member->countKataoNodes())?'markerOptionsBlue':'markerOptionsRed' ?>);
	GEvent.addListener(markerM<?php echo $member->getId(); ?>, "click", function() {
		markerM<?php echo $member->getId(); ?>.openInfoWindowHtml('<?php echo str_replace(array("\r\n", "\n", "\r"), array('\n', '\n', ''), get_partial('katao/gmap_member', array('member' => $member))); ?>');
	});
	map.addOverlay(markerM<?php echo $member->getId(); ?>);
<?php
endforeach;

foreach (KataoSupplierPeer::retrieveByPKs(array_keys(KataoSupplierPeer::getAllVisible())) as $katao_supplier):
	$supplier = $katao_supplier->getFirstKataoUser();
	if (KataoUser::STATUS_ACTIVE == $supplier->getStatus()) {
?>
	var markerS<?php echo $supplier->getId(); ?> = new GMarker(new GLatLng(<?php printf('%f,%f', $katao_supplier->getGmapLat(), $katao_supplier->getGmapLng()); ?>), markerOptionsGreen);
	GEvent.addListener(markerS<?php echo $supplier->getId(); ?>, "click", function() {
		markerS<?php echo $supplier->getId(); ?>.openInfoWindowHtml('<?php echo str_replace(array("\r\n", "\n", "\r"), array('\n', '\n', ''), get_partial('katao/gmap_supplier', array('supplier' => $supplier, 'popup' => false))); ?>');
	});
	map.addOverlay(markerS<?php echo $supplier->getId(); ?>);
<?php
	}
endforeach;

?>
      }
}

window.onunload = GUnload;

/* ]]> */
</script>

</div>