如果特定纬度的街景不可用,如何获取最近的可用街景?
If StreetView is not available for a specified latlong, how to get the nearest available StreetView?
这是我的代码
private static LatLng STREETVIEW = new LatLng(51.503635, -0.119781);
StreetViewPanorama streetViewPanorama;
StreetViewPanoramaView mStreetViewPanoramaView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_street_view);
mStreetViewPanoramaView = findViewById(R.id.streetviewpanorama);
mStreetViewPanoramaView.getStreetViewPanoramaAsync(this);
mStreetViewPanoramaView.onSaveInstanceState(savedInstanceState);
mStreetViewPanoramaView.onCreate(savedInstanceState);
}
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
this.streetViewPanorama = panorama;
panorama.setPosition(STREETVIEW, 20, StreetViewSource.OUTDOOR);
streetViewPanorama.setOnStreetViewPanoramaChangeListener(this);
}
@Override
public void onStreetViewPanoramaChange(StreetViewPanoramaLocation streetViewPanoramaLocation) {
if (streetViewPanoramaLocation != null && streetViewPanoramaLocation.links != null) {
Toast.makeText(StreetViewActivity.this, "StreetView available here.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(StreetViewActivity.this, "Street View not available on this location", Toast.LENGTH_SHORT).show();
//here, how to get nearest streetView within 100 meter distance .?
}
}
如果街景在当前经纬度上不可用。
我想要最近的 streetView(如果在 100 以内或任何指定的米内可用)。
我如何在 android 应用程序中实现这一点?
使用经纬度和半径检索街景。您正在调用此方法:
panorama.setPosition(STREETVIEW, 20, StreetViewSource.OUTDOOR);
获取20米以内的街景。
这里是方法的签名:public void setPosition (LatLng position, int radius, StreetViewSource source)
您需要传递 100 或您想要的任何其他数字作为半径,它会在给定 latlng 周围的该半径内找到街景。
例如,如果您想获得 100 米半径范围内的街景,请调用:
panorama.setPosition(STREETVIEW, 100, StreetViewSource.OUTDOOR);
这是我的代码
private static LatLng STREETVIEW = new LatLng(51.503635, -0.119781);
StreetViewPanorama streetViewPanorama;
StreetViewPanoramaView mStreetViewPanoramaView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_street_view);
mStreetViewPanoramaView = findViewById(R.id.streetviewpanorama);
mStreetViewPanoramaView.getStreetViewPanoramaAsync(this);
mStreetViewPanoramaView.onSaveInstanceState(savedInstanceState);
mStreetViewPanoramaView.onCreate(savedInstanceState);
}
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
this.streetViewPanorama = panorama;
panorama.setPosition(STREETVIEW, 20, StreetViewSource.OUTDOOR);
streetViewPanorama.setOnStreetViewPanoramaChangeListener(this);
}
@Override
public void onStreetViewPanoramaChange(StreetViewPanoramaLocation streetViewPanoramaLocation) {
if (streetViewPanoramaLocation != null && streetViewPanoramaLocation.links != null) {
Toast.makeText(StreetViewActivity.this, "StreetView available here.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(StreetViewActivity.this, "Street View not available on this location", Toast.LENGTH_SHORT).show();
//here, how to get nearest streetView within 100 meter distance .?
}
}
如果街景在当前经纬度上不可用。 我想要最近的 streetView(如果在 100 以内或任何指定的米内可用)。
我如何在 android 应用程序中实现这一点?
使用经纬度和半径检索街景。您正在调用此方法:
panorama.setPosition(STREETVIEW, 20, StreetViewSource.OUTDOOR);
获取20米以内的街景。
这里是方法的签名:public void setPosition (LatLng position, int radius, StreetViewSource source)
您需要传递 100 或您想要的任何其他数字作为半径,它会在给定 latlng 周围的该半径内找到街景。
例如,如果您想获得 100 米半径范围内的街景,请调用:
panorama.setPosition(STREETVIEW, 100, StreetViewSource.OUTDOOR);