Skip to content Skip to sidebar Skip to footer

How To Put Json Loutput (latitude And Longitude) On The Map

I have a main activity which parses the JSON data from my mysql (table tracking:Lattitude and longitude) Now I want to pass this data in to my MapActivity and display on google map

Solution 1:

You need to get bundle from another class : this class will be for your mapActivity

Bundle b = getIntent().getExtras(); // Getting the Bundle object that pass from another activityint SelectedPropertylat = b.getInt("SelectedLat");
        int SelectedPropertylong = b.getInt("SelectedLong");

        String  lattitude = Integer.toString(SelectedPropertylat);          
        String  longertude = Integer.toString(SelectedPropertylong);

        Log.d(lattitude,longertude);

And taking datafrom mysql into your apps use this :

try{

    JSONArray  earthquakes = json.getJSONArray("PropertyDetails");

    for(int i=0;i<earthquakes.length();i++){                        

        JSONObject e = earthquakes.getJSONObject(i);
                lat = e.getString("P_Lat");
        lonng = e.getString("P_Long");

then convert lat and long into an string like :

lonnng = Integer.parseInt(lonng.toString());latt =Integer.parseInt(lat.toString());

then pass the data into your mapview like this :

IntentmoreDetailsIntent=newIntent(PropertiesDetails.this,mapActivity .class);

            BundledataBundle=newBundle();
            dataBundle.putInt("SelectedLong",lonnng);
            dataBundle.putInt("SelectedLat", latt);
            moreDetailsIntent.putExtras(dataBundle);
            startActivity(moreDetailsIntent);

Post a Comment for "How To Put Json Loutput (latitude And Longitude) On The Map"