【问题标题】:Google maps, plotting markers based on a lat / lng value谷歌地图,基于 lat / lng 值绘制标记
【发布时间】:2010-08-20 12:17:40
【问题描述】:

我有以下代码,它在指定的 x/y 屏幕坐标处绘制一个标记。就这样……

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

        //---translate the GeoPoint to screen pixels---
        Point screenPts = new Point();
        mapView.getProjection().toPixels(p, screenPts);

        //---add the marker---
        Bitmap bmp = BitmapFactory.decodeResource(
            getResources(), R.drawable.marker);            
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);  
        System.out.println("X: " + screenPts.x + "Y: " + screenPts.y);
        return true;
    }

但是 API 中是否有任何基于 lat/lng 绘制点的已知方法?

【问题讨论】:

    标签: java android google-maps


    【解决方案1】:

    一种解决方案是创建一个带有点(小圆圈)的位图图像,并将该图像用作标记。然后你可以保持你的代码不变。

    您可以使用任何Drawable 作为标记。 Drawable Resources 上的这篇文章应该可以帮助您找到最适合点标记的实现。

    【讨论】:

      猜你喜欢
      • 2020-08-13
      • 2011-01-06
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-06
      相关资源
      最近更新 更多