繁体   English   中英

Android:如何知道是否点击了Google地图上的位图?

[英]Android: How to know whether a bitmap on Google Maps has been clicked?

我正在使用Google Map在Android上开发应用程序。

地图

我已经成功地在地图上放置了多个位图,如上图所示。
是否可以检测到用户单击了哪个位图,以便应用程序将用户重定向到包含有关单击位置的信息的页面?

Here you will need to put some logic to capture which bitmap Image was clicked.

One technique which works in my case is to override a method in your ItemizedOverlay class

protected boolean onTap(int index) {

// Here you get the index of which bitmap image was tapped on
// You can map this index to the related activity you need to open by mean of your logic

        OverlayItem item = mOverlays.get(index);

        Intent intent=new Intent (context,YourActivity.class);

        context.startActivity(intent);

        return true;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM