在Google地图信息窗口中显示超过1450个标记

时间:2013-07-10 02:22:15

标签: google-maps google-maps-markers infowindow

我已经使用googlemaps制作了一些GIS网页。但我遇到了一些麻烦。我必须显示大约1500 - 2500标记并且有onowindows onclick。 2天前,一切都很好,但是当我在infowindows中添加更多细节时(之前只有4个详细信息,如姓名,地址等,现在有9个详细信息),标记没有出现。我正在使用Json消息函数从数据库中获取值并显示在infowindows中。如果它是1450个标记,它可以正常工作,但是当标记不止于此时,标记不会显示在地图上。内存缓存或cookie问题?请帮忙。谢谢。我正在使用googlechrome,Postgre数据库,PHP和googlemaps api v3。

<?php  
require ('config.php');
$rayon = $_POST['rayon'];
$cabang = $_POST['org_id'];
//echo "$rayon, $cabang, $rayonhasil";
$sql = "SELECT distinct org_id, cp_customer_site_use_id, customer_name, address, postal_code, city, cp_rayon_name, icon_rayon, attribute16, attribute17 FROM hasilgis";
$data = pg_query($sql);
$json = '{"enseval": {';
$json .= '"customer":[ ';
while($x = pg_fetch_array($data)){
    $json .= '{';
    $json .= '"id_customer":"'.$x['org_id'].'",
        "id_photo":"'.$x['cp_customer_site_use_id'].'",
        "postal_code":"'.$x['postal_code'].'",
        "nama_customer":"'.htmlspecialchars($x['customer_name']).'",
        "city":"'.htmlspecialchars($x['city']).'",
        "address":"'.htmlspecialchars($x['address']).'",
        "nama_rayon":"'.htmlspecialchars($x['cp_rayon_name']).'",
        "icon":"'.$x['icon_rayon'].'",
        "x":"'.$x['attribute16'].'",
        "y":"'.$x['attribute17'].'"
    },';
}
$json = substr($json,0,strlen($json)-1);
$json .= ']';
$json .= '}}';

echo $json;
?>

<script type="text/javascript">
    function initialize(){
    var peta;
    var x = new Array();
    var y = new Array();
    var customer_name = new Array();
    var cp_rayon_name = new Array();
    var icon = new Array();
    var photo = new Array();
    var city = new Array();
    var address = new Array();
    var postal_code = new Array();
    // posisi default peta saat diload
    var lokasibaru = new google.maps.LatLng( -1.2653859,116.83119999999997);
    var petaoption = {
        zoom: 5,
        center: lokasibaru,
        mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        peta = new google.maps.Map(document.getElementById("map_canvas"),petaoption);
        var infowindow =  new google.maps.InfoWindow({
                      content: ''
        });
    // memanggil function untuk menampilkan koordinat
        url = "json.php";
        $.ajax({
        url: url,
        dataType: 'json',
        cache: false,
        success: function(msg){
            for(i=0;i<msg.enseval.customer.length;i++){
                x[i] = msg.enseval.customer[i].x;
                y[i] = msg.enseval.customer[i].y;
                customer_name[i] = msg.enseval.customer[i].nama_customer;
                cp_rayon_name[i] = msg.enseval.customer[i].nama_rayon;
                icon[i] = msg.enseval.customer[i].icon;
                photo[i] = msg.enseval.customer[i].id_photo;
                city[i] = msg.enseval.customer[i].city;
                address[i] = msg.enseval.customer[i].address;
                postal_code[i] = msg.enseval.customer[i].postal_code;
                var point = new google.maps.LatLng(parseFloat(msg.enseval.customer[i].x),parseFloat(msg.enseval.customer[i].y));
                var gambar_tanda = 'assets/images/'+msg.enseval.customer[i].icon+'.png';
                var photo_cust = '<img src="assets/images/foto_cust/'+msg.enseval.customer[i].id_photo+'_1.jpg" style="width:200px;height:120px;"/>';
                //var nm_cust = msg.enseval.customer[i].nama_customer;
                //var nm_rayon = , msg.enseval.customer[i].nama_rayon;
                var html = '<b>' + customer_name[i] + '</b><br/>'+city[i]+ ', '+address[i]+', '+postal_code[i]+'<br/>' + cp_rayon_name[i] + '<br/>' + photo_cust;
                tanda = new google.maps.Marker({
                            position: point,
                            map: peta,
                            icon: gambar_tanda,
                            clickable: true
                });
            bindInfoWindow(tanda, peta, infowindow, html  );
            }
        }
        });
}
google.maps.event.addDomListener(window, 'load', initialize);
function bindInfoWindow(tanda, peta, infowindow, data) {
    google.maps.event.addListener(tanda, 'click', function() {
    infowindow.setContent(data);
    infowindow.open(peta, tanda);
    });
}
function reload(form){
    var val=form.org_id.options[form.org_id.options.selectedIndex].value;
    self.location='main_page.php?cabang=' + val ;
}
</script>
    <!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<div id="wrapper"><!-- #wrapper -->
    <header><!-- header -->
        <br><br><br>
        <h1></h1>
    </header><!-- end of header -->

    <section id="main"><!-- #main content area -->
<div id="map_canvas" style=" align: left; width:1000px; height:500px"></div><br>
<?php require ('config.php'); 
    @$cabang=$_GET['cabang'];
    /*if(strlen($cabang) > 0 and !is_numeric($cabang)){ 
    echo "Data Error";
    exit;
    }*/
    $quer2=pg_query("SELECT DISTINCT orgid FROM epmgis order by orgid");
    if(isset($cabang) and strlen($cabang)){
        $quer=pg_query("SELECT DISTINCT nm_rayon FROM epmgis where orgid=$cabang order by nm_rayon"); 
    }
    else{$quer=pg_query("SELECT DISTINCT nm_rayon FROM epmgis order by nm_rayon"); }
        echo"<table>";
            echo"<tr>";
        echo "<form method=post name=f1 action='proses_map.php'>";
        echo " <td>Silahkan Pilih Kode Cabang </td><td>:</td><td><select name='org_id' onchange=\"reload(this.form)\"><option value=''></option>";
            while($noticia2 = pg_fetch_array($quer2)) { 
                if($noticia2['orgid']==@$cabang){echo "<option selected value='$noticia2[orgid]'>$noticia2[orgid]</option>"."<BR>";}
                    else{echo  "<option value='$noticia2[orgid]'>$noticia2[orgid]</option>";}
                }
                    echo "</select></td></tr>";
                    echo"<br>";
                    echo "<tr><td>Silahkan Pilih Rayon</td><td>:</td><td><select name='rayon'><option value=''></option>";
            while($noticia = pg_fetch_array($quer)) { 
                    echo  "<option value='$noticia[nm_rayon]'>$noticia[nm_rayon]</option>";
            }
                    echo "</select></td></tr>";
                    echo "<tr><td><input type=submit value=Submit>";
                    echo "</form>";
        echo"</td></tr>";
        echo"</table>";
?>

0 个答案:

没有答案