【问题标题】:set polyLine Path using Json Arrary [closed]使用 Json 数组设置折线路径 [关闭]
【发布时间】:2014-10-02 18:12:36
【问题描述】:

我创建了一个方法,它使用 c# 从数据库返回纬度和经度数组,现在我想将此列表传递给 JavaScript 以绑定谷歌地图上的 poly_line 路径。

【问题讨论】:

    标签: c# javascript asp.net ajax google-maps


    【解决方案1】:
    var polyOptions = {
        strokeColor: '#000000',
        strokeOpacity: 1.0,
        strokeWeight: 3
    }
    poly = new google.maps.Polyline(polyOptions);
    poly.setMap(map);
    
    var path = new MVCArray;
    
    $.getJSON('json.cs', function(data) {
        //var items = [];
        $.each(data, function(key, val) {
                path.push(new google.maps.LatLng(val.lat, val.longi));
        });
    
        // now update your polyline to use this path
        poly.setPath(path);
    });
    
    
    <body onload="initialize()">
      <div id="map_canvas" style="width:90%; height:100%"></div>
    
    </body>
    
    </html>
    

    For Reference

    【讨论】:

    猜你喜欢
    • 2012-02-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 2011-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多