<?php
// Varsayılan koordinat (İstanbul)
$defaultLatLng = "41.015137,28.979530";

// Koordinatı seç, boşsa varsayılanı kullan
if(!empty($jsl["koordinat"])) {
    $LatLng = $jsl["koordinat"];
    $firstHeading = $rs["t1"];
    $adres = $jsl["adres"];
} else {
    $LatLng = !empty($firm["fmap"]) ? $firm["fmap"] : $defaultLatLng;
    $firstHeading = $firma;
    $adres = $firm["fadres"];
}

// Harita scripti
$gmap = "
<script async defer src=\"https://maps.googleapis.com/maps/api/js?key=AIzaSyAA-Wc9Lyfe2z8R4pgH1rWeHXrdw9ixud8&callback=initMap\"></script>
<script>
function initMap(){
    var myLatlng = new google.maps.LatLng(".$LatLng.");
    var map = new google.maps.Map(document.getElementById('map_canvas'), {
        zoom: 16,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var contentString = '<div id=\"content\"><h4>".$firstHeading."</h4><p>".$adres."</p></div>';
    var infowindow = new google.maps.InfoWindow({ content: contentString });
    var marker = new google.maps.Marker({ position: myLatlng, map: map, title: '".$firstHeading."' });

    marker.addListener('click', function(){ infowindow.open(map, marker); });
}
</script>
<div id=\"map_canvas\" style=\"width:100%; min-height:350px;\"></div>
";

echo $gmap;
?>