Javascript 显示同一地址位置上的多个标记

Javascript 显示同一地址位置上的多个标记,javascript,jquery,ajax,google-maps,google-maps-api-3,Javascript,Jquery,Ajax,Google Maps,Google Maps Api 3,我创建了一个应用程序来显示多个带有产品作业和服务的标记。现在,若谷歌地图上的地址是相同的,那个么只有一个标记出现,尽管很多产品可能在同一个地方。所以我想知道多少次呼叫地址,多少标记通过同一个位置 url = 'http://maps.googleapis.com/maps/api/geocode/json?address='+json[i].DisType+'&sensor=false', $.getJSON(url, null, function (data) { var p

我创建了一个应用程序来显示多个带有产品作业和服务的标记。现在,若谷歌地图上的地址是相同的,那个么只有一个标记出现,尽管很多产品可能在同一个地方。所以我想知道多少次呼叫地址,多少标记通过同一个位置

url = 'http://maps.googleapis.com/maps/api/geocode/json?address='+json[i].DisType+'&sensor=false',

$.getJSON(url, null, function (data)
{
    var p = data.results[0].geometry.location
    var latlng = new google.maps.LatLng(p.lat, p.lng);
    var marker= new google.maps.Marker({
      position: latlng,
      map: map
    });
    google.maps.event.addListener(marker, 'click', (function(marker, i)
    {
        return function() 
        {
            infowindow.setContent(r);
            infowindow.open(map, marker);
        }
    })(marker, i));
});

您需要在响应中循环
var p=data.results[0].geometry.location
您只创建响应中第一项的标记

var item;
for(item in data.results){
    var p = item.geometry.location
    var latlng = new google.maps.LatLng(p.lat, p.lng);
    var marker= new google.maps.Marker({
      position: latlng,
      map: map
    });
    google.maps.event.addListener(marker, 'click', (function(marker, i)
    {
        return function() 
        {
            infowindow.setContent(r);
            infowindow.open(map, marker);
        }
    })(marker, i));
}

213 Al Sinyar Street-迪拜-阿拉伯联合酋长国产品。html:1614 293 Al Satwa路-迪拜-阿拉伯联合酋长国产品。html:1614迪拜硅绿洲-迪拜-阿拉伯联合酋长国产品。html:1614 Tecom-Al Barsha-迪拜-阿拉伯联合酋长国产品。html:1614珍珠朱美拉-迪拜-阿拉伯联合酋长国产品。html:1614非洲菊苑-绿色社区村-迪拜-阿拉伯联合酋长国产品。html:1614 FERTIL-Ruwais-阿拉伯联合酋长国我将该地址传递到address.where Dubai silicon oasis 3次