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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:19:09+00:00 2026-06-11T10:19:09+00:00

I have a MapView when parsing one geopoint from a JSON file the drawable

  • 0

I have a MapView when parsing one geopoint from a JSON file the drawable looks normal, But when I parse all the geopoints for a mapset the drawable icon looks ugly and disfifgured? what would be causing this? I am using the MapView Ballons Library as well. MapView Ballons

Disfigured Map Pin Code

public class ViewAll  extends MapActivity

{   static final String KEY_MAPNAME = "name";
static final String KEY_MAPLOCATION = "address";
static final String KEY_MAPLONG = "longitude";
static final String KEY_MAPLAT = "latitude";
static final String KEY_MAPSETMAPSET = "";

TapControlledMapView mapView; // use the custom TapControlledMapView
List<Overlay> mapOverlays;
Drawable drawable;

SimpleItemizedOverlay itemizedOverlay;



;

 @Override
 public void onCreate(Bundle savedInstanceState)
 {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.maps);

 Intent in = getIntent();
    String mapset = in.getStringExtra(KEY_MAPSETMAPSET);

    mapView = (TapControlledMapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(false);
    // dismiss balloon upon single tap of MapView (iOS behavior) 
    mapView.setOnSingleTapListener(new OnSingleTapListener() {      
        public boolean onSingleTap(MotionEvent e) {
            itemizedOverlay.hideAllBalloons();
            return true;
        }
    });

    mapOverlays = mapView.getOverlays();

    // first overlay
    drawable = getResources().getDrawable(R.drawable.marker2);



    itemizedOverlay = new SimpleItemizedOverlay(drawable, mapView);
    // set iOS behavior attributes for overlay
    itemizedOverlay.setShowClose(false);
    itemizedOverlay.setShowDisclosure(true);
    itemizedOverlay.setSnapToCenter(false); 

try {

          JSONObject jOBj;
          JSONArray  jsonArray;
          JSONArray jarray=new JSONArray(mapset);

          for(int j=0;j<jarray.length();j++){
                jOBj=jarray.getJSONObject(j);
                jsonArray = jOBj.getJSONArray("locations");
                  for(int i=0;i < jsonArray.length();i++){                     



                    JSONObject maps = jsonArray.getJSONObject(i);

                  String.valueOf(i);



                    String latitude = maps.getString("latitude");
                    String longitude = maps.getString("longitude");
                    String name = maps.getString("name");
                    String address = maps.getString("address");

                    double lat = Double.parseDouble(latitude);
                    double lng = Double.parseDouble(longitude);
                    GeoPoint point = new GeoPoint(
                             (int) (lat * 1E6), 
                             (int) (lng * 1E6));
                    OverlayItem overlayItem = new OverlayItem(point, name, 
                            address);
                    itemizedOverlay.addOverlay(overlayItem);



                    mapOverlays.add(itemizedOverlay);

                    // second overlay


                    if (savedInstanceState == null) {

                        final MapController mc = mapView.getController();
                        mc.animateTo(point);
                        mc.setZoom(2);

                    } else {

                        // example restoring focused state of  overlays
                        int focused;
                        focused =  savedInstanceState.getInt("focused_1", -1);
                        if (focused >= 0) {
                             itemizedOverlay.setFocus(itemizedOverlay.getItem(focused));
                        }

                        }


             RadioGroup radGrp = (RadioGroup) findViewById(R.id.map_type);
             int checkedRadioButtonID = radGrp.getCheckedRadioButtonId();
             radGrp.setOnCheckedChangeListener(new  RadioGroup.OnCheckedChangeListener() {
               public void onCheckedChanged(RadioGroup arg0, int id) {
                 switch (id) {

                 case R.id.maps:
                     mapView.setSatellite(false);
                   break;
                 case R.id.satellite:
                     mapView.setSatellite(true);
                   break;

                 default:
                     mapView.setSatellite(false);
                   break;
                 }
               }
             });    }   













              }




 }catch(JSONException e)        {
   Log.e("log_tag", "Error parsing data "+e.toString());
 }
}


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

Normal Map Pin code

public class Maps  extends MapActivity



{
static final String KEY_MAPSETMAPSET = "";
static final String KEY_MAPNAME = "name";
static final String KEY_MAPLOCATION = "address";
static final String KEY_MAPLONG = "longitude";
static final String KEY_MAPLAT = "latitude";


TapControlledMapView mapView; // use the custom TapControlledMapView
List<Overlay> mapOverlays;
Drawable drawable;
Drawable drawable2;
SimpleItemizedOverlay itemizedOverlay;
SimpleItemizedOverlay itemizedOverlay2;




 @Override
 public void onCreate(Bundle savedInstanceState)
 {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.maps);

 Intent in = getIntent();
    String name = in.getStringExtra(KEY_MAPNAME);
    String address = in.getStringExtra(KEY_MAPLOCATION);
    String longitude = in.getStringExtra(KEY_MAPLONG);
    String latitude = in.getStringExtra(KEY_MAPLAT);





    mapView = (TapControlledMapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        mapView.setSatellite(false);
        // dismiss balloon upon single tap of MapView (iOS behavior) 
        mapView.setOnSingleTapListener(new OnSingleTapListener() {      
            public boolean onSingleTap(MotionEvent e) {
                itemizedOverlay.hideAllBalloons();
                return true;
            }
        });

        mapOverlays = mapView.getOverlays();

        // first overlay
        drawable = getResources().getDrawable(R.drawable.marker2);



        itemizedOverlay = new SimpleItemizedOverlay(drawable, mapView);
        // set iOS behavior attributes for overlay
        itemizedOverlay.setShowClose(false);
        itemizedOverlay.setShowDisclosure(true);
        itemizedOverlay.setSnapToCenter(false);
        double lat = Double.parseDouble(latitude);
        double lng = Double.parseDouble(longitude);

        GeoPoint point = new GeoPoint(
                 (int) (lat * 1E6), 
                 (int) (lng * 1E6));
        OverlayItem overlayItem = new OverlayItem(point, name, 
                address);
        itemizedOverlay.addOverlay(overlayItem);



        mapOverlays.add(itemizedOverlay);

        // second overlay


        if (savedInstanceState == null) {

            final MapController mc = mapView.getController();
            mc.animateTo(point);
            mc.setZoom(16);

        } else {

            // example restoring focused state of overlays
            int focused;
            focused = savedInstanceState.getInt("focused_1", -1);
            if (focused >= 0) {
                itemizedOverlay.setFocus(itemizedOverlay.getItem(focused));
            }

            }


 RadioGroup radGrp = (RadioGroup) findViewById(R.id.map_type);
 int checkedRadioButtonID = radGrp.getCheckedRadioButtonId();
 radGrp.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
   public void onCheckedChanged(RadioGroup arg0, int id) {
     switch (id) {

     case R.id.maps:
         mapView.setSatellite(false);
       break;
     case R.id.satellite:
         mapView.setSatellite(true);
       break;

     default:
         mapView.setSatellite(false);
       break;
     }
   }
 });    }   







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

    @Override
    protected void onSaveInstanceState(Bundle outState) {

        // example saving focused state of overlays
        if (itemizedOverlay.getFocus() != null) outState.putInt("focused_1", itemizedOverlay.getLastFocusedIndex());
        super.onSaveInstanceState(outState);

    }



  }

Normal Map Pin
Disfigured Map Pin

  • 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-11T10:19:10+00:00Added an answer on June 11, 2026 at 10:19 am

    You are adding repeatedly the itemizedOverlay to mapview overlays, everytime you add an item to it.

    Move the line:

    mapOverlays.add(itemizedOverlay); 
    

    to just after it has been created, before you start the Try Catch statement and it should work fine.

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

Sidebar

Related Questions

I have a MapView where Drawable markers are placed with a limit set to
I have a FrameLayout view which contains one (MapView-like) control and some additional buttons
I have used MKReverseGeocoder from iPhone sdk for my application without using mapview of
I have A MapView with Multiple annotations. But I need to put different images
I have a MapView in which I place some ca. 200 Overlays , all
I have a mapview where i update my currentlocation with CoreLocation, but I also
I have a MapView in which I am drawing buildings on using geopoints. Currently,
Hi i have a problem with pasing values to one class from other. Basically
I have a mapview , with itemizedoverlay , like on Android developers example. But
I have a mapview and i wish to display a ContextMenu when longclick but

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.