我在谷歌地图上显示了纬度和经度当我点击标记它显示一个气球,其上写有图库名称和地址 我想当我点击气球时获取图库名称如何实现以下是我的代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.map);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
drawable1 = getResources().getDrawable(R.drawable.greenballon);
itemizedOverlay = new MyItemizedOverlay(drawable1, mapView);
drawable2 = getResources().getDrawable(R.drawable.blueballon);
itemizedOverlay2 = new MyItemizedOverlay(drawable2, mapView);
drawable3 = getResources().getDrawable(R.drawable.redballon);
itemizedOverlay3 = new MyItemizedOverlay(drawable3, mapView);
for(int i=0;i<20;i++)
{
if(sitesList.getType().get(i).equalsIgnoreCase("Centros Culturales"))
{
name = sitesList.getLatitude().get(i);
name1 = sitesList.getLongitude().get(i);
Log.i("centos culturales lat" + i,name);
Log.i("culturarls longitiitude"+i,name1);
point = new GeoPoint((int) (Double.parseDouble(name) * 1E6),
(int) (Double.parseDouble(name1) * 1E6));
OverlayItem overlayItem = new OverlayItem(point, sitesList.getGalleryname().get(i),
sitesList.getAddress().get(i));
itemizedOverlay.addOverlay(overlayItem);
}
}
for(int i=0;i<sitesList.getLatitude().size();i++)
{
if(sitesList.getType().get(i).equalsIgnoreCase("Centros Culturales"))
{
name = sitesList.getLatitude().get(i);
name1 = sitesList.getLongitude().get(i);
Log.i("centos culturales lat" + i,name);
Log.i("culturarls longitiitude"+i,name1);
point = new GeoPoint((int) (Double.parseDouble(name) * 1E6),
(int) (Double.parseDouble(name1) * 1E6));
OverlayItem overlayItem = new OverlayItem(point, sitesList.getGalleryname().get(i),
sitesList.getAddress().get(i));
itemizedOverlay.addOverlay(overlayItem);
}
}
for(int i=0;i<sitesList.getLatitude().size();i++)
{
if(sitesList.getType().get(i).equalsIgnoreCase("Residencias"))
{
name = sitesList.getLatitude().get(i);
name1 = sitesList.getLongitude().get(i);
Log.i("residencias latitute" + i,name);
Log.i("residencias longitiitude"+i,name1);
point3 = new GeoPoint((int) (Double.parseDouble(name) * 1E6),
(int) (Double.parseDouble(name1) * 1E6));
OverlayItem overlayItem = new OverlayItem(point3, sitesList.getGalleryname().get(i),
sitesList.getAddress().get(i));
itemizedOverlay2.addOverlay(overlayItem);
}
}
mapOverlays.add(itemizedOverlay);
mapOverlays.add(itemizedOverlay2);
**//actuaaly i show lat long in google map according to "gallery type"..so here how to get data on tap of baloon...??????**
@Override
protected boolean onBalloonTap(int index, OverlayItem item) {
for(int i=0;i<sitesList.getLatitude().size();i++)
{
if(sitesList.getType().get(i).equalsIgnoreCase("Centros Culturales"))
{
array_galleryname1 = new String[sitesList.getGalleryname().size()];
array_galleryurl1 = new String[sitesList.getImagesurl().size()];
galleryname = sitesList.getGalleryname().get(i);
galleryurl = sitesList.getImagesurl().get(i);
array_galleryname1[index] = galleryname;
array_galleryurl1[index] = galleryurl;
}
}
Toast.makeText(c, array_galleryname1[index] + index,
Toast.LENGTH_LONG).show();
for(int i=0;i<sitesList.getLatitude().size();i++)
{ if(sitesList.getType().get(i).equalsIgnoreCase("Residencias"))
{
array_galleryname = new String[sitesList.getGalleryname().size()];
array_galleryurl1 = new String[sitesList.getImagesurl().size()];
galleryname = sitesList.getGalleryname().get(i);
galleryurl = sitesList.getImagesurl().get(i);
array_galleryname[index] = galleryname;
array_galleryurl1[index] = galleryurl;
}
}
答案 0 :(得分:0)
你必须覆盖onTap()。 看到这个链接。 http://developer.android.com/resources/tutorials/views/hello-mapview.html