user2566397
user2566397

Reputation: 119

How convert the code of the google maps api v1 to v2?

How can I do this on Google Maps API v2?

    MapView mv = (MapView) findViewById(R.id.mvGoogle);
    mv.setBuiltInZoomControls(true);
    MapController mc = mv.getController();
    ArrayList all_geo_points = getDirections(17.3849, 78.4866, 28.63491, 77.22461);
    GeoPoint moveTo = all_geo_points.get(0);
    mc.animateTo(moveTo);
    mc.setZoom(12);
    mv.getOverlays().add(new MyOverlay(all_geo_points));

Upvotes: 0

Views: 729

Answers (1)

Mukesh
Mukesh

Reputation: 402

Use FragmentActivity and in onCreate() method:

GoogleMap mMap =((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

ArrayList <LatLng> all_geo_points  = new ArrayList<LatLng>();

all_geo_points.add(new LatLng(17.3849, 78.4866));

all_geo_points.add(new LatLng(28.63491, 77.22461));

LatLng moveTo = all_geo_points.get(0);

CameraPosition cameraPosition = new CameraPosition.Builder().target(moveTo).zoom(12).build();

mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

Check map v2 demo.

Upvotes: 1

Related Questions