私は自分のMainActivityに持っている座標でいっぱいの私のarraylistをgoogle mapsの活動のgoogle mapsに表示したいと思います。私はこれを最も簡単な方法でどうやって行うことができますか?私のarraylistを座標でGoogleマップに表示するには?
for (int j = 0; j <= 10; j++) {
JSONObject marker = placemarks.getJSONObject(j);
JSONArray coordinates = marker.optJSONArray("coordinates");
double lat = coordinates.optDouble(0);
double lng = coordinates.optDouble(1);
latlongList.add(new LatLng(lat, lng));
}
私の現在のGoogleマップの活動:JSONデータを取得するために、forループ マイここ
public class CarLocation extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_car2_go_location);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
MainActivity mainActivity = new MainActivity();
mMap = googleMap;
// Add a marker in Hamburg and move the camera
LatLng hamburg = new LatLng(53.551086, 9.993682);
mMap.addMarker(new MarkerOptions().position(hamburg).title("Marker in Hamburg"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(hamburg));
}
}
CarLocationアクティビティにlatlongListを渡しますか? – Blackkara
可能な場合はあります。その後、私はgoogle maps – Jade
に表示したいと思いますが、latlongListを使ってマーカーを作成するだけでも可能です。他のアクティビティから送信する代わりに、CarLocationでjson操作を行い、使用することができます。私のポストをチェックしてください。 – Blackkara