Jquery 如何在没有地图的情况下在我的应用程序中使用Google api自动完成位置搜索

Jquery 如何在没有地图的情况下在我的应用程序中使用Google api自动完成位置搜索,jquery,html,Jquery,Html,我有谷歌api自动完成的地方搜索,但它是显示结果使用地图,但我不想要地图,我只想要地名。如何做到这一点 代码: 我应该从这里删除什么,以便它能够根据我的需要工作,或者是否有其他方法来实现这一点 您需要包括places api $().ready(function() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: la

我有谷歌api自动完成的地方搜索,但它是显示结果使用地图,但我不想要地图,我只想要地名。如何做到这一点

代码:


我应该从这里删除什么,以便它能够根据我的需要工作,或者是否有其他方法来实现这一点

您需要包括places api

$().ready(function() {

    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    // use all the autocomplete options as documented at http://docs.jquery.com/Plugins/Autocomplete
    /* additional geo_autocomplete options:
        mapkey : 'ABQ...' (required for Static Maps thumbnails, obtain a key for your site from http://code.google.com/apis/maps/signup.html)
        mapwidth : 100
        mapheight : 100
        maptype : 'terrain' (see http://code.google.com/apis/maps/documentation/staticmaps/#MapTypes)
        mapsensor : true or false
    */
    $('#location').geo_autocomplete(new google.maps.Geocoder, {
        mapkey: 'ABQIAAAAbnvDoAoYOSW2iqoXiGTpYBTIx7cuHpcaq3fYV4NM0BaZl8OxDxS9pQpgJkMv0RxjVl6cDGhDNERjaQ', 
        selectFirst: false,
        minChars: 3,
        cacheLength: 50,
        width: 300,
        scroll: true,
        scrollHeight: 330
    }).result(function(_event, _data) {
        if (_data) map.fitBounds(_data.geometry.viewport);
    });

});
$(document).ready(function(){
var input = document.getElementById("location"); //input id
var autoc_options = { componentRestrictions: {country: 'uk'} }; //if want to filter results by country
var autocomplete = new google.maps.places.Autocomplete(input, autoc_options);
});