简体   繁体   English

如何从 StandaloneSearchBox 获取 Lat 和 Lng?

[英]How to get Lat and Lng from StandaloneSearchBox?

I use the react-google-maps StandaloneSearchBox and query the locations of my points of interest.我使用react-google-maps StandaloneSearchBox并查询我的兴趣点的位置。 This works as far as it goes.这是可行的。 However, I get back functions for the location and not the actual value.但是,我得到了该位置的函数,而不是实际值。 How do I actually get the lat and lng values similar to the viewport.我如何实际获得类似于视口的 lat 和 lng 值。

geometry:
 location: _.bf
   lat: ƒ ()
   lng: ƒ ()

 viewport: _.Wf
   Bb: Vf {g: 41.4022605197085, h: 41.4049584802915}
   Ra: Qf {g: 2.173047169708498, h: 2.175745130291502}

You can just call the lat and lng functions to get the values.您可以调用latlng函数来获取值。

  • geometry.location.lat() -> latitude value geometry.location.lat() -> 纬度值
  • geometry.location.lng() -> longitude value geometry.location.lng() -> 经度值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM