Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/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
Javascript 不显示Js Google地图标记和路径_Javascript_Google Maps - Fatal编程技术网

Javascript 不显示Js Google地图标记和路径

Javascript 不显示Js Google地图标记和路径,javascript,google-maps,Javascript,Google Maps,我试图在地图上实现一个标记,标记将沿着指定的路径移动。我可以验证贴图是否在右中心正确渲染和缩放,但标记和路径不会显示。如有任何帮助/建议,将不胜感激。我已经在firefox和chrome上进行了测试 我的html代码如下: <link rel="stylesheet" src="map.css"> </link> <script src="https://maps.googleapis.com/maps/api/j

我试图在地图上实现一个标记,标记将沿着指定的路径移动。我可以验证贴图是否在右中心正确渲染和缩放,但标记和路径不会显示。如有任何帮助/建议,将不胜感激。我已经在firefox和chrome上进行了测试

我的html代码如下:

<link rel="stylesheet" src="map.css"> </link> 
<script src="https://maps.googleapis.com/maps/api/js?key=mykey&callback=initialize" defer ></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    <script src="map.js"></script>
</head>

<body>
    <div id="app-text"></div>
        <h1 center> Sendy Test </h1> 
        <h3 text-center> Question 1 </h3>
    </div>  

  <div id="map_canvas"></div>
</body>
function initialize()
{
    var myOptions = {
        zoom: 16,
        center: new google.maps.LatLng(-1.298982, 36.776811),
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var image = 'https://images.sendyit.com/web_platform/vendor_type/top/2.svg';
    
    marker = new google.maps.Marker({
        position: new google.maps.LatLng(startPos[0], startPos[1]),
        title: "Your driver",
        visible: true,
        map: map,
        icon: image
    });

    marker.setMap(map);
    
    google.maps.event.addListenerOnce(map, 'idle', function()
    {
        animateMarker(marker, [
            // The coordinates of each point you want the marker to go to.
            // You don't need to specify the starting position again.
            [-1.297459, 36.776747],
            [-1.296193, 36.776726],
            [-1.296097, 36.779236],
            [-1.296151, 36.777637],
            [-1.296215, 36.776693],
            [-1.294252, 36.776586],
            [-1.294048, 36.776790],
            [-1.293973, 36.779118],
            [-1.292622, 36.779075],
            [-1.291844, 36.779049],

        ], speed);
    });

    polylineCoords = [];
    
    var startCoords = new google.maps.LatLng(startPos[0], startPos[1]);
    
    polylineCoords.push(startCoords);

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

initialize();

这个错误是因为我在地图上指定了一个错误的起始位置