将自定义控件添加为标记OSMDROID奖金包 [英] Add Custom Control as Marker OSMDROID BONUS PACK

查看:59
本文介绍了将自定义控件添加为标记OSMDROID奖金包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将自定义控件作为标记添加到OSMBONUSPACK吗?

Can I add Custom Control as Marker to OSMBONUSPACK?

我在名为MyMarkerItem.xml的Android xml文件中创建了一些按钮和图像

I create some Buttons and image in Android xml file Named MyMarkerItem.xml

我想要类似 MyMarker.setDesign(R.layout.MyMarkerItem);

谢谢

推荐答案

好的,我知道您希望标记图标本身不是简单的位图,而是布局.

OK, I understand that you want the marker icon itself to be not a simple bitmap, but a layout.

您可以做的是使用标记信息窗口代替"标记图标.

What you can do is to use the marker infowindow "instead" of the marker icon.

首先,创建一个新类CustomInfoWindow,该类继承自MarkerInfoWindow-Markers的默认InfoWindow,并使用您自己的布局:

First of all, create a new class CustomInfoWindow which inherits from MarkerInfoWindow - the default InfoWindow for Markers, and uses your own layout:

public class CustomInfoWindow extends MarkerInfoWindow {
    public CustomInfoWindow(MapView mapView) {
        super(my_own_layout, mapView);
    }
}

CustomInfoWindow myCustomInfoWindow = new CustomInfoWindow(mapView);

然后,在创建标记后,执行以下操作:

Then, just after creating your Marker, do that:

  • 将标记图标设置为1x1像素大小的位图,完全透明:setIcon(mySmall_InvisibleIcon)
  • 将标记信息窗口设置为您自己的:setInfoWindow(myCustomInfoWindow)
  • 根据布局的外观",将信息窗口锚点"设置为最合适和自然的位置:setInfoWindowAnchor(ANCHOR_CENTER,ANCHOR_CENTER)也许?
  • 强制打开信息窗口:showInfoWindow()

所有这些步骤都非常简单.

All these steps are fairly simple.

但是,我想您希望用户单击布局按钮时会发生某些行为.因此,在您的CustomInfoWindow代码中,您肯定必须做一些工作=>遵循本教程.

But then, I guess you expect some behaviour to happen when the user will click on your layout buttons. So, inside your CustomInfoWindow code, you will certainly have to do some work => follow this tutorial.

这篇关于将自定义控件添加为标记OSMDROID奖金包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆