如何使用谷歌地方api特定城市在PHP中

时间:2016-03-30 20:10:14

标签: php google-places-api

我想在特定的城市使用google place api而不是全世界。

目前我使用下面的代码

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places&amp;types=(locality)&amp;input={ahemdabad}" 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>

<input id="searchTextField" type="text" size="50" placeholder="Enter a location" autocomplete="on">

1 个答案:

答案 0 :(得分:0)

<script>
function initialize() {
    var input = document.getElementById('searchTextField');
    var autocomplete = new google.maps.places.Autocomplete(input);
  var marker = new google.maps.Marker({
    position: map.getCenter(),
    map: map,
    title: "hi"
  });
}


</script>';