Google位置自动填充仅在选择时显示街道号码

时间:2018-03-29 11:53:24

标签: javascript angularjs google-location-services

我正在使用vsGoogleAutoComplete进行角度应用。这个库工作得很好,当我开始输入时它会显示建议。

enter image description here

目前的做法是,如果我选择匹配的地址,则会将完整地址放在输入街道名称字段中,如下所示:

enter image description here 但是当我选择匹配的地址时我想要的只有街道名称& number将出现在输入字段中,其他字段将出现在相应的字段中 我尝试了不同的方法,但没有成功。我觉得有一些我找不到的简单方法。任何帮助将不胜感激。

PLUNKER

<div class="form-group">

      <!--5217 98th St-->
      <label style="margin-top:50px;">Enter street name</label> 
      <input vs-google-autocomplete

             ng-model="address.name"
             vs-place="address.place" 
             vs-place-id="address.components.placeId"
             vs-street-number="address.components.streetNumber" 
             vs-street="address.components.street"
             vs-city="address.components.city"
             vs-state="address.components.state"
             vs-country-short="address.components.countryCode"
             vs-country="address.components.country"
             vs-post-code="address.components.postCode"
             vs-latitude="address.components.location.lat"
             vs-longitude="address.components.location.long"

             type="text" 
             name="address"
             id="address"
             class="form-control" 
             placeholder="Enter street name">



 <span class="help-block"><b>City: </b>{{address.components.city}}</span>
      <span class="help-block"><b>State: </b>{{address.components.state}}</span>
      <span class="help-block"><b>Country code: </b>{{address.components.countryCode}}</span>
      <span class="help-block"><b>Country: </b>{{address.components.country}}</span>
      <span class="help-block"><b>Postcode: </b>{{address.components.postCode}}</span>
      <span class="help-block"><b>Latitude: </b>{{address.components.location.lat}}</span>
      <span class="help-block"><b>Longitude: </b>{{address.components.location.long}}</span>
    </div>

0 个答案:

没有答案