InvalidValueError:不是HTMLInputElement的实例-Laravel中的Google Places API

时间:2018-07-09 12:51:48

标签: google-maps laravel-5 google-places-api

我已将google place api添加到laravel应用输入中以实现地址自动填充。一切正常,除了开发人员控制台中几乎没有错误。

收到的错误

InvalidValueError: not an instance of HTMLInputElement

这是我的代码

<script src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&libraries=places"></script>
    <script type="text/javascript">
        google.maps.event.addDomListener(window, 'load', function () {
            var places = new google.maps.places.Autocomplete(document.getElementById('txtPlaces'));
            google.maps.event.addListener(places, 'place_changed', function () {

            });
        });
        google.maps.event.addDomListener(window, 'load', function () {
            var places = new google.maps.places.Autocomplete(document.getElementById('txtPlaces2'));
            google.maps.event.addListener(places, 'place_changed', function () {

            });
        });
        google.maps.event.addDomListener(window, 'load', function () {
            var places = new google.maps.places.Autocomplete(document.getElementById('txtPlaces3'));
            google.maps.event.addListener(places, 'place_changed', function () {

            });
        });
    </script>

如何解决这个问题?

0 个答案:

没有答案