这是我的代码
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 .?
}
}
如果当前的latlong无法使用街景视图。 我想要最近的StreetView(如果可以在100或任何指定的距离内找到)。
我该如何在android应用中实现这一目标?
答案 0 :(得分:1)
使用latlng和radius检索街景。您正在调用此方法:
panorama.setPosition(STREETVIEW, 20, StreetViewSource.OUTDOOR);
可在20米内获得街景。
以下是方法的签名:public void setPosition (LatLng position, int radius, StreetViewSource source)
您需要传递100或您想要的任何其他数字作为半径,它会在给定latlng周围的半径范围内找到街景。
例如,如果您想获得半径100m以内的街景,请致电:
panorama.setPosition(STREETVIEW, 100, StreetViewSource.OUTDOOR);