OverlayItem 不显示标记!

发布于 2024-09-08 17:29:10 字数 2139 浏览 2 评论 0原文

我有以下代码,但标记根本没有出现在地图上!

private class SitesOverlay extends ItemizedOverlay<pfOverlayItem> {

    private List<pfOverlayItem> items=new ArrayList<pfOverlayItem>();
    //private   PopupPanel panel=new PopupPanel(R.layout.popup);

    public SitesOverlay() {
        super(null);

        items = mainOverlayArray;

        populate();

    }

    @Override
    protected pfOverlayItem createItem(int i) {
        return(items.get(i));
    }

    @Override
    public void draw(Canvas canvas, MapView mapView,
                                        boolean shadow) {
        super.draw(canvas, mapView, shadow);

    }


    @Override
    public int size() {

        return(items.size());

    }



    private Drawable getMarker(int resource) {
        Drawable marker=getResources().getDrawable(resource);

        marker.setBounds(0, 0, marker.getIntrinsicWidth(),
                                            marker.getIntrinsicHeight());
        boundCenter(marker);

        return(marker);
    }
}

mainOverlayArray 充满了 pfOverlayItem,该类的代码是

public class pfOverlayItem extends OverlayItem {
private String coolText;

public String getcoolText() {
    return coolText;
}

public void setcoolText(String coolText) {
    this.coolText = coolText;
}

public pfOverlayItem(GeoPoint point, String title, String snippet) {
    super(point, title, snippet);
    // TODO Auto-generated constructor stub
}

}

在处理 XML 文件后,我还在该类之外设置了标记...

 ArrayList<pfOverlayItem> overArray = myXMLHandler.getOverlayArray();
                mainOverlayArray = overArray;
                pfOverlayItem tempOver = null;
                Drawable marker = getResources().getDrawable(R.drawable.icon);
                for (int i = 0; i < mainOverlayArray.size(); i++) {
                    tempOver = mainOverlayArray.get(i);
                    tempOver.setMarker(marker);
                }

                sites=new SitesOverlay();
                myMapView.getOverlays().add(sites);
                myMapView.invalidate(); [/code]

I have the following code and the markers are not appearing on the map at all!

private class SitesOverlay extends ItemizedOverlay<pfOverlayItem> {

    private List<pfOverlayItem> items=new ArrayList<pfOverlayItem>();
    //private   PopupPanel panel=new PopupPanel(R.layout.popup);

    public SitesOverlay() {
        super(null);

        items = mainOverlayArray;

        populate();

    }

    @Override
    protected pfOverlayItem createItem(int i) {
        return(items.get(i));
    }

    @Override
    public void draw(Canvas canvas, MapView mapView,
                                        boolean shadow) {
        super.draw(canvas, mapView, shadow);

    }


    @Override
    public int size() {

        return(items.size());

    }



    private Drawable getMarker(int resource) {
        Drawable marker=getResources().getDrawable(resource);

        marker.setBounds(0, 0, marker.getIntrinsicWidth(),
                                            marker.getIntrinsicHeight());
        boundCenter(marker);

        return(marker);
    }
}

mainOverlayArray is full of pfOverlayItem's and the code for that class is

public class pfOverlayItem extends OverlayItem {
private String coolText;

public String getcoolText() {
    return coolText;
}

public void setcoolText(String coolText) {
    this.coolText = coolText;
}

public pfOverlayItem(GeoPoint point, String title, String snippet) {
    super(point, title, snippet);
    // TODO Auto-generated constructor stub
}

}

I also set the marker outside of this after processing an XML file...

 ArrayList<pfOverlayItem> overArray = myXMLHandler.getOverlayArray();
                mainOverlayArray = overArray;
                pfOverlayItem tempOver = null;
                Drawable marker = getResources().getDrawable(R.drawable.icon);
                for (int i = 0; i < mainOverlayArray.size(); i++) {
                    tempOver = mainOverlayArray.get(i);
                    tempOver.setMarker(marker);
                }

                sites=new SitesOverlay();
                myMapView.getOverlays().add(sites);
                myMapView.invalidate(); [/code]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2024-09-15 17:29:10

看来您是从其中一个开始的我的很多 示例 Google 地图 应用程序。此处显示的代码不完整(例如,根据此处的代码,您从未创建任何 OverlayItem 实例)。

我的建议是您回滚到我上面链接到的示例之一并从那里开始修改,或者您开始​​尝试找出哪些方法被调用,哪些没有被调用。

It looks as though you're starting from one of my many sample Google Map applications. Your code as shown here is incomplete (e.g., according to the code here, you never create any OverlayItem instances).

My recommendation is you roll back to one of the samples I link to above and start modifying from there, or you start trying to figure out which of your methods are getting called and which are not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文