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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:42:11+00:00 2026-06-11T09:42:11+00:00

I have the following problem with mapView in eclipse/java. Using mapView.getOverlays() I get the

  • 0

I have the following problem with mapView in eclipse/java.

Using mapView.getOverlays() I get the error.

mapView cannot be resolved

I tried to use a local variable for mapView (using MapView) but it crashes.
Is mapView declared somewhere ?

I import com.google.android.maps.MapView;

but I can’t access the code and the offcial doc did not help

and MapView cannot be resolved or is not a field did not help too

I have installed the SDK and checked Google API in Eclipse

project build target

I can display a map without problem

and my MainActivity extends MapActivity

Here is the full code

package com.example.test_app;

import java.util.List;

import android.app.Activity;
import com.example.test_app.MyLocation;
import com.example.test_app.MyLocation.LocationResult;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

import android.content.Context;

import android.location.Location;
import android.location.LocationProvider;

import android.location.LocationListener;

import android.location.LocationManager;

import android.os.Bundle;

import android.widget.Toast;

public class MainActivity extends MapActivity

{


/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState)

{

    super.onCreate(savedInstanceState);
    MapView mapView = (MapView) findViewById(R.id.mapview);
    if (mapView == null)
        Toast.makeText(getApplicationContext(),"mapview is null",Toast.LENGTH_SHORT).show();
    else
        mapView.setBuiltInZoomControls(true);

    setContentView(R.layout.activity_main);

    LocationResult locationResult = new LocationResult(){
        @Override
        public void gotLocation(Location loc){
            Toast.makeText(getApplicationContext()," long : " +loc.getLongitude()+ " lat :"+ loc.getLatitude(),Toast.LENGTH_SHORT).show();
            //List<Overlay> mapOverlays = mapView.getOverlays();
        }
    };
    MyLocation myLocation = new MyLocation();
    myLocation.getLocation(this, locationResult);

}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}/* End of UseGps Activity */
  • 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-06-11T09:42:13+00:00Added an answer on June 11, 2026 at 9:42 am

    Add this in Your menifest

    <uses-library android:name="com.google.android.maps"/>
    

    in your layout

    <com.google.android.maps.MapView
        android:id="@+id/mv"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="---- Your Key -------"
        />
    

    You have a sily mistake. Move your setContentView above the declairation of the MapView. For that reason it gettting that error

    super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_map);
    
            MapView mapView = (MapView) findViewById(R.id.mv);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using GWT/JAVA for development. I have following problem: I want to remove
I have following problem with using cucumber and jRuby under windows: load error: bundler/definition
I have the following problem. I have embedded a map using Google Maps' API.
I have the following problem, from c++ I send huge string[] to java. huge
i have following problem To decode the Biquinary code use the number 5043210. At
I have following problem. I use this tutorial to creating a multiple file uploader:
I have following problem. I worked two days on a solution but I cannot
I have following problem to be solved in java: Implement class Alkio. Test with
I have the following problem using subversion: I'm currently working on the trunk of
I have following Problem: First up... i use MagicalRecord for the whole CoreData thing

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.