ASP.NET中的Google地方自动填充功能

时间:2011-09-27 04:23:10

标签: asp.net google-maps

任何人都有ASP.NET for Google Places Autocomplete API包装器吗? http://code.google.com/apis/maps/documentation/places/autocomplete.html

非常感谢样品或方法。

由于

2 个答案:

答案 0 :(得分:4)

以下是Google地方自动填充功能的演示链接......

http://code.google.com/apis/maps/documentation/javascript/examples/places-autocomplete.html

右键单击浏览器并查看页面源...您可以找到方法....如何做到....

相关文件..从这里找...

http://code.google.com/p/geo-autocomplete/

答案 1 :(得分:1)

在Google的API v3中,他们展示了一个包含此剪辑的示例:

      function fillInAddress() {
        // Get the place details from the autocomplete object.
        var place = autocomplete.getPlace();

        for (var component in componentForm) {
            document.getElementById(component).value = '';
            document.getElementById(component).disabled = false;
        }

        // Get each component of the address from the place details
        // and fill the corresponding field on the form.
        for (var i = 0; i < place.address_components.length; i++) {
            var addressType = place.address_components[i].types[0];
            if (componentForm[addressType]) {
                var val = place.address_components[i][componentForm[addressType]];
                document.getElementById(addressType).value = val;
            }
        }
    }

但是,在ASP.NET中,需要使用格式document.getElementById(&#34;&lt;%= controlname.ClientID%&gt;&#34;)

如何在上面的fillInAddress()中创建语法以传递&#39;组件&#39;对象并创建正确的语法以使其工作?感谢