M522828 发表于 2016-8-27 15:37:42

google.maps.places.SearchBox选择地址没有响应

本帖最后由 M522828 于 2016-8-27 15:45 编辑

引入ionic.bundle.js后选择地址无响应,移除ionic.bundle.js可以正常选择地址。附上测试代码:<!DOCTYPE html>
<html>

      <head>
                <meta charset="UTF-8">
                <title></title>
                <script src="http://ditu.google.cn/maps/api/js?libraries=places&language=zh-HK"></script>
      </head>
      <body>
                <div>
                        <input type="text" id="language" />
                        <div id="map" style="height: 300px;"></div>
                </div>
                <script>
                        function initialize() {
                              var mapOptions = {
                                        zoom: 8,
                                        center: new google.maps.LatLng(-34.397, 150.644)
                              };

                              var map = new google.maps.Map(document.getElementById('map'),
                                        mapOptions);

                              var label_startPoint = document.getElementById('language');
                              startPointBox = new google.maps.places.SearchBox(label_startPoint);

                              startPointBox.addListener('places_changed', function() {
                                        var places = startPointBox.getPlaces();
                                        if(!places || places.length == 0) {
                                                return;
                                        }

                                        places.forEach(function(place) {
                                                var _address_forrmat = place.formatted_address;
                                                alert(_address_forrmat);
                                        });
                              });
                        }
                        initialize();
                </script>
                <script src="js/ionic.bundle.min.js"></script>
      </body>
</html>

页: [1]
查看完整版本: google.maps.places.SearchBox选择地址没有响应