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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:58:35+00:00 2026-06-01T07:58:35+00:00

I have parse json file which contain more than hundred location name, there latitude

  • 0

I have parse json file which contain more than hundred location name, there latitude and longitude.
Up to now i am able to get location name, lattitude and longitude.

I want to plot these all values in google map and place a marker for each of them.

Also I want to show the location name which i got from parsing JSON when user touch the marker placed in google map.

I solve it guys. see below:

Update:
main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

 <com.google.android.maps.MapView 
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:enabled="true"
    android:clickable="true"
    android:apiKey="0hlQp-ys3VmVGNLoJ0aGYQhDmBH5KC-ZQmc3yNA"
    />

<LinearLayout
    android:id="@+id/zoom"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" />

 </RelativeLayout>

ShowMapActivity.java

public class ShowMapActivity extends MapActivity {

private static String url = "http://10.0.2.2/test/myfile.php";
JSONArray root = null;
private static final String TAG_ROOT = "root";
private static final String TAG_LATTITUDE = "lattitude";
private static final String TAG_LONGITUDE = "longitude";
private static final String TAG_NAME="name";

MapController mc;
GeoPoint p;

double lattitudeValue;
double longitudeValue;
String lattitude;
String longitude;
String name;

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

    // showing MapView
    MapView mapView = (MapView) findViewById(R.id.mapView);
    LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom);
    View zoomView = mapView.getZoomControls();
    zoomLayout.addView(zoomView, new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    mapView.displayZoomControls(true);
    mc = mapView.getController();
    String coordinates[] = { "53.5146152", "-2.2857034" };
    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);
    p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
    mc.animateTo(p);
    mc.setZoom(10);
    mapView.invalidate();


    // Parsing JSON value and Read location name, lattitude, longitude from JSON


    JSONParser jParser = new JSONParser();

    JSONObject json = jParser.getJSONFromUrl(url);
    System.out.println("Testingggg..." + json.length());

    try {

        root = json.getJSONArray(TAG_ROOT);
        for (int i = 0; i < root.length(); i++) {
            JSONObject c = root.getJSONObject(i);
            name=c.getString(TAG_NAME);   //Getting location name
            lattitude = c.getString(TAG_LATTITUDE); //Getting lattitude value in string
            longitude = c.getString(TAG_LONGITUDE); //Getting longitude value in string
            lattitudeValue = Double.parseDouble(lattitude); //converting string lattitude value to double
            longitudeValue=Double.parseDouble(longitude); //converting string longitude value to double



                List<Overlay> mapOverlays = mapView.getOverlays();
            Drawable drawable = this.getResources().getDrawable(
                    R.drawable.locationmarker);
            HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(
                    drawable, this);
            GeoPoint point = new GeoPoint((int) (lattitudeValue * 1E6),
                    (int) (longitudeValue * 1E6));
            OverlayItem overlayitem = new OverlayItem(point, name, "I'm in"
                    + name);

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



        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

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

CustomItemizedOverlay.java

public class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem> {

private final ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();

private Context context;

public CustomItemizedOverlay(Drawable defaultMarker) {
    super(boundCenterBottom(defaultMarker));
}

public CustomItemizedOverlay(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();
}

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

}

HelloItemizedOverlay.java

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

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

public void addOverlay(OverlayItem overlay) {
    mOverlays.add(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-06-01T07:58:37+00:00Added an answer on June 1, 2026 at 7:58 am
    Drawable srcdrawable = getApplicationContext().getResources().getDrawable(R.drawable.pin_blue);
    CustomItemizedOverlay srcitemizedOverlay = new CustomItemizedOverlay(srcdrawable, getApplicationContext());
    forloop(setoflocations){
    GeoPoint srcpoint = new GeoPoint((int)( Double.parseDouble(lat) * 1E6),(int)( Double.parseDouble(lng)* 1E6));
    OverlayItem srcoverlayitem = new OverlayItem(srcpoint, "Hello!", "This is your Location.");
    if(srcitemizedOverlay!=null && mapController!=null){
    srcitemizedOverlay.addOverlay(overlayitem);
    mapController.animateTo(point);
    animatePoint = point;
    }
    }
    mapView.getOverlays().clear();
    mapView.getOverlays().add(srcitemizedOverlay);
    

    Use the above code in oncreate() after you get set of location
    also below is the below CustomItemizedOverlay.java class

    public class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem> {
    
        private final ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();
    
        private Context context;
    
        public CustomItemizedOverlay(Drawable defaultMarker) {
            super(boundCenterBottom(defaultMarker));
        }
    
        public CustomItemizedOverlay(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();
        }
    
        public void addOverlay(OverlayItem overlay) {
            mapOverlays.add(overlay);
            this.populate();
        }
    
    }
    

    Refer this LINK.

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

Sidebar

Related Questions

I have a flash file which loads data from JSON and parses it. It
I have a huge JSON file to parse in my Android app. I suppose
I have a JSON which I get from web application. I try this parse
I have an XML file which I want to convert into JSON file using
I have a 1GB json file and i want to parse it using simplejson
I have JSON data which contents Strings and Image URLs, and I already parse
Possible Duplicate: How to parse JSON in JavaScript I have this JSON string: [{title:
I have no problems getting the Json to work and parse the json return.
I have looked at GSON to parse some of my JSON objects. However, this
currently I have the following which parses a json api.. import simplejson import urllib2

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.