Localiser des points sur une carte google
Bonjour, j'ai une liste de point a localiser, je fais comme ca :
je charge une dropdownlist avec tous les elements
Je prends tous les elements qui existent dans ma BD (le nombre = a celui dans la ddl)
je passe les elements a une fonction javascript dans un tableau et je les localise
Mon probleme c'est qu'il ne les localise pas tous :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
int len = ddlAdr.Items.Count;
string[,] tabStation = new string[ddlAdr.Items.Count, 4];
connection.Open();
System.Data.SqlClient.SqlDataReader oDBDataReader2;
String Query2 = "SELECT * FROM [StationsServices]";// where ID_Station =" + ddlAdr.Items[d].Value
SqlCommand cmdDatabase2 = new SqlCommand(Query2, connection);
oDBDataReader2 = cmdDatabase2.ExecuteReader();
int a = 0;
while (oDBDataReader2.Read() == true)
{
for (int i = a; i < ddlAdr.Items.Count; i++)
{
tabStation[i, 0] = oDBDataReader2["Adresse"].ToString();
tabStation[i, 1] = oDBDataReader2["Name_station"].ToString();
tabStation[i, 2] = oDBDataReader2["Latitude"].ToString();
tabStation[i, 3] = oDBDataReader2["Longitude"].ToString();
a = a + 1;
break;
}
}
connection.Close();
StringBuilder builder2 = new StringBuilder();
builder2.Append("[");
for (int i = 0; i < len; ++i)
{
builder2.Append("['");
for (int j = 0; j < 4; ++j)
{
builder2.Append(tabStation[i, j]);
if (j != 4 - 1)
{
builder2.Append("','");
}
}
builder2.Append("']");
if (i != len - 1)
{
builder2.Append(",");
}
}
builder2.Append("]");
string result = builder2.ToString();
BtnStations.Attributes.Add("onClick", "javascript:findAllAddress(" + result + "); return false;"); |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| function findAllAddress(tabStation) {
clearOverlays();
var n = tabStation.length;
for (var i = 0; i < n; i++) {
findAddress2(tabStation[i][0], tabStation[i][1], tabStation[i][2], tabStation[i][3]);
}
}
function findAddress2(adresse, name, lt, lg) {
var latlng = new google.maps.LatLng(lt, lg);
var address = adresse;
// script uses our 'geocoder' in order to find location by address name
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) { // and, if everything is ok
// we will center map
var addrLocation = latlng;
map.setCenter(addrLocation);
// store current coordinates into hidden variables
document.getElementById('lat').value = lt;
document.getElementById('lng').value = lg;
// and then - add new custom marker and Infowindow
var addrMarker = new google.maps.Marker({
position: addrLocation,
map: map,
title: results[0].formatted_address
//animation: google.maps.Animation.BOUNCE
});
iconFile = 'https://maps.gstatic.com/mapfiles/ms2/micons/gas.png';
addrMarker.setIcon(iconFile) ;
var infowindow = new google.maps.InfoWindow({
content: '<DIV STYLE="line-height:1.35;overflow:hidden;white-space:nowrap;"><DIV STYLE=overflow:auto; width:50px; height:50px><font style="color:#000;">' + name +
'<br /></font></div></div>'
});
infowindow.open(map, addrMarker);
markers.push(addrMarker);
addrMarker.indice = markers.length - 1;
// suppression du marker sur dblclick
google.maps.event.addListener(addrMarker, 'dblclick', function (data) {
this.setMap(null);
var ind = this.indice;
markers.splice(ind, 1);
// r?©ajuste les indices des autres marqueurs
for (; markers[ind]; ind++) {
markers[ind].indice = ind;
}
});
}
});
} |
quand je met une alert a l'interieur de la fonction findAllAddress, je vois que tous mes elements sont récupérés avec le nombre exact de donnés mais siur la carte il me localise uniquement 5 element
pourriez vous m'aidez ?