我有一组地址,我用来加载地图,
我使用像
这样的HiddenField将这些地址从cs文件加载到javascript// In code behind
string []arr=new string[]
{
"51.482238,0.001581",
"51.473364,0.011966","51.471974,-0.000651",
"51.472108,-0.002196","51.474995,-0.003827",
"51.476492,-0.005629","51.477855,-0.006058",
"51.478443,-0.007045","51.479298,-0.007861",
"51.481202,-0.002136","51.481577,-0.0022"
};
for ( int j = 0; j < arr.Length ; j++ )
{
HiddenField1.Value += arr[j] + ":";
}
}
//in javascript
var hidValue= document.getElementById("<%=HiddenField1.ClientID%>").value;
var latlonArr = hidValue.split(':');
for (var i = 0; i < latlonArr.length - 1; i++)
{
//alert("item :"+ i + " : "+latlonArr[i]);
var latlonA = latlonArr[i].split(',');
var latlon = new google.maps.LatLng(latlonA[0],latlonA[1]);
arrCoords.push(latlon);
}
所以,现在如果我有更多没有。对于地址,可以使用HiddenField来处理100到1000或更多的地址..
答案 0 :(得分:0)
使用您可能拥有的最大地址数来检查性能,如果性能正常,那么您应该没问题。 如果性能不好,则考虑异步获取地址,例如一次100个。
答案 1 :(得分:0)
在代码隐藏中,您可以使用:
string []arr=new string[]
{
"51.482238,0.001581",
"51.473364,0.011966","51.471974,-0.000651",
"51.472108,-0.002196","51.474995,-0.003827",
"51.476492,-0.005629","51.477855,-0.006058",
"51.478443,-0.007045","51.479298,-0.007861",
"51.481202,-0.002136","51.481577,-0.0022"
};
HiddenField1.Value = arr.join(",");