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

  • Home
  • SEARCH
  • 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 9069769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:30:59+00:00 2026-06-16T17:30:59+00:00

i tried to apply these codes that is in this link . But I’m

  • 0

i tried to apply these codes that is in this link. But I’m getting error like NullPointerException.

I use fragmentation and here is my function that is in my BaseFragment

 public void createMapViewForHaritaFragment(IlanList list)
{
    IlanList gelenListe;
    gelenListe=list;

    if(gelenListe!=null)
    {
        MainActivity parent = getParentActivity();
        mMapViewContainer = parent.getmMapViewContainer();
        mMapView = parent.getmMapView();

        /**/
            mc = mMapView.getController();

            LocationManager lm = (LocationManager) parent.getSystemService(parent.getApplicationContext().LOCATION_SERVICE); 
            Location location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            String longitude = String.valueOf(location.getLongitude()).substring(0, 9);
            String latitude = String.valueOf(location.getLatitude()).substring(0, 9);


            String coordinates[] = {latitude,longitude};
            double lat = Double.parseDouble(coordinates[0]);
            double lng = Double.parseDouble(coordinates[1]);

            p = new GeoPoint(
                (int) (lat * 1E6), 
                (int) (lng * 1E6));

            mc.animateTo(p);
            mMapView.setBuiltInZoomControls(true);      

            mMapView.setSatellite(false);               
            mc.setZoom(16);         




            /*Harita
            public View mMapViewContainer;
            public MapView mMapView;
            public MapController mc;
            public GeoPoint p;

            public List<Overlay> mapOverlays;
            public Drawable drawable;
            public MapItemizedOverlay itemizedOverlay;  
            Harita*/

            drawable = this.getResources().getDrawable(R.drawable.map_kirmizi_png);
            itemizedOverlay = new MapItemizedOverlay(drawable, parent.getApplicationContext(), 30);//text size: 30

            GeoPoint gPointMe = new GeoPoint(41099932,29002657);
            OverlayItem overlayItem = new OverlayItem(gPointMe, "Me", "This is my location");
            itemizedOverlay.addOverlay(overlayItem);    

            mapOverlays.add(itemizedOverlay);

            mMapView.setBuiltInZoomControls(true);

            //move map over to my position
            mc.animateTo(gPointMe);  



        mMapView.invalidate();
    }

}

And I think, I’m getting error while processing this code :

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

These are my LogCat.

12-21 12:35:53.443: E/AndroidRuntime(19782): FATAL EXCEPTION: main
12-21 12:35:53.443: E/AndroidRuntime(19782): java.lang.NullPointerException
12-21 12:35:53.443: E/AndroidRuntime(19782):    at com.mert.fragment.BaseFragment.createMapViewForHaritaFragment(BaseFragment.java:274)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at com.mert.fragment.impl.EtrafimdaHaritaFragment$MyHandler.handleMessage(EtrafimdaHaritaFragment.java:154)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at android.os.Looper.loop(Looper.java:143)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at android.app.ActivityThread.main(ActivityThread.java:4277)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at java.lang.reflect.Method.invokeNative(Native Method)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at java.lang.reflect.Method.invoke(Method.java:507)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-21 12:35:53.443: E/AndroidRuntime(19782):    at dalvik.system.NativeStart.main(Native Method)

Thanks for your help.

  • 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-16T17:31:01+00:00Added an answer on June 16, 2026 at 5:31 pm
            AddItemized Overlay class:
    
            public class AddItemizedOverlay extends ItemizedOverlay<OverlayItem> {
    
                private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();
    
                private Context context;
    
                public AddItemizedOverlay(Drawable defaultMarker) {
                     super(boundCenterBottom(defaultMarker));
                }
    
                public AddItemizedOverlay(Drawable defaultMarker, Context context) {
                     this(defaultMarker);
                     this.context = context;
                }
    
                @Override
                protected OverlayItem createItem(int i) {
                   return mapOverlays.get(i);
                }
    
                @Override
                public int size() {
                   return mapOverlays.size();
                }
    
                @Override
                protected boolean onTap(int index) {
                   Log.e("Tap", "Tap Performed");
                   return true;
                }
    
                public void addOverlay(OverlayItem overlay) {
                   mapOverlays.add(overlay);
                    this.populate();
                }
    
             }
    
    
        Use this code in your Activity
    
    
          List<Overlay> mapOverlays = mv.getOverlays();
                Drawable drawable = this.getResources().getDrawable(R.drawable.drawable);
                AddItemizedOverlay itemizedOverlay =
                new AddItemizedOverlay(drawable, this);
                OverlayItem overlayitem = new OverlayItem(gp, "Hello", "I am here");
                itemizedOverlay.addOverlay(overlayitem);
                mapOverlays.add(itemizedOverlay);
    
    
     public void createMapViewForHaritaFragment(IlanList list)
    {
        IlanList gelenListe;
        gelenListe=list;
    
        if(gelenListe!=null)
        {
            MainActivity parent = getParentActivity();
            mMapViewContainer = parent.getmMapViewContainer();
            mMapView = parent.getmMapView();
    
            /**/
                mc = mMapView.getController();
    
                LocationManager lm = (LocationManager) parent.getSystemService(parent.getApplicationContext().LOCATION_SERVICE); 
                Location location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                String longitude = String.valueOf(location.getLongitude()).substring(0, 9);
                String latitude = String.valueOf(location.getLatitude()).substring(0, 9);
    
    
                String coordinates[] = {latitude,longitude};
                double lat = Double.parseDouble(coordinates[0]);
                double lng = Double.parseDouble(coordinates[1]);
    
                p = new GeoPoint(
                    (int) (lat * 1E6), 
                    (int) (lng * 1E6));
    
            mc = mMapView.getController();
            mc.setCenter(p);
            mc.setZoom(16);
    
            List<Overlay> mapOverlays = mv.getOverlays();
            Drawable drawable = this.getResources().getDrawable(R.drawable.pin);
            AddItemizedOverlay itemizedOverlay = new AddItemizedOverlay(drawable,
                    this);
            OverlayItem overlayitem = new OverlayItem(p, "Hello", "I AM HERE");
            itemizedOverlay.addOverlay(overlayitem);
            mapOverlays.add(itemizedOverlay);
    
               /* mc.animateTo(p);
                mMapView.setBuiltInZoomControls(true);      
    
               mMapView.setSatellite(false);               
               mc.setZoom(16);   */      
    
    
    
    
                /*Harita
                public View mMapViewContainer;
                public MapView mMapView;
                public MapController mc;
                public GeoPoint p;
    
                public List<Overlay> mapOverlays;
                public Drawable drawable;
                public MapItemizedOverlay itemizedOverlay;  
                Harita*/
    
              /*  drawable = this.getResources().getDrawable(R.drawable.map_kirmizi_png);
                itemizedOverlay = new MapItemizedOverlay(drawable, parent.getApplicationContext(), 30);//text size: 30
    
                GeoPoint gPointMe = new GeoPoint(41099932,29002657);
                OverlayItem overlayItem = new OverlayItem(gPointMe, "Me", "This is my location");
                itemizedOverlay.addOverlay(overlayItem);    
    
                mapOverlays.add(itemizedOverlay);
    
                mMapView.setBuiltInZoomControls(true);
    
                //move map over to my position
                mc.animateTo(gPointMe);  
    
    
    
            mMapView.invalidate(); */
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use this code but it doesn't work. http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html Ld /Users/waitonza/Library/Developer/Xcode/DerivedData/Dr_Ngoo-aanknxmuodcgjicaigxevljxokeq/Build/Products/Debug-iphonesimulator/Dr Ngoo.app/Dr
i wrote a simple class that derives QPushButton, and tried to apply stylesheet on
I have a GLM, family=binomial(link=logit) model that I apply within a predict() function, seen
I have seen this question but not asked like this, if there is a
I have tried almost all the techniques to apply sticky footer to my site
Hi i want to apply style on every 2nd <li> i have tried <script>
UPDATE: Seems to me like it is pretty much an Apple bug. I tried
tried uncommenting pam_limits.so from the pam.d directory but no luck. Basic PAM seems to
I have tried searching the database for a similar issue, but was unsuccessful in
When I paste this code into a REPL, it works fine: (use 'clojure.contrib.seq-utils) (defn-

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.