如何在javascript谷歌地图中添加两个库

时间:2016-06-10 02:16:52

标签: javascript google-maps google-maps-api-3

我在创建路径检查后创建路线但是它的错误与geomtry库,我想添加请帮帮我,怎么做,我的代码在下面

 for (var i = 0; i < overviewPathGeo.length; i++) {
                        triangleCoords.push( [{lat:
       overviewPathGeo[i],  lng: overviewPathGeo[i]}]
    );
                    }


             var bermudaTriangle = new google.maps.Polygon({paths: triangleCoords});


        google.maps.event.addListener(mapse, 'click', function(e) {
          var resultColor =
              google.maps.geometry.poly.containsLocation(e.latLng, bermudaTriangle) ?
              'red' :
              'green';
              alert(resultColor);
               });

如何使用路径库添加几何库

 <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false"></script>

我想要两者如何添加,这些都是冲突

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

enter image description here

1 个答案:

答案 0 :(得分:0)

阅读页面底部的documentation图书馆:概述):

  

要请求多个库,请用逗号分隔:

<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=geometry,places">
</script>