простите мой английский, как я могу получить данные о широте из массива, который я создал на острове данных отдельно, как преобразовать эту строку в данные в моем массиве данных? LatLng sydney = Новый LatLng (-34, 151);
MapsActivity.java
надеюсь объяснить, я могу понять
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
**LatLng sydney = new LatLng(-34, 151);**
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
IslandData.java
public class IslandData {
public static String[][] data = new String[][] {
{"-8.586478",
"119.432801"},
{"-8.712502",
"116.995508"},
{"-0.221392",
"130.494268"},
{"-2.605546",
"140.557166"},
{"-8.324768",
"115.118091"},
{"1.622413",
"124.760006"},
{"-4.082819",
"137.289229"},
{"-3.115814",
"119.670047"},
{"-7.608001",
"110.203859"},
{"-6.302454",
"106.895116"}
};
public static ArrayList<Island> getListData(){
Island island;
ArrayList<Island> list = new ArrayList<>();
for (String[] mData : data) {
island = new Island();
island.setLatitude(mData[0]);
island.setLongitude(mData[1]);
list.add(island);
}
return list;
}
}
Island.java
public class Island implements Parcelable {
private String name, elevation, photo, description, location, latitude, longitude;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getElevation() {
return elevation;
}
void setElevation(String elevation) {
this.elevation = elevation;
}
public String getPhoto() {
return photo;
}
void setPhoto(String photo) {
this.photo = photo;
}
public String getDescription() {
return description;
}
void setDescription(String description) {
this.description = description;
}
public String getLocation() {
return location;
}
void setLocation(String location) {
this.location = location;
}
public String getLatitude() {
return latitude;
}
void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
void setLongitude(String longitude) {
this.longitude = longitude;
}
Island() {
}
private Island(Parcel in) {
name = in.readString();
elevation = in.readString();
photo = in.readString();
description = in.readString();
location = in.readString();
latitude = in.readString();
longitude = in.readString();
}
public static final Creator<Island> CREATOR = new Creator<Island>() {
@Override
public Island createFromParcel(Parcel in) {
return new Island(in);
}
@Override
public Island[] newArray(int size) {
return new Island[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(name);
parcel.writeString(elevation);
parcel.writeString(photo);
parcel.writeString(description);
parcel.writeString(location);
parcel.writeString(latitude);
parcel.writeString(longitude);
}
}
LatLng Сидней = Новый LatLng (-34, 151);