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 7017547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:55:42+00:00 2026-05-27T22:55:42+00:00

I have set up a MapView Class which has Overlays (and they’re working fine.)

  • 0

I have set up a MapView Class which has Overlays (and they’re working fine.)

My application is built around tabs and on my first tab, this is my code:

 public void onCreate(Bundle savedInstanceState) {
        Button ButtonName1;
        Button ButtonName2;

        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout);

        {
        ButtonName1 = (Button) findViewById(R.id.ButtonName1);
        ButtonName1.setOnClickListener(new OnClickListener() {
          public void onClick(View arg0) {
            Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:51.594748,-0.107879"));
            i.setClassName("my.android.project", "my.android.project.Map"); // .Map is my MapView file
            startActivity(i);
          }
        });
        }
        {
        ButtonName2 = (Button) findViewById(R.id.ButtonName2);
        ButtonName2_Cinema.setOnClickListener(new OnClickListener() {
            public void onClick(View arg1) {
                Intent ii = new Intent(Intent.ACTION_VIEW, Uri.parse("51.55748,0.07388"));
                ii.setClassName("my.android.project", "my.android.project.Map");
                startActivity(ii);
              }
            });
        }
          }

}

Now by clicking on those buttons, it successfully leads me onto the Map class and my overlays are displayed perfectly well, in the correct position, but it doesn’t point me to that those exact latitude and longitude positions, therefore, not directly onto the overlays.

Does anyone know why?

Here’s my MapClass:

public class Map extends MapActivity {

private MapView mapView;


public static int latitude1 = (int) (51.508170 * 1E6);
public static int longitude1 = (int) (-0.128017 * 1E6);



@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.map_layout);

    mapView = (MapView) findViewById(R.id.mapview);       
    mapView.setBuiltInZoomControls(true);

    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
    OverlayMap itemizedOverlay = new OverlayMap(drawable, this);


    GeoPoint location1 = new GeoPoint(latitude1, longitude1);
    OverlayItem overlayitem = new OverlayItem(location1, "Title", "Contents");
    itemizedOverlay.addOverlay(overlayitem);


    mapOverlays.add(itemizedOverlay);

    MapController mapController = mapView.getController();

    GeoPoint yourGeoPoint = new GeoPoint(latitude1,longitude1);
    mapController.animateTo(yourGeoPoint);
    mapController.setZoom(10);

}

@Override
protected boolean isRouteDisplayed() {
    return true;
}

}

  • 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-27T22:55:43+00:00Added an answer on May 27, 2026 at 10:55 pm

    Are you using animateTo(GeoPoint geoPoint) method to go to your geo point?

    EDIT:

    You have to do something like this in your MapActivity, you can put the code in onCreate():

    GeoPoint yourGeoPoint = new GeoPoint(yourLatitude*1E6, yourLongitude*1E6);
    yourMapViewControler.animateTo(yourGeoPoint);
    

    I don’t know exactly how is your MapActivity to help you better but the thing is that you have to put the code above in the MapActivity where you have access to your map controler and the new coordinates (I think in onCreate() ).

    EDIT II :

    I think you are not sending correctly the longitude and latitude through your intent.

    You have to make use of a Bundle to do that. Please read this article for more details..

    EDIT III :

    Ok so you should do this to pass your geopoints to the next activity:
    In your button click listener you should write this:

    /* create a intent to start the new activity */
    Intent intent = new Intent(this, YourMapActivity.class);
    /* create a bundle to pass data to your next activity */
    Bundle bundle = new Bundle();
    /* put the latitude and longitude values into the bundle */
    bundle.putInt("latitude_key", yourLatitudeValue); 
    bundle.putInt("longitude_key", yourLongitudeValue);
    /* include the bundle into your intent */
    intent.putExtras(bundle);
    /* start your MapActivity */
    startActivity(intent);
    

    Ok so now we have to get the data from the bundle and use it on your map.. The following code is for your MapActivity in onCreate() method:

    /* get the bundle from the button activity */
    Bundle bundle = getIntent().getExtras();
    /* get the latitude and longitude based on the same key you put in the ButtonActivity to send the data */
    int latitude = bundle.getInt("latitude_key", 0);
    int longitude = bundle.getInt("longitude_key", 0);
    /* put the data into a GeoPoint and make the animation */
    GeoPoint yourGeoPoint = new GeoPoint(latitude * 1E6, longitude * 1E6);
    yourMapViewControler.animateTo(yourGeoPoint);
    

    The ButtonActivity is the activity on which you have the buttons :). Note that you have to use the same key strings in your bundle to get the correct data, just like in the example above.

    I hope now everything is clear :D.

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

Sidebar

Related Questions

I have set up a Django application that uses images. I think I have
How does one set the zoom level on a mapview? I have a map
I have a MKMapView with it's delegate set to my controller (m) class. Code
In ViewPagerAdapter.class I have 2 layout(whereami.xml and mapview.xml), and use LayoutInflater to inflate each
I have enabled the built in zoom controls in my google maps application, however,
I'm developing on an app that is location-based, I have a mapView set to
I have an MKMapView whose delegate is set in Interface Builder and which is
I have written an app which displays the location of a set of traffic
I have a view controller with an MKMapView that calls [self.mapView setRegion:region animated:YES]; which
I am building a Tab Bar App and have a MapView set up on

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.