How to put JSON lOutput (latitude and longitude) on the map

前端 未结 1 935
刺人心
刺人心 2021-01-28 19:29

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

1条回答
  •  [愿得一人]
    2021-01-28 19:44

    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 activity
            int 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

    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 :

    Intent moreDetailsIntent = new Intent(PropertiesDetails.this,mapActivity .class);
    
                Bundle dataBundle = new Bundle();
                dataBundle.putInt("SelectedLong",lonnng);
                dataBundle.putInt("SelectedLat", latt);
                moreDetailsIntent.putExtras(dataBundle);
                startActivity(moreDetailsIntent);
    

    0 讨论(0)
提交回复
热议问题