试图在Laravel中添加Google自动填充功能。我的代码如下:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&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 () {
});
});
</script>
<span>Location:</span>
<input type="text" id="txtPlaces" style="width: 250px" placeholder="Enter a location" />
它绝对可以在HTML / PHP文件中使用。html / php文件中的输出是这样的-
但是,当我想在Laravel中实现时,它根本无法工作。它显示以下错误。
您能帮我解决这个问题吗?
您需要在网址中添加密钥,此错误的原因是您尚未配置Google Maps API密钥。
请参阅参见-如何创建密钥:http : //docs.gravityview.co/article/306-signing-up-for-a-google-maps-api-key
向网址添加密钥:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR API KEY&libraries=places"></script>
或使用以下网址:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句