简体   繁体   中英

OverlayItem looses focus when FragmentActivity Dismiss

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM