为什么只显示谷歌地图中的网格线?

时间:2012-06-19 04:32:46

标签: android

我正在我的应用程序中开发谷歌地图,但它没有显示仅显示网格线的地图,请有人帮我解决问题是什么?                                               而且我在气泡上绘制文本,当超过2个气泡位于相同位置时,在这种情况下,文本相互重叠。                                                                           更改API键后,地图将显示,但我的第二个问题仍然存在。我必须在地图上绘制气泡和文本(该气泡上的属性大小)假设有4个列表的大小,那么4应该在bubble上绘制。我已经实施了这些,但没有愿望输出显示。                                                                                      当同一个位置上有超过2个属性且每个都有超过2个列表大小时,气泡上的文字会互相重叠,对不起我的解释我正在使用此代码 -

            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);
                                }

                            }
                        }

//绘制文字绘制方法

                @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;
    }

2 个答案:

答案 0 :(得分:2)

请参阅此链接using google maps on android

答案 1 :(得分:0)

最有可能你没有提取谷歌地图api密钥,请按照以下链接中的说明获取,然后尝试: https://developers.google.com/maps/documentation/android/mapkey