I am currently working on a project where the user can use Street View to locate a restaurant. Is there a way, using a maps API in JavaScript, to locate the nearest restaurant?

Basically, I want the user to hit a button, which places a pin on the nearest restaurant. I want the pin to be placed based on their street view location, not their real location. So you could be using it in Thailand but have street view enabled and be in London, so that it would find the nearest restaurant from there.

Any ideas how to get nearest restaurants?

Thanks.

有帮助吗?

解决方案

You can use google places API.

The response will contain a "geometry" property like the following :

     "geometry" : {
        "location" : {
           "lat" : -33.8731950,
           "lng" : 151.2063380
        }
     }

You can use those coordinates to create a link to streetview. See https://developers.google.com/maps/documentation/streetview/#url_parameters

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top