Question

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);
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top