1
我試圖讓一個算法,只顯示在一個給定的半徑這個標記是我的代碼:僅顯示在給定的半徑標記
for(i = 0; i < markers.length; i++) {
d = google.maps.geometry.spherical.computeDistanceBetween(
new google.maps.LatLng(user_logged_in[0][0],user_logged_in[0][1]),
new google.maps.LatLng(markers[i][0], markers[i][1]));
var position = new google.maps.LatLng(markers[i][0], markers[i][1]);
var icon = {url:"http://".concat(markers[i][3]),
scaledSize: new google.maps.Size(20, 20), // scaled size
origin: new google.maps.Point(0,0), // origin
anchor: new google.maps.Point(0, 0) };
marker = new google.maps.Marker({
position: position,
map: map,
title: markers[i][4].toString().concat(' ').concat(markers[i][5].toString()),
icon: icon,
url:'im:<sip:'+markers[i][6]+'>'
});
if(<?=$this->translate($this->layout()->is_super_admin)?>==0){
marker.setVisible(false);
$(document).ready(function() {
$('#select-distance').change(function() {
var e = document.getElementById("select-distance");
var value = parseInt(e.options[e.selectedIndex].value);
if(d < value){
marker.setVisible(true);
}else{
marker.setVisible(false);
}
circle.setRadius(value);
circle.bindTo('center', markerc, 'position');
find_closest_marker(value);
});
});
}
}
但是當我測試了一下,只能對於給定半徑中的最後一個用戶。例如,如果我有3個距離爲2km,3km,1km的用戶,並且我選擇了5km的半徑,那麼我只能得到3公里的用戶!感謝幫助。
我得到這個錯誤未捕獲TypeError:無法讀取未定義的屬性'addListener !!!!! –
@samersboui和你得到這個錯誤的行。 –
var infowindow = new google.maps.InfoWindow({ content:'' }); 標記[I] .addListener( '鼠標懸停',函數(){ infowindow.setContent( '
'+ this.title +'
'+ '