2013-07-03 77 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],並從那我們可以添加標記