Veritabanından tesisleri çekiyorsunuz ya dizi yani array olarak. Bir tane çekmiyorsunuz sonuçta hepsini çekiyorsunuz. Bu çektiğiniz veriler tesisleri tutan dizi yani array de duruyor ve siz döngü ile teker teker yazdıracaksınız.
Aslında daha iyi yardımcı olmak için kodun önceki kısmını da görmek lazım.
Tesisleri databaseden çekiyorum (dosyanın en başında)
mysql_select_db($database_Veritabani, $Veritabani);
$query_tesisler = "SELECT TesisAdi, TesisFoto, TesisKoordinat FROM tesisler";
$tesisler = mysql_query($query_tesisler, $Veritabani) or die(mysql_error());
$row_tesisler = mysql_fetch_assoc($tesisler);
$totalRows_tesisler = mysql_num_rows($tesisler);
Maps Kodları aşağıdaki gibi.
<div class="box-body" id="map" style='height:500px;'>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDT8bees3OGXi7sh588Ssh_Bo">
</script>
<script>
function initialize() {
//map options
var mapOptions = {
zoom: 6,
center: new google.maps.LatLng(39, 35),
disableDefaultUI: true
};
// Get the HTML DOM element that will contain the map
var mapElement = document.getElementById('map');
// create map using element and options defined above
var map = new google.maps.Map(mapElement, mapOptions);
setMarkers(map, officeLocations);
}
var officeLocations = [
['<?php echo $row_tesisler['TesisAdi']; ?>', <?php echo $row_tesisler['TesisKoordinat']; ?>, '<?php echo $row_tesisler['TesisFoto']; ?>'],
];
//set and place the markers
function setMarkers(map, locations)
{
//set global pin image
var globalPin = 'assets/img/pin.png';
for (var i = 0; i < locations.length; i++) {
var office = locations[i];
var myLatLng = new google.maps.LatLng(office[1], office[2]);
var infowindow = new google.maps.InfoWindow({content: contentString});
var contentString =
'<div>'+
'<div>'+
'</div><strong>'+
office[0] +
'</strong><div>'+
'<br><img src="upload/foto/'+office[3]+'" width="150px">'+
'</div>'+
'</div>';
var image = {
url: 'images/location_map.png',
size: new google.maps.Size(30, 30),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(10, 30)
};
var marker = new google.maps.Marker({
position: myLatLng,
icon: image,
map: map,
title: office[0],
});
google.maps.event.addListener(marker, 'click', getInfoCallback(map, contentString));
}
}
function getInfoCallback(map, content) {
var infowindow = new google.maps.InfoWindow({content: content});
return function() {
infowindow.setContent(content);
infowindow.open(map, this);
};
}
initialize();
</script>İstersen dosyanın tamamını da yüklerim.