【问题标题】:Google place API get input text from Autocomplete formGoogle Place API 从自动完成表单中获取输入文本
【发布时间】:2015-02-20 02:02:25
【问题描述】:

所以这里是JSFiddle example
一切都很好,很容易。但是,如何从自动完成表单中获取直接输入文本?整个文本值?

如果您调用.getPlace(),您会得到结构化信息,但我需要从输入字段中获取与用户输入的文本相同的文本。

var place = tbgeo.getPlace();

// How to get something like this => var userinput = tbgeo.InnerText;

console.log(JSON.stringify(place));

var lat = place.geometry["location"]["k"]
var lng = place.geometry["location"]["D"]

var address = '';
if (place.address_components) {
    address = [
      (place.address_components[0] && place.address_components[0].short_name || ''),
      (place.address_components[1] && place.address_components[1].short_name || ''),
      (place.address_components[2] && place.address_components[2].short_name || '')
    ].join(' ');
}

【问题讨论】:

    标签: javascript jquery autocomplete google-api google-places-api


    【解决方案1】:

    你可以这样做,

    <div ng-app="">
    
    <p>Name: <input type="text" ng-model="userInputText" ></p>
    Bind Name: <input type="text" ng-model="userInputText" >
    
    <!-- or use ng-bind instead of ng-model -->
    <p ng-bind="userInputText"></p>
    
    </div>
    

    【讨论】:

      猜你喜欢
      • 2022-01-14
      • 2019-03-15
      • 1970-01-01
      • 2015-07-28
      • 2016-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-15
      相关资源
      最近更新 更多