开发者

How do I set streetView in my mapview

can my MapView show Google map tiles at streetView level if the emulator cannot connect to the internet? Because my code below aint working!!

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 a开发者_如何学运维ndroid.widget.LinearLayout;

public class HelloMapView extends MapActivity {
    private static MapController myMapController = null;
    private static GeoPoint geoPoint = new GeoPoint((int)(25.24243399999999 * 1E6),(int)(55.30611937301637 * 1E6));

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        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.androidmarker);
        HelloItemizedOverlay itemizedOverlay = new HelloItemizedOverlay(drawable);
        OverlayItem overlayItem = new OverlayItem(geoPoint,"abc","");
        itemizedOverlay.addoverlay(overlayItem);
        mapOverlays.add(itemizedOverlay);
        //mapView.setSatellite(true);
        mapView.setStreetView(true);




    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

The other class that extends ItemizedOverlay

package com.HelloMapView;

import java.util.ArrayList;

import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class HelloItemizedOverlay extends ItemizedOverlay {
    private ArrayList<OverlayItem> mOverlay=new ArrayList<OverlayItem>();
    public HelloItemizedOverlay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
    }
    @Override
    protected OverlayItem createItem(int i) {
        return mOverlay.get(i);
    }
    @Override
    public int size() {
        return mOverlay.size();
    }
    public void addoverlay(OverlayItem overlay)
    {
        mOverlay.add(overlay);
        populate();
    }

}

Somebody please lend me a hand. Plus eclipse says setStreetView is deprecated and is not supported anymore. I dont know if I am alone in this because other forums are saying my problem is that i should use setStreetView from the MapView class. But it is deprecated, I dont know if they know this or not!! Thanx in advance.


It is deprecated, but setStreetView is not what it seems anyway, it only showed a indicator whether street view tiles "were" available for a specific street, it did not not actually show street view tiles.

Google does not expose a way to get the streeview camera for the android API, you may only show satellite or 2d map view. This plus a lot of other features sadly are not available from Google Maps for our use.

And for the other two modes you always need an internet connection

Reference setStreetView

Notice that it says Control whether Street View availability (blue outlines) is shown on the map in other words it would draw a blue outline around streets that you could obtain street view for, well at least for google maps, but not via the Android API

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜