Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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
Google maps getJSON谷歌地图多段线_Google Maps_Getjson_Polyline - Fatal编程技术网

Google maps getJSON谷歌地图多段线

Google maps getJSON谷歌地图多段线,google-maps,getjson,polyline,Google Maps,Getjson,Polyline,这是我的jsonData中的一个示例: "lineformap":"new google.maps.LatLng(52.25602231800669, 6.160540580749512),new google.maps.LatLng(52.25543780780041, 6.1602723598480225),new google.maps.LatLng(52.255818725438296, 6.160014867782593)" 这是我的代码: (不显示任何行) 当我将数据复制到代码中时

这是我的jsonData中的一个示例:

"lineformap":"new google.maps.LatLng(52.25602231800669, 6.160540580749512),new google.maps.LatLng(52.25543780780041, 6.1602723598480225),new google.maps.LatLng(52.255818725438296, 6.160014867782593)"
这是我的代码: (不显示任何行) 当我将数据复制到代码中时,可以在地图上看到这些线 谁能帮我做这个

var poly;
var map;
function initialize() {
    var latlng = new google.maps.LatLng(52.2554, 6.1627);
  var myOptions = {
    zoom: 15,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};

    var bermudaTriangle;

    map = new google.maps.Map(document.getElementById("ObjectMap"), myOptions);
    $.getJSON('/api/dbklineforbws', function (createbws) {
        $(createbws).each(function (i, itemb) {
            // Define the LatLng coordinates for the polygon's path.
            var flightPlanCoordinates = [
            itemb.lineformap
          ];

            var flightPath = new google.maps.Polyline({
                path: flightPlanCoordinates,
                geodesic: true,
                strokeColor: '#FF0000',
                strokeOpacity: 1.0,
                strokeWeight: 2
            });



            flightPath.setMap(map);
        });
    });
    }


    google.maps.event.addDomListener(window, 'load', initialize);

对我来说,json文件的用法非常奇怪。但是,为了使其工作,我将json文件更改为:

{
"lineformap": "[new google.maps.LatLng(52.25602231800669, 6.160540580749512),new google.maps.LatLng(52.25543780780041, 6.1602723598480225),new google.maps.LatLng(52.255818725438296, 6.160014867782593)]"
}

获取多段线

var flightPlanCoordinates = [
    itemb.lineformap
];
var flightPlanCoordinates = eval(itemb.lineformap);