I have a mapview with overlay items in it. These overlay can be tapped then show a fragmentactivity within the mapview. The problem is that when the fragmentactivity has been dismissed, mapview returns the focus to my current location. I want to return the focus on the tapped overlay item. How can this be done? Your answers will be highly appreciated. Thanks

This is the code I have but it isn't working.

final DefaultItemizedOverlay overlay = new DefaultItemizedOverlay(trafficProfileMarkerOverlay);

        final OverlayItem overlayItem = new OverlayItem(geopoint, "", "");      
        overlay.addItem(overlayItem);

        overlay.setTapListener(new ItemizedOverlay.OverlayTapListener() {
            @Override
            public void onTap(GeoPoint pt, MapView mapView) {
                Intent trafficProfileIntent = new Intent(getApplicationContext(), TrafficProfilePopUpActivity.class);
                startActivity(trafficProfileIntent);overlay.setFocus(overlayItem);
            }
        });         
        mapView.getOverlays().add(overlay);
有帮助吗?

解决方案

Before your TrafficProfilePopUpActivity gets open , you can store your GeoPoint in some variable.

and when user comes to map activity you can use CameraUpdateFactory.newCameraPosition to move map camera to your geopoint stored in variable before in OnResume() method.

Happy To Help.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top