Google maps 在google地图上显示带有多段线的标记

Google maps 在google地图上显示带有多段线的标记,google-maps,Google Maps,我试图从数据库值向im图形的多段线添加标记,但添加标记的代码时,多段线不显示,标记也不显示。 我从数据库中获取每个人id的坐标,并在地图上显示多段线。我想添加标记或信息窗口,但未能添加。 dynamic.php <?php include "connection.php"; $i=0; $table = mysql_query ("select distinct TeamWorkerId from Map"); while ($row = mysql

我试图从数据库值向im图形的多段线添加标记,但添加标记的代码时,多段线不显示,标记也不显示。 我从数据库中获取每个人id的坐标,并在地图上显示多段线。我想添加标记或信息窗口,但未能添加。 dynamic.php

    <?php
    include "connection.php";
    $i=0;
    $table = mysql_query ("select distinct TeamWorkerId from Map");
    while ($row = mysql_fetch_array($table))
    {
        $i++;

      echo "var flightPath".$i." = new google.maps.Polyline(); var infowindow".$i." = new google.maps.InfoWindow();  function drawLine".$i."() {
        var flightPlanCoordinates".$i." = [";
        $workerid = $row["TeamWorkerId"];
       $ttable= mysql_query("select * from Map where TeamWorkerId='$workerid'");
       while ($trow = mysql_fetch_array($ttable))
       {

         echo "new google.maps.LatLng(".$trow[3]."),";
       }
        echo "];

        flightPath".$i.".setMap(null);

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

      google.maps.event.addListener(flightPath".$i.", 'click', function(event) {


            infowindow".$i.".setPosition(event.flightPlanCoordinates".$i.");
            infowindow".$i.".open(map);
        });





        flightPath".$i.".setMap(map);


    }";

Testing.php



    function initialize() 
    {
        var mapOptions = 
        {
            zoom: 3,
            center: new google.maps.LatLng(37.772323,-122.214897),
            mapTypeId: google.maps.MapTypeId.TERRAIN
        };

        map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);


    }


    google.maps.event.addDomListener(window, 'load', initialize); </script>
      </head>
      <body >
      <script language="javascript">
        function view ()
        {
            alert ('called');
            drawLine1();
        }
      </script>
      <input type="button" value="show"  onclick='view();'/>
        <div id="map-canvas"></div>
      </body>
    </html>

    <script>
    $(document).ready(function(e) {

    setInterval(
    function () {
        $.get("dynamic.php",function (data) {
        //  alert (data);
            eval (data);
            });
    }
            ,60000);
    });

    </script>

地图似乎是空的。

我建议您在一个部分中编写所有php代码,在另一个部分中编写js,混合使用两者可能很难阅读和调试

请提供一个(包括所需的任何HTML和CSS)。Stackoverflow不允许发布整个代码,但我已经以某种方式发布了它。请重新检查并告诉我,如果你能帮忙,我当然没有要求完整的代码。不清楚的最小值呢?请仔细阅读。我正在努力满足要求。我必须从需要php的数据库中获取坐标。我是在一个单独的html页面中访问这段代码的,在该页面中地图是初始化的。@hamidkhanlodhi数据库的坐标是多少?您可以做两件事,在页面的一部分运行所有php代码,然后在($row=mysql\u fetch\u array($table)){$flightpath[]=$row;}时发布结果然后在js中,您可以像var flightpath=;然后,您将有一个包含flightpath php变量内容的js变量,您可以使用js循环json变量,等等。
var map;