Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过javascript对象循环以绘制多段线google maps_C#_Javascript_Json_Google Maps Api 3 - Fatal编程技术网

C# 通过javascript对象循环以绘制多段线google maps

C# 通过javascript对象循环以绘制多段线google maps,c#,javascript,json,google-maps-api-3,C#,Javascript,Json,Google Maps Api 3,我已经在这里找到了一些关于javascript对象的文章,但我似乎还不太了解。我将JSON字符串转换为javascript对象,如下所示 public class LinePoint { public string Latitude { get; set; } public string Longitude { get; set; } public int Pointnumber { get; set; } } public class PolyLine { p

我已经在这里找到了一些关于javascript对象的文章,但我似乎还不太了解。我将JSON字符串转换为javascript对象,如下所示

public class LinePoint {
    public string Latitude { get; set; }
    public string Longitude { get; set; }
    public int Pointnumber { get; set; }
}

public class PolyLine {
    public List<LinePoint> LinePoints { get; set; }
    public int PolyLineNumBer { get; set; }
}

public class RootObject {
    public List<PolyLine> PolyLines { get; set; }
}

有人能帮我一个忙,告诉我如何循环javascript对象并获取属性值吗?

我错过了有关html文档结构的信息

for(key in objs){
    var value= objs[key];
    //..
}
但是,我会尽力帮助:

$("#rootitemid").children().each(function(){
    var value= $(this).html(); 
    //..
});
前面的循环覆盖html文档中的元素

for(key in objs){
    var value= objs[key];
    //..
}

前面在javascript对象上的循环。

假设使用jQuery,每个循环都可以使用$。像这样的方法应该会奏效:

    var line = JSON.parse(document.getElementById('hdfPolyLines').value);

    $.each(line.PolyLines, function(polyLineIndex, polyLineValue) {

        var path = Array();

        $.each(polyLineValue.LinePoints, function (linePointIndex, linePointValue) {

            path.push(new google.maps.LatLng(linePointValue.Latitude, linePointValue.Longitude));
        });

        var polyline = new google.maps.Polyline({
            path: path,
            strokeColor: '#ff0000',
            strokeOpacity: 1.0,
            strokeWeight: 3
        });

        polyline.setMap(map);
    });

这段代码在我看来不像javascript,它看起来像java。它的工作方式很有魅力。Thanx!!