繁体   English   中英

同一页面上的Google Map和Geocomplete不起作用

[英]Google Map and Geocomplete at the same Page Does not work

我正在页面中使用Google Map-带有2个标记以及这些标记之间的路线。

页面中也有一个GeoComplete。

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places"></script>

这是GeoComplete随附的脚本,

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false" type="text/javascript"></script> 

这是地图包含的脚本。

问题是,这两种方法无法一起使用。 当我删除一个库时,一项工作,而另一项则不行。

这是Geocomplete代码

                $("#point").geocomplete({country: "ARE"})
                .bind("geocode:result", function(event, result) {
                    $("#latpoint").val(result.geometry.location.ob);
                    $("#longpoint").val(result.geometry.location.pb);
                });

这是地图代码

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 }); 

当我使用此Single Javascript include时,此功能正常运行

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM