Laravel 项目中的谷歌地图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36443836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
google maps in laravel project
提问by Muhammad Umar
I am workin on laravel project in which i have to integrate google maps. I am using this package https://github.com/alexpechkarev/google-mapsfor google maps . I install this package and get api key from https://console.developers.google.com/apis/credentials. then I just follow the usage of this package for example i write the code in my controller
我正在从事 Laravel 项目,我必须在其中集成谷歌地图。我正在使用这个包https://github.com/alexpechkarev/google-mapsfor google maps 。我安装了这个包并从https://console.developers.google.com/apis/credentials获取 api 密钥。然后我只是按照这个包的用法,例如我在我的控制器中编写代码
$response = \GoogleMaps::load('geocoding')
->setParam (['address' =>'santa cruz'])
->get();
It giving me data in json encode formate but i dont't know what i do next . How can i display maps . can someone please give me proper example of this package via code i will be thankfull for that thanks in advanced
它以 json 编码格式为我提供数据,但我不知道接下来要做什么。如何显示地图。有人可以通过代码给我这个包的正确示例吗?
回答by Angad Dubey
You need to actually implement the map on the front end in your views:
您需要在视图中实际实现前端的地图:
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js" async defer></script>
<script>
function initMap() {}
</script>
Read this: https://developers.google.com/maps/tutorials/fundamentals/adding-a-google-map#introduction
阅读:https: //developers.google.com/maps/tutorials/fundamentals/adding-a-google-map#introduction