php - 如何为我的 php 应用程序使用 google place api

标签 php jquery google-maps-api-3

我正在尝试创建一个网页。当用户开始在文本框中输入内容时,带有州名列表的自动完成城市会出现在建议的下拉框中,就像在谷歌地图中一样。

我有谷歌地点自动完成的 api。但是我无法实现它。

有人可以建议我如何实现 google place api 吗?

API 网址为:Google Place API Page

最佳答案

我实现的是下面的代码,它给了我想要的解决方案 -

   <html>
       <head>
       <style type="text/css">
               body {
                       font-family: sans-serif;
                       font-size: 14px;
               }
       </style>
       <title>Google Maps JavaScript API v3 Example: Places Autocomplete</title>
       <script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places" type="text/javascript"></script>
        <script type="text/javascript">
               function initialize() {
                       var input = document.getElementById('searchTextField');
                       var autocomplete = new google.maps.places.Autocomplete(input);
               }
               google.maps.event.addDomListener(window, 'load', initialize);
       </script>
       </head>
           <body>
               <div>
                       <input id="searchTextField" type="text" size="50" placeholder="Enter a location" autocomplete="on">
               </div>
           </body>
       </html>

关于php - 如何为我的 php 应用程序使用 google place api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7555279/

相关文章:

php - 尝试从数据库 jquery 检索用户名

javascript - 添加在 Google map API v3 中打开信息窗口的链接

javascript - 无法在 google api 上获取标记

php - PHP array() 构造的 "value"部分可以包含什么?

php - 导出 csv 之前设置数据库列别名

javascript - 水平平滑滚动

google-maps-api-3 - 在 Google Map API 3 中突出显示美国各州和城市的边界

PHP - 将 PDO 与 IN 子句数组一起使用

php - Cakephp 错误重定向

javascript - jquery-ui 自动完成似乎没有触发?