我正在開發需要顯示街景的Android應用程序,我決定使用谷歌街景API。但是,當我呼籲街景視圖功能,它會交換到「谷歌街景應用程序」,而不是我的應用程序裏面......關於谷歌街景(安卓)
是它可以顯示我的應用程序內的街景?
我正在開發需要顯示街景的Android應用程序,我決定使用谷歌街景API。但是,當我呼籲街景視圖功能,它會交換到「谷歌街景應用程序」,而不是我的應用程序裏面......關於谷歌街景(安卓)
是它可以顯示我的應用程序內的街景?
謝謝!我正在閱讀關於APIv3,謝謝:))! – Kennett
是啊!它可能我也正在開發一個基於谷歌街景和距離API的應用程序。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.ronak.justforclone.MapsActivity" >
<LinearLayout
android:id="@+id/map_container2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:orientation="vertical">
<fragment
android:id="@+id/streetviewpanorama"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
class="com.google.android.gms.maps.SupportStreetViewPanoramaFragment" />
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
class="com.google.android.gms.maps.SupportMapFragment"
map:cameraTargetLat="-33.87365"
map:cameraTargetLng="151.20689"
map:cameraZoom="15" />
</LinearLayout>
通過這個U可以進行佈局和Java
public class MapsActivity extends AppCompatActivity implements GoogleMap.OnMarkerDragListener, StreetViewPanorama.OnStreetViewPanoramaChangeListener {
private static final String MARKER_POSITION_KEY = "MarkerPosition";
// George St, Sydney
private static final LatLng SYDNEY = new LatLng(-33.87365, 151.20689);
private StreetViewPanorama mStreetViewPanorama;
private Marker mMarker;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
final LatLng markerPosition;
if (savedInstanceState == null) {
markerPosition = SYDNEY;
} else {
markerPosition = savedInstanceState.getParcelable(MARKER_POSITION_KEY);
}
SupportStreetViewPanoramaFragment streetViewPanoramaFragment =
(SupportStreetViewPanoramaFragment)
getSupportFragmentManager().findFragmentById(R.id.streetviewpanorama);
streetViewPanoramaFragment.getStreetViewPanoramaAsync(
new OnStreetViewPanoramaReadyCallback() {
@Override
public void onStreetViewPanoramaReady(StreetViewPanorama panorama) {
mStreetViewPanorama = panorama;
mStreetViewPanorama.setOnStreetViewPanoramaChangeListener(
MapsActivity.this);
// Only need to set the position once as the streetview fragment will maintain
// its state.
if (savedInstanceState == null) {
mStreetViewPanorama.setPosition(SYDNEY);
}
}
});
SupportMapFragment mapFragment =
(SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap map) {
map.setOnMarkerDragListener(MapsActivity.this);
// Creates a draggable marker. Long press to drag.
mMarker = map.addMarker(new MarkerOptions()
.position(markerPosition)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.pegman))
.draggable(true));
}
});
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(MARKER_POSITION_KEY, mMarker.getPosition());
}
@Override
public void onStreetViewPanoramaChange(StreetViewPanoramaLocation location) {
if (location != null) {
mMarker.setPosition(location.position);
}
}
@Override
public void onMarkerDragStart(Marker marker) {
}
@Override
public void onMarkerDragEnd(Marker marker) {
mStreetViewPanorama.setPosition(marker.getPosition(), 150);
}
@Override
public void onMarkerDrag(Marker marker) {
}
}
瞭解更多信息通過這個代碼U將得到類似的東西檢查此鏈接 https://developers.google.com/maps/documentation/android-api/streetview
:d
什麼是您的Google maps API版本n? –
v2。這已經是切入的版本。 – Kennett
我打算開發一個新版本,所以哪個版本的API也可用 – Kennett