Bonsoir tout le monde,
J'ai développée une application qui permet d'afficher des marqueurs autour de la position de l'utilisateur à partir des données récupérées d'un serveur .
Il n'y a pas des erreurs dans le logcat et la position de l'utilisateur s'affiche mais les marqueurs ne s'affichent pas .
Voila mon MainActivity.java:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
package com.example.recherche_restaurant;
 
import java.io.InputStream;
 
import java.util.List;
 
 
 
 
 
 
import org.apache.http.HttpEntity;
import org.json.JSONArray;
import org.json.JSONException;
 
import org.json.JSONObject;
 
 
import com.example.recherche_restaurant.R;
import com.example.recherche_restaurant.JsonParser;
import com.example.recherche_restaurant.ListItimizedOverlay;
 
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
 
 
 
 
import android.graphics.drawable.Drawable;
 
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
 
import android.os.AsyncTask;
import android.os.Bundle;
 
import android.view.KeyEvent;
 
 
 
public class MainActivity extends  MapActivity  implements
LocationListener {
 
 
 
	private static double lat = 0;
    private static double lng = 0;
 
    private static final String TAG_results = "results";
	private static final String TAG_geometry = "geometry";
	private static final String TAG_location = "location";
	private static final String TAG_lat = "lat";
	private static final String TAG_lng = "lng";
	JSONArray contacts = null;
 
    private MapView mapView = null;
    private LocationManager lm = null;
 
 
    private MapController mc = null;
    private MyLocationOverlay myLocation = null;
 
 
    HttpEntity httpEntity;
    static InputStream is = null;
 
	static JSONObject jObj = null;
 
	static String json = "";
	final String extra_longitude ="";
	final String extra_latitude =""; 
 
 
 
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
 
 
	mapView = (MapView) this.findViewById(R.id.mapView);
	mapView.setBuiltInZoomControls(true);
	lm = (LocationManager) this.getSystemService(LOCATION_SERVICE);
	lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10, 0, this);
	lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0,
		this);
 
 
	mc = mapView.getController();
	mc.setZoom(15);
	myLocation = new MyLocationOverlay(getApplicationContext(), mapView);
	myLocation.runOnFirstFix(new Runnable() {
	    public void run() {
		mc.animateTo(myLocation.getMyLocation());
		mc.setZoom(17);
	    }
	});
 
	mapView.getOverlays().add(myLocation);
	myLocation.enableMyLocation();
 
 
 
 
    }
 
 
 
    @Override
    protected void onResume() {
	super.onResume();
	myLocation.enableMyLocation();
	myLocation.enableCompass();
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_S) {
	    mapView.setSatellite(!mapView.isSatellite());
	    return true;
	}
	return super.onKeyDown(keyCode, event);
    }
 
 
	@Override
	public void onLocationChanged(Location location) {
		lat = location.getLatitude();
		lng = location.getLongitude();
 
		Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
		final ListItimizedOverlay itemizedoverlay = new ListItimizedOverlay(drawable,this);
		final  String url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location="+lat+","+lng +"&radius=500&types=food&name=harbour&sensor=true&key=AIzaSyDxms7wMJorpD9LZVRL9OiozgV1D9wJKxo";
		new AsyncTask<Void, Void, JSONObject>(){
			@Override
		protected JSONObject doInBackground(Void... params) {
				// instancier la classe JsonParser
				JsonParser jParser = new JsonParser ();
				// récupérer le JSONObject à partir de l’url du fichier employes.json
				JSONObject json = jParser.getJSONFromUrl(url);
 
				return json;
			};
 
 
		protected void onPostExecute(JSONObject json) {
 
			try {
 
				// récupérer la liste de tous les employés
				JSONArray results = json.getJSONArray(TAG_results);
 
				// parcourir toute la liste des employés
				for(int i = 0; i < results.length(); i++){
 
				// récupérer un employé de type JSONObject
				JSONObject emp = results.getJSONObject(i);
 
				// récupérer le JSONObject phone qui contient deux items
				JSONObject geometry = emp.getJSONObject(TAG_geometry);
				JSONObject location = geometry.getJSONObject(TAG_location);
				String latitude = location.getString(TAG_lat);
				String longitude= location.getString(TAG_lng);
				double b = Double.parseDouble(latitude);
				double c = Double.parseDouble(longitude);
 
 
			GeoPoint geoPoint = new GeoPoint((int) (c* 1E6) , (int)(b* 1E6));
			OverlayItem overlayitem = new OverlayItem(geoPoint, "Hello from", "Tahiti");
			itemizedoverlay.addOverlayItem(overlayitem);
 
 
			List<Overlay> mapOverlays = mapView.getOverlays();
			mapOverlays.add(itemizedoverlay);
 
			}
			}
			catch(JSONException e)
			{
				e.printStackTrace();
			}
		};
 
	}.execute();
 
	}
 
 
 
 
 
	@Override
	public void onProviderDisabled(String arg0) {
		// TODO Auto-generated method stub
 
	}
 
 
	@Override
	public void onProviderEnabled(String arg0) {
		// TODO Auto-generated method stub
 
	}
 
 
	@Override
	public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
		// TODO Auto-generated method stub
 
	}
 
 
	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}
 
}

Pouvez vous m'aider s'il vous plait et merci d'avance .