Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在React应用程序上实现Google地图API_Javascript_Google Maps_Reactjs_Google Maps Api 3_Npm - Fatal编程技术网

Javascript 在React应用程序上实现Google地图API

Javascript 在React应用程序上实现Google地图API,javascript,google-maps,reactjs,google-maps-api-3,npm,Javascript,Google Maps,Reactjs,Google Maps Api 3,Npm,我是react的初学者,并尝试在我的应用程序中实现Google Maps API 我在页面http://localhost:8080/ 我如何在搜索输入框中实现谷歌地图自动完成搜索,以及如何在下面的地图上显示搜索结果。我还喜欢从谷歌地图API获取地理位置、商业网站、电话号码、小时数等json数据 如何使用React实现此功能???如果您可以找到React native的gmap,请尝试如下:我认为您不需要使用第三方库。首先,需要将脚本嵌入index.html中 <script src="h

我是react的初学者,并尝试在我的应用程序中实现Google Maps API

我在页面
http://localhost:8080/

我如何在搜索输入框中实现谷歌地图自动完成搜索,以及如何在下面的地图上显示搜索结果。我还喜欢从谷歌地图API获取地理位置、商业网站、电话号码、小时数等json数据


如何使用React实现此功能???

如果您可以找到React native的gmap,请尝试如下:

我认为您不需要使用第三方库。首先,需要将脚本嵌入index.html中

<script src="https://maps.googleapis.com/maps/api/js?key=[YOUR_API_KEY]&libraries=places"></script>
自动完成类有一个名为place\u changed的事件。当您单击其中一个结果时,可以触发自动完成类getPlace()函数并获取坐标和其他字段

handlePlaceChanged() {
    const place = this.autocomplete.getPlace();
    this.props.onPlaceChanged(place);
  } 
handlePlaceChanged() {
    const place = this.autocomplete.getPlace();
    this.props.onPlaceChanged(place);
  }