下一个 &给定 IP 或纬度/经度的最近 Google 街景

发布于 2024-10-01 22:37:48 字数 215 浏览 0 评论 0原文

我使用 ipinfodb.com 一段时间来从用户 IP 获取纬度和经度来查看 google 街景。但最近 ipinfodb 改变了他们的数据库,大部分纬度/经度值都改变了,因此我看不到街景。

我正在使用“Google Maps Javascript API V3 Services”,但不确定如何前往下一个和最近的可能的 GoogleStreetview。可以请您推荐一下吗?

问候

I'm using ipinfodb.com for a while to get the Latitude and Longitude from the user IP to view the google streetview. But recently ipinfodb has changed their database, and most the latitude/longitude values are changed, because of which I dont get the streetview.

I'm using "Google Maps Javascript API V3 Services" but not sure on how to the next and nearest possible GoogleStreetview. Could you please suggest.

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笔芯 2024-10-08 22:37:48

该 API 在 StreetViewService 类中有一个 getPanoramaByLocation 方法,

如下所示如何获取给定 latLng 位置周围给定半径内的街景的示例,请注意,如果半径小于 50 米,将返回最近的全景图

var streetViewService = new google.maps.StreetViewService();
streetViewService.getPanoramaByLocation(latLng, radius, function(data, status)
{
    if (status == google.maps.StreetViewStatus.OK)
    {
        var nearStreetViewLocation = data.location.latLng;              
        //...
    }
});          

The API has a getPanoramaByLocation method in StreetViewService Class

Below is an example of how to get a streetview within a given radius around the given latLng position, note that if the radius is less than 50 meters the nearest panorama will be returned

var streetViewService = new google.maps.StreetViewService();
streetViewService.getPanoramaByLocation(latLng, radius, function(data, status)
{
    if (status == google.maps.StreetViewStatus.OK)
    {
        var nearStreetViewLocation = data.location.latLng;              
        //...
    }
});          
神妖 2024-10-08 22:37:48

radius 不保证最近的街道视图点。例如:如果视点距离 10m,但您将半径定义为 1000,则不会选择最近的点。因此,如果你有几个点(有些非常接近,有些非常远),那么我仍然会使用迭代:

var streetViewService = new google.maps.StreetViewService();
var radius = 10;

streetViewService.getPanoramaByLocation(latLng, radius, handler);

function handler(data, status) {
    if (status == google.maps.StreetViewStatus.OK) {
        var nearStreetViewLocation = data.location.latLng;              
        //...
    } else {
        radius += 50;
        streetViewService.getPanoramaByLocation(latLng, radius, handler);
    }
}; 

radius doesn't guarantee the closest street view point. For example: if the view point is 10m away but you define your radius as 1000 then the closest isn't selected. So if you have several points (some really close, some really far) then I would still use iteration:

var streetViewService = new google.maps.StreetViewService();
var radius = 10;

streetViewService.getPanoramaByLocation(latLng, radius, handler);

function handler(data, status) {
    if (status == google.maps.StreetViewStatus.OK) {
        var nearStreetViewLocation = data.location.latLng;              
        //...
    } else {
        radius += 50;
        streetViewService.getPanoramaByLocation(latLng, radius, handler);
    }
}; 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文