Anlık arama yapın
<?php //arazi.php içeriği set_time_limit(0); header('Content-Type: text/html; charset=utf-8'); if(!file_exists("cache")){mkdir("cache", 0777);} function iller(){ if(!file_exists("cache/iller.json")){ $il=file_get_contents("http://cbsservis.tkgm.gov.tr/megsiswebapi.v2/api/idariYapi/ilListe"); file_put_contents("cache/iller.json",$il); }else{ $il=file_get_contents("cache/iller.json"); } $il=json_decode($il,true); $iller=null; foreach($il["features"] as $il){ $iller[]=$il["properties"]; } return $iller; } if(isset($_POST["il"])){ if(!file_exists("cache/".$_POST["il"].".json")){ $ilce=file_get_contents("http://cbsservis.tkgm.gov.tr/megsiswebapi.v2/api/idariYapi/ilceListe/".$_POST["il"]); file_put_contents("cache/".$_POST["il"].".json",$ilce); }else{ $ilce=file_get_contents("cache/".$_POST["il"].".json"); } $ilce=json_decode($ilce,true); $ilceler=null; echo '<select id="ilce" class="form-control">'; echo '<option>Seçiniz</option>'; foreach($ilce["features"] as $ilce){ echo '<option value="'.$ilce["properties"]["id"].'">'.$ilce["properties"]["text"].'</option>'; } echo '</select>'; echo '<script type="text/javascript"> $(document).ready(function() { $("#sonuc").html("Seçmeye Devam Ediniz..."); $("#ilce").bind("change",function(){ if($("#ilce").val() != 0){ var ilce=$("#ilce option:selected").val(); var ilcetext=$("#ilce option:selected").text(); $.ajax({ type: "POST", url: "arazi.php", data: "ilce="+ilce, dataType: "html", beforeSend: function() { $("#ilce").after("<label id=\"ilce\" class=\"bg-secondary text-white form-control\">"+ilcetext+"</label>"); $("#ilce").remove(); }, success: function(data) { $("#ilce").after(data); } }); } }); }); </script>'; }elseif(isset($_POST["ilce"])){ if(!file_exists("cache/".$_POST["ilce"].".json")){ $mahalle=file_get_contents("http://cbsservis.tkgm.gov.tr/megsiswebapi.v2/api/idariYapi/mahalleListe/".$_POST["ilce"]); file_put_contents("cache/".$_POST["ilce"].".json",$mahalle); }else{ $mahalle=file_get_contents("cache/".$_POST["ilce"].".json"); } $mahalle=json_decode($mahalle,true); $mahalleler=null; echo '<select id="mahalle" class="form-control">'; echo '<option>Seçiniz</option>'; foreach($mahalle["features"] as $mahalle){ echo '<option value="'.$mahalle["properties"]["id"].'">'.$mahalle["properties"]["text"].'</option>'; } echo '</select>'; echo '<script type="text/javascript"> $(document).ready(function() { $("#sonuc").html("Seçmeye Devam Ediniz..."); $("#mahalle").bind("change",function(){ if($("#mahalle").val() != 0){ var mahalle=$("#mahalle option:selected").val(); var mahalletext=$("#mahalle option:selected").text(); $.ajax({ type: "POST", url: "arazi.php", data: "mahalle="+mahalle, dataType: "html", beforeSend: function() { $("#mahalle").after("<label id=\"mahalle\" class=\"bg-secondary text-white form-control\">"+mahalletext+"</label>"); $("#mahalle").remove(); }, success: function(data) { $("#mahalle").after(data); } }); } }); }); </script>'; }elseif(isset($_POST["mahalle"])){ echo '<input type="number" id="ada" class="form-control" placeholder="Ada">'; echo '<input type="number" id="parsel" class="form-control" placeholder="Parsel">'; echo '<script type="text/javascript"> $(document).ready(function() { $("#sonuc").html("Ada ve Parsel Bilgisi Giriniz..."); $("#ada,#parsel").on("input",function(){ var ada=$("#ada").val(); var parsel=$("#parsel").val(); if(ada > 0 && parsel > 0){ var mahalle='.$_POST["mahalle"].'; $.ajax({ type: "POST", url: "arazi.php", data: "veri="+mahalle+"/"+ada+"/"+parsel, dataType: "html", beforeSend: function() { $("#sonuc").html("Sorgulanıyor..."); }, success: function(data) { $("#sonuc").html(data); } }); } }); }); </script>'; }elseif(isset($_POST["veri"])){ if(!file_exists("cache/".str_replace("/","-",$_POST["veri"]).".json")){ $parsel=file_get_contents("http://cbsservis.tkgm.gov.tr/megsiswebapi.v2/api/parsel/".$_POST["veri"]); file_put_contents("cache/".str_replace("/","-",$_POST["veri"]).".json",$parsel); }else{ $parsel=file_get_contents("cache/".str_replace("/","-",$_POST["veri"]).".json"); } $parsel=json_decode($parsel,true); if($parsel["properties"]){ foreach($parsel["properties"] as $title=>$key){ echo '<label class="bg-success text-white form-control">'.ucfirst($title)." : ".$key."</label>"; } }else{ echo '<label class="bg-danger text-white form-control">Sonuç Bulunamadı</label>"; } } /* ada 1 parsel 2 https://cbsservis.tkgm.gov.tr/megsiswebapi.v2/api/idariYapi/mahalleListe/648 ada 5 parsel 3 https://cbsservis.tkgm.gov.tr/megsiswebapi.v2/api/parsel/144808/5/3 */ ?>