<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Seminarorte</title>
<style>
body, table, td{
font-family:Georgia, "Times New Roman", Times, serif;	
}
</style>
<!--<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

<?php

include_once "conect.php";
	
// STEP 2: Query the table with the marker information

$sql = "SELECT * FROM localitate";
$sql2 = "SELECT * FROM localitate WHERE seminarort='1'";
$rez=mysql_query($sql);
$rez2=mysql_query($sql2);
$lat=array();
$lng=array();
$inf=array();
$lata=array();
$lnga=array();
$infa=array();
	
// STEP 3: Store the marker info in arrays for each row found
// save the count of markers for later

$mrk_cnt = 0;
$mrk_cnta = 0;
while ($row = mysql_fetch_array($rez))  // get all rows (markers)
{	

    $lat[$mrk_cnt] = $row['lat'];  // save the lattitude
    $lng[$mrk_cnt] = $row['long'];  // save the longitude
	$idu=$row['id_loc'];
	$sql_scoli="SELECT * FROM scoala WHERE id_localitate='$idu' ORDER BY id_localitate, denumire_sc";
	$rez_scoli=mysql_query($sql_scoli);
  //$inf[$mrk_cnt] = "<table><tr><td><a href=go.php?idu=".$row['id'].">".$row['denumire'].", ".$row['localitate']."</a></td></tr>
	///<tr><td><img src=../arhin_privat/images/".$row['id']."/public/icon/1.jpg /></td></tr></table>"; 
	$inf[$mrk_cnt] = "<table><tr><td style=color:red>".$row['denumire_de']."/".$row['denumire_loc']."</td></tr>";
		while($row_scoli=mysql_fetch_array($rez_scoli)){
			$inf[$mrk_cnt].="<tr><td>".$row_scoli['denumire_sc']."</td></tr>";
		}
		$inf[$mrk_cnt].="</table>";
	// $inf[$mrk_cnt] = $row['id'].", ".$row['denumire'].", ".$row['localitate'];
	// save the info-window
 
// increment the marker counter
//echo $inf[$mrk_cnt]."<br />";
	// de la if ca sa am longitudini sau latitudini
$mrk_cnt++; 
}

 //print_r($inf);
// die();
while ($row2 = mysql_fetch_array($rez2))  // get all rows (markers)
{	

    $lata[$mrk_cnta] = $row2['lat'];  // save the lattitude
    $lnga[$mrk_cnta] = $row2['long'];  // save the longitude
	//$idu2=$row2['id_loc'];
	//$sql_scoli="SELECT * FROM scoala WHERE id_localitate='$idu' ORDER BY id_localitate, denumire_sc";
	//$rez_scoli=mysql_query($sql_scoli);
  //$inf[$mrk_cnt] = "<table><tr><td><a href=go.php?idu=".$row['id'].">".$row['denumire'].", ".$row['localitate']."</a></td></tr>
	///<tr><td><img src=../arhin_privat/images/".$row['id']."/public/icon/1.jpg /></td></tr></table>"; 
	$infa[$mrk_cnta] = "<table><tr><td style=color:red>".$row2['denumire_de']."/".$row2['denumire_loc']."</td></tr></table>";
		/*while($row_scoli=mysql_fetch_array($rez_scoli)){
			$inf[$mrk_cnt].="<tr><td>".$row_scoli['denumire_sc']."</td></tr>";
		}
		$inf[$mrk_cnt].="</table>";*/
	// $inf[$mrk_cnt] = $row['id'].", ".$row['denumire'].", ".$row['localitate'];
	// save the info-window
 
// increment the marker counter
//echo $inf[$mrk_cnt]."<br />";
	// de la if ca sa am longitudini sau latitudini
$mrk_cnta++; 
}
//die();
// Now we have the lattitude, longitude and info-window text for each marker 
// stored in php arrays. Now we need to write the marker's JavaScript 
// dynamically with this information
	
?>

<script type='text/javascript'>
var point;
var mrktx;
function incarca() {
   addTo = 0;
   var latlng = new google.maps.LatLng(45.797794, 24.150138);
   var myOptions = {
      zoom: 7,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
   };
   var latlnga = new google.maps.LatLng(45.797794, 24.150138);
   var myOptionsa = {
      zoom: 7,
      center: latlnga,
     mapTypeId: google.maps.MapTypeId.ROADMAP
   };
   //icon nou
   var image = new google.maps.MarkerImage('blau.png',
        new google.maps.Size(19, 30),
        new google.maps.Point(0,0),
        new google.maps.Point(9, 30)
    );
	   var image1 = new google.maps.MarkerImage('blau.png',
        new google.maps.Size(19, 30),
        new google.maps.Point(0,0),
        new google.maps.Point(9, 30)
    );

   
   // NOTE: all values: latitude, longitude, zoom, etc.
   //       should also come from the database for flexibility
       
   var map = new google.maps.Map(document.getElementById("map_canvas"), 
              myOptions);
      var mapa = new google.maps.Map(document.getElementById("map_canvas2"), 
              myOptionsa);
// This next block of JavaScript needs to be generated by PHP 
// to 'add-in' the information from the arrays

<?php
for ($lcnt = 0; $lcnt < $mrk_cnt; $lcnt++)
{ 
	if(($lat[$lcnt]!="0") && ($lng[$lcnt]!="0")){
		
    echo "var point$lcnt = new google.maps.LatLng($lat[$lcnt], $lng[$lcnt]);\n";
    echo "var mrktx$lcnt = '$inf[$lcnt]';\n";
	echo "var infowindow$lcnt = new google.maps.InfoWindow({
   			content: mrktx$lcnt
			});\n";
    echo "var marker$lcnt = new google.maps.Marker({position: point$lcnt, map: map,icon: image1});\n";
	echo "google.maps.event.addListener(marker$lcnt, 
         'click', function() {
   		     infowindow$lcnt.open(map,marker$lcnt);
          });\n";
	}
}


for ($lcnta = 0; $lcnta < $mrk_cnta; $lcnta++)
{ 
	if(($lata[$lcnta]!="0") && ($lnga[$lcnta]!="0")){
		
    echo "var pointa$lcnta = new google.maps.LatLng($lata[$lcnta], $lnga[$lcnta]);\n";
    echo "var mrktxa$lcnta = '$infa[$lcnta]';\n";
	echo "var infowindowa$lcnta = new google.maps.InfoWindow({
   			content: mrktxa$lcnta
			});\n";
    echo "var markera$lcnta = new google.maps.Marker({position: pointa$lcnta, map: mapa, icon: image});\n";
	echo "google.maps.event.addListener(markera$lcnta, 
         'click', function() {
   		     infowindowa$lcnta.open(mapa,markera$lcnta);
          });\n";
	}
}
?>
}
</script>
<script type="text/javascript">
//$(document).ready(function(){
    // Asynchronously Load the map API 
  //  var script = document.createElement('script');
  //  script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyDFoxWWqhBpHgke8KqKlvSK3WBGRPm8W9I&callback=incarca";
 //   document.body.appendChild(script);
//});</script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=AIzaSyDFoxWWqhBpHgke8KqKlvSK3WBGRPm8W9I&callback=incarca" async defer></script>

</head>

<body>
<h2 style="font-family:Georgia, 'Times New Roman', Times, serif; font-size:medium"> Ortschaften mit Unterrichtseinrichtungen in deutscher Sprache unterrichten</h2>
<p style="font-family:Georgia, 'Times New Roman', Times, serif; font-size:small">Für Schulnamen auf Marker klicken!</p>
<div id="map_canvas" style="width: 800px; height: 600px; margin: 0 auto;">
   </div>
 <h2 style="font-family:Georgia, 'Times New Roman', Times, serif; font-size:medium"> Seminarorte</h2>
<p style="font-family:Georgia, 'Times New Roman', Times, serif; font-size:small">2016-2017</p>
<div id="map_canvas2" style="width: 800px; height: 600px; margin: 0 auto;">
   </div>
</body>
</html>