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
Javascript 谷歌地图和Geocomplete在同一页面上不起作用_Javascript_Google Maps_Google Maps Api 3_Google Maps Api 2 - Fatal编程技术网

Javascript 谷歌地图和Geocomplete在同一页面上不起作用

Javascript 谷歌地图和Geocomplete在同一页面上不起作用,javascript,google-maps,google-maps-api-3,google-maps-api-2,Javascript,Google Maps,Google Maps Api 3,Google Maps Api 2,我在一个页面中使用一个谷歌地图,上面有两个标记和一个图标,标出了这些标记之间的路线 页面中也有一个完整的地理信息 <script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places"></script> 这是地图代码 var map = new GMap2(document.getElementById("map")); var directio

我在一个页面中使用一个谷歌地图,上面有两个标记和一个图标,标出了这些标记之间的路线

页面中也有一个完整的地理信息

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places"></script>
这是地图代码

var map = new GMap2(document.getElementById("map"));
       var directions = new GDirections(map);
       var isCreateHeadPoint = true;
       var headMarker, tailMarker;

       map.setCenter(new GLatLng(51.50, -0.12), 12);

       var point = new google.maps.LatLng(someLat, someLong);  
       headMarker = new GMarker(point); 
       map.addOverlay(headMarker);
       var point = new google.maps.LatLng(SomeotherLat, SomeotherLong);  
       tailMarker = new GMarker(point);
       map.addOverlay(tailMarker);

       directions.load("from:SomeLat,SomeLong to:SomeotherLat,SomeotherLong", 
                             { getPolyline: true, getSteps: true }); 

当我使用这一个Javascript include时,它就开始工作了

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false"></script>


您确定这是完整的脚本吗?它看起来与。将地图代码更新到V3,您不需要同时包含两个地图API
var map = new GMap2(document.getElementById("map"));
       var directions = new GDirections(map);
       var isCreateHeadPoint = true;
       var headMarker, tailMarker;

       map.setCenter(new GLatLng(51.50, -0.12), 12);

       var point = new google.maps.LatLng(someLat, someLong);  
       headMarker = new GMarker(point); 
       map.addOverlay(headMarker);
       var point = new google.maps.LatLng(SomeotherLat, SomeotherLong);  
       tailMarker = new GMarker(point);
       map.addOverlay(tailMarker);

       directions.load("from:SomeLat,SomeLong to:SomeotherLat,SomeotherLong", 
                             { getPolyline: true, getSteps: true }); 
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false"></script>