我正在研究一个Android项目,我需要设置我的地图放大并显示我的地图的更详细的视图,就像我希望我的坐标三角测量的街道。问题出在Mapview类中,不推荐使用setStreetView,是替代? 这就是setStreetView在我使用它时的样子。
package com.HelloMapView;
import java.util.List;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.LinearLayout;
public class HelloMapView extends MapActivity {
MapView mapview;
LinearLayout linearlayout;
List<Overlay> mapOverlay;
Drawable drawable;
HelloItemizedOverlay itemizedOverlay;
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapview=(MapView)findViewById(R.id.mapview);
mapview.setBuiltInZoomControls(true);
mapview.setStreetView(true);
mapOverlay=mapview.getOverlays();
drawable=this.getResources().getDrawable(R.drawable.androidmarker);
itemizedOverlay=new HelloItemizedOverlay(drawable);
GeoPoint geoPoint=new GeoPoint(19240000,-99120000);
OverlayItem overlayitem=new OverlayItem(geoPoint,"","");
itemizedOverlay.addoverlay(overlayitem);
mapOverlay.add(itemizedOverlay);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
这不起作用它只显示没有地图的方框
答案 0 :(得分:2)
我知道它迟到但对将来的其他人有帮助 如果你只看到灰色瓷砖而不是地图,那么问题在于你生成的密钥与代码无关,请参阅本教程了解kay http://www.youtube.com/watch?v=XdduYAs7klY这个用于街景http://mobiforge.com/developing/story/using-google-maps-android
答案 1 :(得分:0)
使用MapView的 setStreetView(boolean)。
答案 2 :(得分:0)
myMapView.setStreetView(true);
答案 3 :(得分:0)
公共类ABC扩展了MapActivity {
private static MapController myMapController = null;
private static GeoPoint geoPoint = new GeoPoint
( (int)(25.24243399999999 * 1E6),(int)(55.30611937301637 * 1E6));
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contact_us_layout);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.displayZoomControls(false);
mapView.setBuiltInZoomControls(true);
mapView.setFocusable(true);
myMapController = mapView.getController();
myMapController.animateTo(geoPoint);
myMapController.setZoom(15);
// mapView.invalidate();
// mapView.setFocusable(true);
myMapController.setCenter(geoPoint);
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(
R.drawable.mapmarker);
HelloItemizedOverlay itemizedOverlay = new HelloItemizedOverlay(
drawable, this);
OverlayItem overlayItem = new OverlayItem(geoPoint,
"abc");
itemizedOverlay.addOverlay(overlayItem);
mapOverlays.add(itemizedOverlay);
//mapView.setSatellite(true);
**mapView.setStreetView(true);**
公共类HelloItemizedOverlay扩展了ItemizedOverlay { private ArrayList mOverlays = new ArrayList(); private Context mContext;
public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
super(boundCenterBottom(defaultMarker));
mContext = context;
}
public void addOverlay(OverlayItem overlay) {
mOverlays.add(overlay);
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
@Override
public int size() {
return mOverlays.size();
}
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}
}
}
您好,,, 我发布了你想要的工作代码...... 如果您的地图没有显示任何内容。您的api密钥未正确签名。请再次签名并在mapView中提供。 如果你想使用streetView的地图: mapView.setStreetView(真) 如果你想使用地图的satelliteView: mapView.setSatellite(真)