2013-07-03 78 views
-1

在jquery中使用gmap [jQuery FN Google Map 3.0-rc]我试图通过从当前位置显示标记来搜索多个位置?怎么做? 如下搜索字符串的代码只给出一个结果,而谷歌地图给出了很多标记。附近位置搜索gmap jquery

代码:

navigator.geolocation.getCurrentPosition (function(position) {   
var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 
//console.log(clientPosition); 
$('#map_canvas').gmap({'center': clientPosition, 'zoom': 10, 'disableDefaultUI':true, 'callback': function() {   
      var self = this;   
      self.search({'address' : 'SBI Bank, Bangalore, Karnataka, India'},function(results,status){ 
       if(status == 'OK') 
       { 
        console.log(results); 
        self.addMarker({ 'position': results[0].geometry.location}, function(map,marker){ 
         console.log('Inside marker'); 
        }); 
       }       
      }); 
     }}); 
}); 
+0

有人可以帮忙吗? – vinod

回答

0

有没有关于它的神秘,只是重复:

self.search({'address' : 'SBI Bank, Bangalore, Karnataka, India'},function(results,status){ 
       if(status == 'OK') 
       { 
        console.log(results); 
        self.addMarker({ 'position': results[0].geometry.location}, function(map,marker){ 
         console.log('Inside marker'); 
        }); 
       }       
      }); 

的次数,只改变地址搜索。如果你愿意,你可以把这个结构放到一个循环中。

0

谢谢Walter。但是,最好的办法是使用谷歌API “https://maps.googleapis.com/maps/api/place/search/xml?location=‘+经纬度+’&半径= 10000 &类型=” +检索类别+” &传感器=假&名= ABC &键= AIzaSyA8NKZp03E7Nk0P39nj9nrckPdvqYL38Y4' 的返回结果XML或JSON [更改地方/搜索/ XML的地方/搜索/ JSON],并从那我们可以添加标记