Sunday, 22 November 2015

XML : Converting the code of google maps v1 to google maps v2 so I can replace MapController?

How can I do this on Google Maps API v2? I have already updated my xml layout to included code for Google maps V2.But I am not sure how to replace MapContoller, mapView etc to update to V2. I am new to Android so please bare with me. Thanks for your help in advance.

MapController mapController; Location latestLocation, targetLocation;

      /** Called when the activity is first created. */      @Override      public void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.activity_main);            // Get a reference to the MapView          MapView myMapView = (MapView)findViewById(R.id.myMapView);          // Get the Map View�s controller          mapController = myMapView.getController();          // Configure the map display options          myMapView.setSatellite(true);          myMapView.displayZoomControls(false);          // Zoom in          mapController.setZoom(19);            // Add the MyPositionOverlay          List<Overlay> overlays = myMapView.getOverlays();          MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, myMapView);          overlays.add(myLocationOverlay);          //myLocationOverlay.enableCompass();          myLocationOverlay.enableMyLocation();            LocationManager locationManager;          String context = Context.LOCATION_SERVICE;          locationManager = (LocationManager)getSystemService(context);            Criteria criteria = new Criteria();          criteria.setAccuracy(Criteria.ACCURACY_FINE);          criteria.setAltitudeRequired(false);          criteria.setBearingRequired(false);          criteria.setCostAllowed(true);          criteria.setPowerRequirement(Criteria.POWER_LOW);          String provider = locationManager.getBestProvider(criteria, true);          latestLocation = locationManager.getLastKnownLocation(provider);          updateWithNewLocation(latestLocation);            locationManager.requestLocationUpdates(provider, 2000, 10, locationListener);        }    

No comments:

Post a Comment