0

我通过从 api 的值动态使用 for 循环在 mapview 中显示多个点,并且我得到了精确点,但是我无法显示从用于获取标题的 api 获得的多个标题,但我正在显示最后一个在每一个精确点上一次又一次。这是我的代码。请帮忙。

for(int i = 0;i<adapt_objgps.latitude_array.length;i++){
    System.out.println("valud oer values:::" +adapt_objgps.latitude_array[1]);
    lat = adapt_objgps.latitude_array[i];
    longit = adapt_objgps.longitude_array[i];
    title = adapt_objgps.title_array[i];
    address = adapt_objgps.address_array[i];

    total = lat+","+longit;
    System.out.println("value of total:::" +total);
    System.out.println("value of title:::"+title);

    mapview = (MapView) findViewById(R.id.mapView);
    mapview.setBuiltInZoomControls(true);

    List<Overlay> mapOverlays = mapview.getOverlays();

    Drawable drawable = myrefgps.getResources().getDrawable(R.drawable.mark_red);
    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);

    double dLat = Double.parseDouble(lat) *1E6;
    double dLongotitue =Double.parseDouble(longit) *  1E6;

    int iLat = (int) dLat;
    int iLongtitue = (int) dLongotitue;

    point = new GeoPoint(iLat, -iLongtitue);

    System.out.println("point length::" +point);
    System.out.println("point length::" +title);
    System.out.println("point length::" +address);

    OverlayItem overlayitem = new OverlayItem(point, title,address);
    itemizedoverlay.addOverlay(overlayitem);

    mapOverlays.add(itemizedoverlay);
}
4

1 回答 1

0

刚刚重新排列您的代码现在尝试并请告诉::

mapview = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
mapView.displayZoomControls(true);
List<Overlay> mapOverlays = mapView.getOverlays();  
Drawable drawable = myrefgps.getResources().getDrawable(R.drawable.mark_red);
for(int i = 0;i<adapt_objgps.latitude_array.length;i++){
    double dLat = Double.parseDouble(adapt_objgps.latitude_array[i]) *1E6;
    double dLongotitue =Double.parseDouble(adapt_objgps.longitude_array[i]) *  1E6;
    int iLat = (int) dLat;
    int iLongtitue = (int) dLongotitue;
    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);
    GeoPoint point = new GeoPoint(iLat, -iLongtitue);
    OverlayItem overlayitem = new OverlayItem(point, adapt_objgps.title_array[i],adapt_objgps.address_array[i]);
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
}
于 2012-04-12T05:55:51.730 回答