gpt4 book ai didi

android - 谷歌地图从异步任务加载多个标记

转载 作者:行者123 更新时间:2023-11-29 03:00:17 25 4
gpt4 key购买 nike

您好,我目前正在 Android 中使用 Google map 。当我从 mysql 数据库中检索纬度、经度和 fragment 值列表并尝试在 Google map 中显示它时。这是我现在尝试的代码,但我没有在 map 中得到标记,

public static ArrayList<HashMap<String,Double>> vehiclehistory1= new ArrayList<HashMap<String,Double>>();
double latitude;
double longitude;
for(int i=0;i<user.length();i++)
{
System.out.println("forloop i valuie"+i);
JSONObject c1 = user.getJSONObject(i);
JSONObject c2 = c1.getJSONObject(TAG_SRES);

vehicle_reg_numb = c2.getString(TAG_Vechicle_REG);
latitude= c2.getDouble(TAG_Latitude);
longitude = c2.getDouble(TAG_Longitude);
speed = c2.getString(TAG_Speed);
exceed_speed_limit=c2.getString(TAG_Exceed_Speed);
bus_tracking_timestamp = c2.getString(TAG_bus_tracking_timestamp);
address=c2.getString(TAG_address);
map1.put(TAG_Latitude,latitude);
map1.put(TAG_Longitude,longitude);
map.put(TAG_Speed, speed);
map.put(TAG_address, address);

vehiclehistory1.add(map1);
vehiclehistory.add(map);

}
@Override
protected void onPostExecute(String file_url) {

super.onPostExecute(file_url);
cDialog.dismiss();
for (int i = 0; i < vehiclehistory1.size(); i++) {
LatLng pinLocation = new LatLng(Float.parseFloat(vehiclehistory1.get(i).latitude), Float.parseFloat(vehiclehistory1.get(i).longitude));
Marker storeMarker = map.addMarker(new MarkerOptions()
.position(pinLocation)
.title(vehiclehistory1.get(i).pinname)
.snippet(vehiclehistory1.get(i).address)
);
}
}

我得到的纬度是 Unresolved 类型。谁能告诉我哪里做错了?

最佳答案

试试这个

  LatLng pinLocation = new LatLng(Double.parseDouble(vehiclehistory1.get(i).latitude), Double.parseDouble(vehiclehistory1.get(i).longitude));

LatitudeLongitude 使用 Double 而不是 Parse Float

关于android - 谷歌地图从异步任务加载多个标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24780543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com