0
我試圖讓被點擊的標記,但我只得到了最後一個標記名稱 我希望在所選擇的標記申請對話框,但它得到的最後一個標記只有在Google地圖中標記點擊
for(int i=0;i<objectResults.length();i++){
JSONObject place=objectResults.getJSONObject(i);
String store_id=place.getString("id");
final String place_name=place.getString("name");
double latitude1, longitude1;
latitude1=place.getJSONObject("geometry").getJSONObject("location").getDouble("lat");
longitude1=place.getJSONObject("geometry").getJSONObject("location").getDouble("lng");
MarkerOptions markerOptions=new MarkerOptions();
LatLng latLng=new LatLng(latitude1,longitude1);
markerOptions.position(latLng);
markerOptions.title(place_name);
mMap.addMarker(markerOptions);
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
Toast.makeText(getContext(),"YOU CLICKED ON "+place_name,Toast.LENGTH_LONG).show();
return false;
}
);
}
在此先感謝。
它的工作,非常感謝 – rookieDeveloper