Android Maps v2自定义标记在缩放上的位置不正确 [英] Android Maps v2 custom marker has incorrect position on zoom

查看:69
本文介绍了Android Maps v2自定义标记在缩放上的位置不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道之前已经讨论过,但是实际上找不到解决方法.

I know this has been discussed before, but I actually can't find a solution.

我要为标记添加一个自定义图标:

I am adding a custom icon for my marker:

markerUserLocation = mMap.addMarker(new
                        MarkerOptions().position(new
                                LatLng(point.latitude,
                                        point.longitude))
                                .anchor(0.5f, 1.0f)
                               .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_marker_my_location)));

问题是当放大/缩小标记时,标记会放在错误的位置.

The problem is when zooming in/out the marker gets positioned in a bad place.

我尝试使用锚值,但没有成功.默认的锚点不是图像的中间/底部吗? 我需要做的是实际上将标记的底部保持在指定的点坐标上,而与缩放级别无关吗?

I have tried to play with the anchor values, but no success. Isn't the default anchor mid/bottom of the image ? What i need to do, to actually keep the bottom of the marker at the specified point coordinates, independent of zooming level ?

这是一个ic_marker_my_location图标示例(xhdpi大小),因为我无法上传原始图标.

Here is a ic_marker_my_location icon sample (xhdpi size), as I can't upload the original icon.

LE:这确实很愚蠢,但是如果我使用较小的标记图像...可以正常工作...那么标记资源图像尺寸可能有错误吗?或者,如果图像更大,我需要设置一些额外的参数?

LE: this is a really silly, but if i use a smaller marker image... it works correctly... So maybe there is a bug with marker resource image size ? Or if the image is bigger, I need to set some extra parameters ?

推荐答案

我设法通过制作新的标记png来解决此问题.基本上制作了一个相同大小的新png并重新创建了图像...现在可以正常工作了.因此我不知道实际发生了什么,也许地图控件不喜欢某些边距或其他内容.

I managed to fix the issue by making a new marker png. Basically made a new png of the same size and recreated the image... and now it works. So I have no idea what really happened, maybe the map control didn't like some margins or something.

这篇关于Android Maps v2自定义标记在缩放上的位置不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆