开发者

Clicking on Overlays in MapView

开发者 https://www.devze.com 2023-03-12 15:47 出处:网络
I\'ve created a MapActivity that uses MapView to place drawables on an ArrayList of points I\'ve specified.This works great.

I've created a MapActivity that uses MapView to place drawables on an ArrayList of points I've specified. This works great.

I want the user to be able to press each point and have a bubble appear (as when you are using Google Maps in your web browser) with some information about that point.

I can not figure out how to do this. Could someone po开发者_如何学运维int me to some good resources?


If you are using ItemizedOverlay, just override onTap() in your overlay class. Here is a sample project demonstrating this.

The relevant snippet there is:

    @Override
    protected boolean onTap(int i) {
        Toast.makeText(NooYawk.this, items.get(i).getSnippet(),
                        Toast.LENGTH_SHORT).show();

        return(true);
    }

Instead of displaying a Toast, you can do something else. For example, here is a sample project that displays a popup. And here's an Android library project that displays bubbles that point to the actual marker.

0

精彩评论

暂无评论...
验证码 换一张
取 消