I'm trying to take a marker using Naver API map, but the value of the marker is double type, so it can't
double LNG = Double.parseDouble(longitude.toString());
I tried to change it to Double and put it in, but there was an error.
longitude = new ArrayList<>();
latitude = new ArrayList<>();
I'm going to take a marker using the longitude and lateitude declared as ArrayList.
double LNG = Double.parseDouble(longitude.toString());
double LAT = Double.parseDouble(latitude.toString());
Marker marker = new Marker();
marker.setPosition(new LatLng(LAT, LNG));
marker.setMap(naverMap);
The code looks like this. Just in case, I will put the json parsing code as well.
try {
JSONObject Land = new JSONObject(result);
JSONArray jsonArray = Land.getJSONArray("Response");
for(int i = 0 ; i<jsonArray.length(); i++){
JSONObject subJsonObject = jsonArray.getJSONObject(i);
String sLAT = subJsonObject.getString("latitude");
String sLNG = subJsonObject.getString("longitude");
latitude.add(sLAT);
longitude.add(sLNG);
}
} } catch (JSONException e) {
e.printStackTrace();
}
I look forward to hearing from you
json marker android java
Transforming the List does not convert all elements in the list to Double.
Declare latitude, longitude
as a list containing double as shown below.
List<Double> latitude = new ArrayList<>();
List<Double> longitude = new ArrayList<>();
Modify the code that handles json.
Double sLAT = subJsonObject.getDouble("latitude"); //String sLAT = subJsonObject.getString("latitude");
Double sLNG = subJsonObject.getDouble("longitude"); //String sLNG = subJsonObject.getString("longitude");
© 2024 OneMinuteCode. All rights reserved.