Google Places API类型功能. [英] Google Places API types functionality..

查看:77
本文介绍了Google Places API类型功能.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<html>
    <head>
        <title></title>

        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=true"></script>
        <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                var input = document.getElementById('location');
                var options = {                    
                    types: ["locality"]
                };

                autocomplete = new google.maps.places.Autocomplete(input, options);
            });
        </script>        
    </head>
    <body>
        <div>Location: <input type="text" id="location" style="width:400px;" /></div>               
    </body>
</html>

有我的代码来生成我的自动完成位置文本输入. Google的受支持类型列表( http://code.google.com/apis/maps/documentation/当我不希望一切都返回到结果(业务等)中时,places/supported_types.html )将本地性"显示为要使用的类型.我没有结果.

There is my code to generate my autocomplete location text input. Google's list of supported types (http://code.google.com/apis/maps/documentation/places/supported_types.html) shows "locality" as being the type to use when I do not wish for everything to come back in the result(businesses, etc). I am getting no results.

基本上,我想实现的目标是搜索城市(即多伦多),并且只会看到类似加拿大安大略省多伦多"的结果.也许我对如何实现此API感到困惑.

Basically, what I would like to achieve is to search for a city (IE: Toronto) And only see results like: "Toronto, ON, Canada". Perhaps I am confused on how I implement this API.

非常感谢您的答复!

推荐答案

我认为根据文档,您正在寻找的选项是地理编码"(

I think the option you are looking for according to the docs is "geocode" ( http://code.google.com/apis/maps/documentation/javascript/reference.html#AutocompleteOptions ):

var options = {                    
    types: ["geocode"]
};

这篇关于Google Places API类型功能.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆