How can I get city name from a latitude and longitude point?

后端 未结 11 1202
感情败类
感情败类 2020-11-28 03:07

Is there a way to get a city name from a latitude and longitude point using the google maps api for javascript?

If so could I please see an example?

11条回答
  •  攒了一身酷
    2020-11-28 03:16

    BigDataCloud also has a nice API for this, also for nodejs users.

    they have API for client - free. But also for backend, using API_KEY (free according to quota).

    Their GitHub page.

    the code looks like:

    const client = require('@bigdatacloudapi/client')(API_KEY);
    
    async foo() {
        ...
        const location: string = await client.getReverseGeocode({
              latitude:'32.101786566878445', 
              longitude: '34.858965073072056'
        });
    }
    

提交回复
热议问题