0
我有一个googlemap应用程序显示两个项目(itemizedoverlay类),我有一个更新按钮。当我按下更新按钮时,我想从地图中删除项目,并再次将相同的项目,但与新的经度和纬度值(我有一个服务,realice我有sharedPreferences中的经度和纬度字段,和另外我通过一束捆绑其他位置)如何在Googlemap中实际显示物品的位置?
我做错了什么?当我尝试我的代码,在地图的项目不被删除....只是新的项目出现......但我想删除旧的
updateButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mapOverlays.clear();
updateMyPosition();
updateFriendPosition();
}
});
,这些都是我的两个功能:
private void updateFriendPosition()
{
Bundle bundle = this.getIntent().getExtras();//get the intent & bundle passed by X
userText.setText(bundle.getString("user"));
permissionText.setText(bundle.getString("permission"));
lastUpdateText.setText(bundle.getString("lastupdate"));
String coordinates[] = {bundle.getString("lat"), bundle.getString("lon")};
lat = Double.parseDouble(coordinates[0]);
lng = Double.parseDouble(coordinates[1]);
p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
OverlayItem overlayitem1 = new OverlayItem(p, bundle.getString("user"), "Hi Friend!");
itemizedoverlay.addOverlay(overlayitem1);
mapOverlays.add(itemizedoverlay);// dibujo la estrella con la posicion actual del friend
mc.animateTo(p); ///nos centra el mapa en la posicion donde esta nuestro amigo
mc.setZoom(10); /// ajusta el zoom a 10
}
private void updateMyPosition()
{
String coordinates[] = {settings.getString("mylatitude", null),settings.getString("mylongitude", null)};
lat = Double.parseDouble(coordinates[0]);
lng = Double.parseDouble(coordinates[1]);
p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
OverlayItem overlayitem1 = new OverlayItem(p, "Me", "My Position");
itemizedoverlay2.addOverlay(overlayitem1);
mapOverlays.add(itemizedoverlay2);//dibujo mi icono para mostrarme a mi
}
我也tryed上的MapView无效(),但它不工作... ...仍然粉刷旧项目...
之前的感谢!嘿嘿解决了也许你也可以帮我解决这个问题呢? http://stackoverflow.com/questions/4216231/how-to-actualice-the-positions-of-the-items-in-a-googlemap – NullPointerException 2010-11-18 17:49:26
很高兴工作。您的其他问题的链接指向这一个! – NickT 2010-11-18 17:59:52
哦对不起,请查看:http://stackoverflow.com/questions/4217090/why-this-thread-doesnt-work – NullPointerException 2010-11-18 18:22:18