如何在图形页面显示的气球,一旦地图显示? [英] How to display balloon on the MapView, once map is shown?
问题描述
我用的Android mapviewballoons 库显示的气球。 因此,一旦用户点击我的标记,示出气球
我的问题:如何显示气球特定项目,而无需等待用户点击
UPD。如何识别我? 目前,我有以下几点:
公共类地图扩展MapActivity {
公共无效的onCreate(包savedInstanceState){
//这里我有extras.getDouble(土地增值税)和extras.getDouble(LNG) -
//位置的气囊应显示为
...
itemizedOverlay =新MapOverlay(绘制,图形页面);
的for(int i = 0; I< items.getCount();我++){
//这里我想补充的标记,其中一人将有纬度和经度等于
//在额外传递的值
公共类MapOverlay扩展BalloonItemizedOverlay< OverlayItem> {
...
保护OverlayItem createItem中(int i)以{
此外,关于以下code:
// BalloonOverlayView是一个原始类型。引用泛型类型BalloonOverlayView<项目>应该是参数化
BalloonOverlayView BOV =新BalloonOverlayView(背景下,50);
//什么项目呢?应的getItem(ⅰ)?
bov.setData(项目);
//该方法setPosition两种(INT)是未定义的类型BalloonOverlayView
BalloonOverlayView.setPosition(ⅰ);
Plase参考本教程。
在 @覆盖保护OverlayItem createItem中(int i)以
方法,你可以膨胀的气球ovarlay为您的特定指标。假设你的具体点就是2那么你可以做上面的方法按照
如果(我== 2){
BalloonOverlayView BOV =新BalloonOverlayView(背景下,50);
bov.setData(项目);
BalloonOverlayView.setPosition(ⅰ);
BalloonOverlayView.setGeoPoint(GeoPoint对象);
MapView.LayoutParams PARAMS =新MapView.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,GeoPoint对象,MapView.LayoutParams.BOTTOM_CENTER);
params.mode = MapView.LayoutParams.MODE_MAP;
mapView.addView(BOV,则params);
}
I use android-mapviewballoons library to show balloons. So, once user clicks on my marker, balloon is shown.
The question I have: how to display the balloon for particular item without waiting for user click?
Upd. how to identify i? Currently I have the following:
public class Map extends MapActivity {
public void onCreate(Bundle savedInstanceState) {
// here I have extras.getDouble("lat") and extras.getDouble("lng") -
// the location balloon should be shown for
...
itemizedOverlay = new MapOverlay(drawable, mapView);
for (int i = 0; i < items.getCount(); i++) {
// here I add markers, one of them will have lat and lng equal to
// the values passed in extras
public class MapOverlay extends BalloonItemizedOverlay<OverlayItem> {
...
protected OverlayItem createItem(int i) {
Also, with regards to the following code:
// BalloonOverlayView is a raw type. References to generic type BalloonOverlayView<Item> should be parameterized
BalloonOverlayView bov = new BalloonOverlayView(context, 50);
// What is item there? should be getItem(i)?
bov.setData(item);
// The method setPosition(int) is undefined for the type BalloonOverlayView
BalloonOverlayView.setPosition(i);
Plase refer this tutorial.
In @Override protected OverlayItem createItem(int i)
method you can inflate that ballon ovarlay for your particular index. suppose your specific point is 2 then you can do following in above method
if(i==2){
BalloonOverlayView bov = new BalloonOverlayView(context, 50);
bov.setData(item);
BalloonOverlayView.setPosition(i);
BalloonOverlayView.setGeoPoint(geoPoint);
MapView.LayoutParams params = new MapView.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, geoPoint,MapView.LayoutParams.BOTTOM_CENTER);
params.mode=MapView.LayoutParams.MODE_MAP;
mapView.addView(bov, params);
}
这篇关于如何在图形页面显示的气球,一旦地图显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!