【问题标题】:how to call google api of near by placess如何调用附近地方的google api
【发布时间】:2017-01-09 07:27:46
【问题描述】:

我希望通过谷歌地图的地点API调用附近:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=17.4359,78.3417&radius=1000&type=school&key='KEY'

当我调用上面的链接时,它给出了结果,但是当我将上面的链接更改为下面的链接时

'http://maps.googleapis.com/maps/api/place/nearbysearch/json?location=latitude,longitude&type=school&key=KEY'

latitude=17.4359;longitude=78.3417 链接在位置结果数组附近没有给出。 我们不能发送纬度,经度动态吗?

我的代码是:

let latitude=this.lat;
    let longitude= this.lng



   return this.http.get('https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=latitude,longitude&radius=5000&type=school&sensor=false&key=Key')
    .map(response=>response.json())
    .subscribe(data=>{
        // console.log("sucess "+JSON.stringify(data.results))
        this.schools=data.results
         console.log("school length "+this.schools.length)}}

【问题讨论】:

    标签: angular google-maps-api-3 google-api


    【解决方案1】:

    是的,我们可以,但是您需要以正确的格式传递变量。 你的 lat 和 lon 变量是浮动的吗?

    【讨论】:

    【解决方案2】:

    在 2016 年之后,您的网站以及 google place url 需要在 ssl 中才能从 google map api 获取数据。

    确保您的网站已实施 ssl,并且您正在使用 https 调用 google place api

    【讨论】:

      猜你喜欢
      • 2019-10-31
      • 1970-01-01
      • 1970-01-01
      • 2018-12-27
      • 2017-06-12
      • 2018-06-20
      • 2012-06-10
      • 1970-01-01
      • 2013-06-27
      相关资源
      最近更新 更多