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&libraries=places"></script> 这是地图代码 var map = new GMap2(document.getElementById("map")); var directio
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&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>