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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:40:08+00:00 2026-06-04T04:40:08+00:00

So I’m just trying to create a generic mapView in android and put a

  • 0

So I’m just trying to create a generic mapView in android and put a few geopoints in it. I’ve followed the instructions from the android developer website and had no success… can anyone help? here is my code.

public class HelloItemizedOverlay extends ItemizedOverlay {

    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    Context mContext;

    public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
        // defines the bounds for the overlayItems
        super(boundCenterBottom(defaultMarker));
        mContext = context;
    }

    @Override
    protected OverlayItem createItem(int i) {
        // returns the correct ArrayList position from int i
        return mOverlays.get(i);
    }

    @Override
    public int size() {
        // returns number of items in ArrayList
        return mOverlays.size();
    }

    public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
    }

    @Override
    protected boolean onTap(int index) {
        OverlayItem item = mOverlays.get(index);
        AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
        dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();
        return true;
    }

}

//Here’s my main class

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.maptastic);
        ((TextView)((FrameLayout)((LinearLayout)((ViewGroup) getWindow().getDecorView()).getChildAt(0)).getChildAt(0)).getChildAt(0)).setGravity(Gravity.CENTER);
        setTitle("Field Trip");

        Drawable drawable = this.getResources().getDrawable(R.drawable.supaaaa);
        HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this);
        //initControls();

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

        mapview.setBuiltInZoomControls(true);

        mcontroller = mapview.getController();
        // Plot all geo points
        for (Entry<Integer, FieldTripStop> cur : Statics.fieldTripStops.entrySet())
        {
            // get the FieldTripStop object from the current hash table entry
            Statics.currentFTStop = cur.getValue();
            // concatenate numbers before (all) and after (6) the decimal, since
            // geopoints only accept 6 numbers past the decimal.
            theLat = Statics.currentFTStop.latitude;
            theLong = Statics.currentFTStop.longitude;

            /*
             * String manipulation method
             * 
             * theLat = theLat.replace(".","");
             * theLat = theLat.substring(0, 8);
             * theLong = theLong.replace(".","");
             * theLong = theLong.substring(0, 8);
             * point = new GeoPoint((int)(Integer.valueOf(theLat)), (int)(Integer.valueOf(theLong))); 
             */

            theDLat = Double.parseDouble(theLat);
            theDLong = Double.parseDouble(theLong);



            //olay = new OverlayItem(point, "herp", "derp");
            //olayitems.add(olay);
            List<Overlay> mapOverlays = mapview.getOverlays();





            point = new GeoPoint((int)(theDLat*1E6), (int)(theDLong*1E6));
            OverlayItem overlayitem = new OverlayItem(point, "holda, Mundo!", "I'm in Mexico City~!");

            itemizedoverlay.addOverlay(overlayitem);
            mapOverlays.add(itemizedoverlay);

        }
  • 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-04T04:40:09+00:00Added an answer on June 4, 2026 at 4:40 am

    You need to a) use only a single HelloItemizedOverlay (instead one for each point) and b) add this overlay to the map before you add the markers (In your current code, the overlay is not yet associated with the map when populate is called, so the map does not receive any notification and doesn’t refresh itself).

    Some things to check:

    • Did you specify your api key for the MapView? *

    *) How to specify your api key (in the layout resource for your activity):

    <com.google.android.maps.MapView android:id="@+id/map"
        ...
        android:apiKey="your-api-key-here"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.