json вернул массив маркеров, указывающих на последние маркеры - PullRequest
0 голосов
/ 22 ноября 2011

что я делаю, так это то, что я размещаю несколько маркеров на карте, возвращенной из массива json, здесь мой code.my маркеры отображаются правильно, но когда я нажимаю на каждый маркер, он создает информационное окно одного маркера, который является последним маркероммассив

 function latLongCallback(latitutde,longitutde){
    var latlng = new google.maps.LatLng(latitutde, longitutde);
    var options = {zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP};
    var map = new google.maps.Map(document.getElementById('map'), options);
    $.ajax({type: "GET",
      dataType: 'json',
      url: "http://www.xyz.com/xcv/xainee/test/markers.php",
    success: function(response){
         var total=response.length;
       data_array,name,type,address,lat,lon,point,infowindow,marker,arrival,departure,notes;
         var icon_image = 'http://www.xyz.com/userftp/fawad/test/images/map-icon.png';


       for(var i=0; i < total; i++) 
       {
            data_array=response[i];
            name=data_array['name'];
            address=data_array['address'];
            arrival=data_array['arrival'];
            departure=data_array['departure'];
            notes=data_array['notes'];
            lat=data_array['lat'];
            lon=data_array['lon'];
         contentString ="Name : "+name+"<br/> Location : "+address+"<br/> Arrival :"+arrival+"<br/> Departure : "+departure+"<br/> Notes : "+notes;
            point = new google.maps.LatLng(lat,lon);

            infowindow = new google.maps.InfoWindow({content: contentString,maxWidth: 400,maxHeight: 201});

            marker = new google.maps.Marker({map: map,icon: icon_image, position: point});

            marker.setMap(map);
            google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker);});

       }
        }
    });
    return;
}

вот мой markers.php

     <?php session_start();
  include_once("database.php");
 $data=array();

      $retrive_marker_query = "SELECT fb_user.name,schedule.location,schedule.arrival,schedule.departure,schedule.notes,schedule.lat,schedule.lon FROM schedule,fb_user where fb_user.fb_id = schedule.fb_id";
     $result         =    db_execute($retrive_marker_query);
     $cnt=0;
   while ($row = @mysql_fetch_assoc($result)){
$name=$row['name'];
$address= $row['location'];
$arrival= $row['arrival'] ;
$departure= $row['departure'] ;
$notes= $row['notes'] ;
$lat= $row['lat'];
$lon= $row['lon'];

$data[$cnt]['name']=$name;
$data[$cnt]['address']=$address;
$data[$cnt]['arrival']=$arrival;
$data[$cnt]['departure']=$departure;
$data[$cnt]['notes']=$notes;
$data[$cnt]['lat']=$lat;
$data[$cnt]['lon']=$lon;

$cnt++;
 }
  $data=json_encode($data);
  echo($data);

 ?>

почему мой контент маркеров одинаков, хотя все маркеры отображаются в разных широтах и ​​долготах

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...