【问题标题】:Marker anchor/offset on Mapbox 5.2Mapbox 5.2 上的标记锚点/偏移量
【发布时间】:2017-12-27 17:33:55
【问题描述】:

我正在 Android Mapbox 上设置标记。这些标记不是平方图像,不能居中,它们需要偏移。

在 Google 地图上,我可以使用 Anchor、X 和 Y。

在以前版本的 Mapbox 上,我可以将 MarkerView 与相同的 Anchor 一起使用。

但现在 Mapbox 5.2 MarkerView 已被弃用。

那么如何在我的地图上正确对齐我的标记?

谢谢

【问题讨论】:

    标签: android anchor mapbox deprecated marker


    【解决方案1】:

    我目前正在使用这个解决方案:

     /**
     * Generate a new bitmap to center it on Mapbox
     * @param icon the icon to display
     * @param centerFromTop The center of the picto from the top, in percentage, from 0.0 to 1.0. 1.0 
     *                      means the picto will be centered on the exact bottom of the original image.
     * @return
     */
    public static Bitmap cheatMapboxMarker(Bitmap icon, float centerFromTop) {
        int height = (int) (2 * centerFromTop * icon.getHeight());
        Bitmap loc_img = Bitmap.createBitmap(icon.getWidth(), height, Bitmap.Config.ARGB_8888);
        Canvas bitmapCanvas = new Canvas(loc_img);
        Bitmap tempBitmap = icon.copy(Bitmap.Config.ARGB_8888, false);
        bitmapCanvas.drawBitmap(tempBitmap, 0, 0, null);
        return loc_img;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 2016-05-20
      • 1970-01-01
      • 2023-03-26
      • 2023-01-12
      • 2021-10-22
      相关资源
      最近更新 更多