get city from geocoder results?

后端 未结 13 1953
我寻月下人不归
我寻月下人不归 2020-12-02 14:07

Having problems getting the different arrays content from geocoder results.

item.formatted_address works but not item.address_components.locality?

ge         


        
13条回答
  •  悲哀的现实
    2020-12-02 15:01

    I used a lodash function called find which returns the object that the predicate returns true for. As simple as that!

    let city = find(result, (address) => {
      return typeof find(address.types, (a) => { return a === 'locality'; }) === 'string';
    });
    

提交回复
热议问题