Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4032796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:45:59+00:00 2026-05-20T11:45:59+00:00

I have a function that shows a map page so I can get the

  • 0

I have a function that shows a map page so I can get the user to choose their current location. But if you run this function twice it crashes the App with the Single MapView in a MapActivity error (i.e. opening that settings view again).

public void showMapSetterPage(View v) {
    Log.i(DEBUG_TAG, "Settings screen, set map center launched");

    // Set which view object we fired off from
    set_pv(v);

    // Show Map Settings Screen
    setContentView(R.layout.set_map_center);

    // Initiate the center point map
    if (mapView == null) {
        mapView = (MapView) findViewById(R.id.mapview);
    }

    mapView.setLongClickable(true);
    mapView.setStreetView(true);
    mapView.setBuiltInZoomControls(false);
    mapView.setSatellite(false);

    mapController = mapView.getController();
    mapController.setZoom(18);

    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Location location = lm
            .getLastKnownLocation(LocationManager.GPS_PROVIDER);

    int lat = (int) (location.getLatitude() * 1E6);
    int lng = (int) (location.getLongitude() * 1E6);

    Log.i(DEBUG_TAG, "The LAT and LONG is: " + lat + " == " + lng);

    point = new GeoPoint(lat, lng);

    // mapController.setCenter(point);
    mapController.animateTo(point);
}

So I have a button that shows this View and onClick=”showMapSetterPage”. But if you go back to the settings screen out of the map and click the button again I get this error:

03-06 20:55:54.091:
ERROR/AndroidRuntime(28014): Caused
by: java.lang.IllegalStateException:
You are only allowed to have a single
MapView in a MapActivity

How can I delete the MapView and recreate it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:45:59+00:00Added an answer on May 20, 2026 at 11:45 am

    I think everyone was a little right, it seams like a flaw in the API to me. I should be able to inflate a view and use the map in it, if I recall the view then be able to delete it or review it again without error.

    The easiest workaround was to remove the inflation or setContentView using the xml and going with a dynamic build of the map, then storing that in memory.

    I removed:

    // Show Map Settings Screen
    setContentView(R.layout.set_map_center);
    
    // Initiate the center point map
    if (mapView == null) {
        mapView = (MapView) findViewById(R.id.mapview);
    }
    

    And replaced it with:

    if (mapView == null) {
       // public MapView mapView = null; // Public defined Variable
       mapView = new MapView(this, this.getString(R.string.APIMapKey));
    }
    
    setContentView(mapView);
    

    This works great and gives me chances to call the map. Thanks for responding everyone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that shows a map and a list of names. The
I have created a function that shows/hides different messages according to a combination of
I have a simple function that shows loading spinner while fetching data (usually takes
Inside my Controller i have function that runs after user clicks on item, which
So I have function that formats a date to coerce to given enum DateType{CURRENT,
I have a show page that should show a business and a google map
I have a html page that calls a php object to get some data
I am looking for a Google maps library/API/.NET function that simply shows the map
I have an archive page that shows custom posts, each of which has a
I have a codeigniter application.In that i call the controller function using ajax/jquery.But when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.