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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:19:50+00:00 2026-05-23T13:19:50+00:00

Please help me out, I am working on a Project Xyz having the mapView

  • 0

Please help me out, I am working on a Project Xyz having the mapView with add multiple overlays and remove overlays as per userChoice.

To be more clear it filters the overlays as per user choice,,,,

Suppose showing favorite places, friends of a user…

PostLoginServiceHomeBean is my ArrayList with an ArrayList NearByFavoritePlacesList object

entry.getNearByFavoritePlacesList().get(i).getGpsLatitude()
.trim()

i.e by this i’m getting the multiple lat long form server…

The code runs f9 and add the multiple overlays to my map and shows name and address of repective place on overlay tap.But how could I remove the overlays form my map…

I am enclosing the code:Please find the code below:

Please help me out….

package com.gogozing.app;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;

import com.gogozing.service.LocateServices;
import com.gogozing.util.Data;
import com.gogozing.util.PostLoginServiceHomeBean;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class HomeMapActivity extends MapActivity {
    private MapView myMapView;
    private MapController myMapController;
    private List<Overlay> mapOverlays;
    private HomeMapItemizedOverlay itemizedOverlay;
    private Context context;
    private PostLoginServiceHomeBean entry;
    private GeoPoint initGeoPoint;
    private CheckBox peopleCheckBox, friendsCheckBox, favoritesCheckBox;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home_map_layout);
        context = this;
        backButton = (Button) findViewById(R.id.HomeMapLeftBackButton);
        eventsBtn = (Button) findViewById(R.id.EventsBtn);
        profileBtn = (Button) findViewById(R.id.ProflieBtn);
        homeBtn = (Button) findViewById(R.id.HomeBtn);
        locateButton = (Button) findViewById(R.id.LocateBtn);
        socializeButton = (Button) findViewById(R.id.SocializeBtn);
        peopleCheckBox = (CheckBox) findViewById(R.id.HomeMapViewPeopleCheckBox);
        favoritesCheckBox = (CheckBox) findViewById(R.id.HomeMapViewFavoritesCheckBox);
        friendsCheckBox = (CheckBox) findViewById(R.id.HomeMapViewFriendsCheckBox);


        homeBtn.setBackgroundResource(R.drawable.home_f);
        myMapView = (MapView) findViewById(R.id.mapviewHome);


        myMapView.setBuiltInZoomControls(true);
        // Set satellite view
        myMapController = myMapView.getController();

        // Get the current location in start-up
        try {

            entry = Data.postLoginServiceHomeMain.get(0);

            favoritesCheckBox
                    .setOnCheckedChangeListener(new OnCheckedChangeListener() {
                        public void onCheckedChanged(CompoundButton buttonView,
                                boolean isChecked) {
                            if (isChecked) {
                                viewFavoritePlaces();
                            } else
                                removeFavoritePlaces();

                        }
                    });

        } catch (Exception e) {
            Log.e(Data.LOG, e.getMessage(), e);
        }
    }

    void viewFavoritePlaces() {
        for (int i = 0; i < entry.getNearByFavoritePlacesList().size(); i++) {
            double latitude = Double.valueOf(
                    **entry.getNearByFavoritePlacesList().get(i).getGpsLatitude()
                            .trim()**).doubleValue();
            double longitude = Double.valueOf(
                    entry.getNearByFavoritePlacesList().get(i)
                            .getGpsLongitude().trim()).doubleValue();
            Log.v(Data.LOG1, " Latitude " + latitude + " Longitude "
                    + longitude);

            String name = entry.getNearByFavoritePlacesList().get(i)
                    .getMerchantName();
            String address = entry.getNearByFavoritePlacesList().get(i)
                    .getAddress();
            initGeoPoint = new GeoPoint((int) (latitude * 1E6),
                    (int) (longitude * 1E6));

            mapOverlays = myMapView.getOverlays();
            Drawable drawable = this.getResources().getDrawable(
                    R.drawable.map_store_place);

            itemizedOverlay = new HomeMapItemizedOverlay(drawable, this);
            OverlayItem overlayItem = new OverlayItem(initGeoPoint, name,
                    address);

            itemizedOverlay.addOverlay(overlayItem);

            mapOverlays.add(itemizedOverlay);
            myMapController.animateTo(initGeoPoint);
            myMapController.setZoom(15);
        }
    }
    void removeFavoritePlaces() {
        //List<Overlay> mapOverlays = myMapView.getOverlays();

        mapOverlays.remove(itemizedOverlay);

    }



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

    public class HomeMapItemizedOverlay extends ItemizedOverlay<OverlayItem> {
        private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
        private Context mContext;

        public HomeMapItemizedOverlay(Drawable defaultMarker, Context context) {
            super(boundCenterBottom(defaultMarker));
            mContext = context;
        }

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

        @Override
        protected OverlayItem createItem(int i) {
            return mOverlays.get(i);
        }

        @Override
        public int size() {
            return mOverlays.size();
        }

        @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;
        }
    }

}
  • 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-23T13:19:51+00:00Added an answer on May 23, 2026 at 1:19 pm

    Here I am giving one solution what I am getting from your question… You need to add Lat Long into Overlay item which is coming from server and add it to itemized overlay, after that when ever you would like to remove any Itemizedoverlay with specific lat long you can check and remove from map overlay as well.

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

Sidebar

Related Questions

Please help me out here because im getting kind of confused.. I have a
I asked this question yesterday, looking if more people can help me out. I
Please help me understand why this isn't working. I don't know if there is
I’m quite new to Silverlight. I’m working for a project which mainly depends on
I am working on one project for performance enhancement. I had one doubt, while
I'm currently working on a project were we use freemarker as a template language.
While working with project I upgraded the version of IOS SDK 3.2 to 4.2
I am working in one iPhone application in which I need to add inApp
I am going to start working on a website that has already been built
I installed Scala IDE for Eclipse , and it seems to be working okay.

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.