0

我正在我的应用程序中开发谷歌地图,但它没有显示地图只显示网格线,请任何人帮助我这是什么问题?我在气泡上绘制文本,当超过 2 个气泡位于相同的位置时,在这种情况下文本相互重叠。更改 API 密钥后,地图将显示,但我的第二个问题仍然存在。我必须在地图和文本上绘制气泡(该气泡上的属性大小)假设列表 4 的大小然后应该在气泡上绘制 4。我一直实现了这些,但没有显示期望的输出。

            drawable = this.getResources().getDrawable(R.drawable.bluedot);
            drawable1 = this.getResources().getDrawable(R.drawable.bluedot_large);

             overlay = new GoogleMapViewOverlay(drawable,mapView,activity);

//GoogleMapViewOverlay 方法如下:-

public GoogleMapViewOverlay(Drawable drawable, MapView mapView,
            Activity activity2)
    {
        //super(drawable);
        super(boundCenterBottom(drawable));
        setLastFocusedIndex(-1);
        populate();         
        arrayList1  = new ArrayList<Applicationdataset>() ;
        items = new ArrayList<OverlayItem>();
        marker = drawable;
        mContext = mapView.getContext();
        mc = mapView.getController();
        this.activity = activity2;
        DB = new DatabaseHelper(activity2);
    }

//将项目添加为

if(point != null)
                        {
                            if(arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
                            {  
                                oi = overlay.createItem(i);
                                System.out.println("listing when 1 value is"+arrayList.get(i).getUnitstotal());
                                overlay.addItem(oi);
                            }
                            else if(!arrayList.get(i).getUnitstotal().equalsIgnoreCase("1"))
                            {
                                oi = overlay.createItem(i);
                                System.out.println("listing when more value is  "+ arrayList.get(i).getUnitstotal());
                                if(overlay!=null)
                                {
                                    overlay.addItem(oi);
                                    //overlay.draw(canvas, mapView, shadow);
                                }

                            }
                        }

//draw方法在气泡上绘制文本

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



        arrayList1 = arrayList;
        for (int index = 0; index < items.size(); index++)
          {
            OverlayItem item = items.get(index);
            GeoPoint point = item.getPoint();
            Point ptScreenCoord = new Point();
            mapView.getProjection().toPixels(point, ptScreenCoord);
            //Paint
            Paint paint = new Paint();
            paint.setStyle(Style.STROKE);  
            paint.setTextAlign(Paint.Align.CENTER);
            paint.setTypeface((Typeface.defaultFromStyle(Typeface.BOLD)));
            paint.setTextSize(20);
            paint.setColor(Color.WHITE);
            paint.setFilterBitmap(false);//true
            if(arrayList.get(index).getUnitstotal().equalsIgnoreCase("1"))                  
                canvas.drawText("", ptScreenCoord.x, ptScreenCoord.y-20,paint);
            else
            {

                  canvas.drawText(arrayList.get(index).getUnitstotal().toString(), ptScreenCoord.x, ptScreenCoord.y-40, paint); 
            }

        }

        return true;
    }
4

1 回答 1

0

很可能您还没有获取 google map api 密钥,请按照以下链接上的说明获取它,然后尝试: https ://developers.google.com/maps/documentation/android/mapkey

于 2012-06-19T05:07:09.433 回答