LA_
LA_

Reputation: 20429

How to display particular position on the MapView?

I have a position, which I need to display. The format is like:

lat: 59.915494, lng: 30.409456

Also I need to display current position of the user. The following code:

    MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);
    mapView.getOverlays().add(myLocationOverlay); 
    myLocationOverlay.enableMyLocation(); 

doesn't center map on the current position.

Upvotes: 0

Views: 1331

Answers (1)

CaseyB
CaseyB

Reputation: 25058

In order to adjust where the map is centered on or zoomed into you need to get the MapController.

MapController controller = mMapView.getController();
controller.animateTo(geoPoint);
// Or if you just want it to snap there
controller.setCenter(geoPoint);

controller.setZoom(5); 

That point that you want to show you're going to need to add an Overlay. Here is the documentation for that and a nice tutorial on how to do it.

Upvotes: 2

Related Questions