我正在尝试绘制折线,但在重载方法中存在一些错误,我无法理解为什么当我正确执行它时会导致错误......我的代码,
private void BuildScript(DataTable tbl)
{
String Locations = "";
String locations = "";
foreach (DataRow r in tbl.Rows)
{
// bypass empty rows
if (r["Latitude"].ToString().Trim().Length == 0)
continue;
string Latitude = r["Latitude"].ToString();
string Longitude = r["Longitude"].ToString();
double latitude = Convert.ToDouble(r["Latitude"]);
double longitude =Convert.ToDouble(r["Longitude"]);
var points = new List<GLatLng> {new GLatLng(latitude,longitude)};
var polyline = new GPolyline(points);
// create a line of JavaScript for marker on map for this record
Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + Latitude + "," + Longitude + ")));";
locations += Environment.NewLine + " map.addOverlay(new GPolyline(new GLatLng(" + Latitude + "," + Longitude + ")));";
}
// construct the final script
js.Text = @"<script type='text/javascript'>
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById('map_canvas'));
map.setCenter(new GLatLng(45.05,7.6667), 2);
" + Locations + @"
map.setUIToDefault();
}
}
</script> ";
js.Text = @"<script type='text/javascript'>
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById('map_canvas'));
map.setCenter(new GLatLng(45.05,7.6667), 2);
" + locations + @"
map.setUIToDefault();
}
}
</script> ";
}
现在它给了我脚本折线不存在的错误
希望得到您的回复...