【问题标题】:Searchbox in Google map API - integrated with infobox database linkGoogle 地图 API 中的搜索框 - 与 infoblox 数据库链接集成
【发布时间】:2016-04-26 09:30:26
【问题描述】:

我是这方面的新手,这个问题对你们很多人来说可能很简单,但请帮忙。

我正在尝试在一个非常简单的谷歌地图脚本中集成一个搜索框。

1- 我从这里成功复制了文件:From Info Windows to a Database: Saving User-Added Form Data 配置好,效果很好!!

现在我正在尝试将搜索框功能添加到现有代码中。 基本上,我想整合这个:Place Search Box 进入前面的代码。

这将使我能够在将特定位置添加到我的数据库之前搜索地点(城市)。

谢谢各位!

【问题讨论】:

    标签: php google-maps google-maps-api-3 location


    【解决方案1】:

    你可以这样设置:

    1. 实现搜索地点。
    2. 获取重要数据(姓名、地址、类型)自动使用这些数据填充信息窗口。
    3. 在数据库中编辑/保存数据。

    代码:

    // Create a marker for each place.
     markers.push(new google.maps.Marker({
     map: map,
     icon: icon,
     title: place.name,
     position: place.geometry.location
     }));
    

    然后从您的链接添加自定义信息窗口/调整表单中的一些值,获取搜索地点的结果。

    var html = "<table>" +
    "<tr><td>Name:</td> <td><input type='text' id='name'/> </td> </tr>" +
    "<tr><td>Address:</td> <td><input type='text' id='address'/></td> </tr>" +
    "<tr><td>Type:</td> <td><select id='type'>" +
    "<option value='bar' SELECTED>bar</option>" +
    "<option value='restaurant'>restaurant</option>" +
    "</select> </td></tr>" +
    "<tr><td></td><td><input type='button' value='Save & Close' onclick='saveData()'/></td></tr>";
    infowindow = new google.maps.InfoWindow({
    content: html
    });
    
    google.maps.event.addListener(map, "click", function(event) {
    marker = new google.maps.Marker({
    position: event.latLng,
    map: map
    });
    google.maps.event.addListener(marker, "click", function() {
    infowindow.open(map, marker);
    });
    });
    }
    

    这里是来自places details 的项目响应列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-28
      • 1970-01-01
      相关资源
      最近更新 更多