精确定位纬度/经度标记

发布于 2024-10-10 08:34:02 字数 466 浏览 0 评论 0原文

我正在尝试将 40x40 标记置于地图视图的 itemizedOverlay 中的纬度/经度位置的中心。

我设置标记边界时

    markerDefault.setBounds( -markerDefault.getIntrinsicWidth()/2
            ,-markerDefault.getIntrinsicHeight()/2
            , markerDefault.getIntrinsicWidth()/2
            , markerDefault.getIntrinsicHeight()/2);

,当我通过点击标记图像的中心检查纬度/经度时,纬度似乎与图像的高度有关。

有没有办法确保图像以所需的纬度/经度为中心?

默认鼠标光标(箭头)是否可能没有执行其使用其尖头与模拟器交互的通常行为?

谢谢,

杰夫

I'm trying to centre a 40x40 marker at a lat/lon position in an itemizedOverlay for a mapview.

I set the marker bounds with

    markerDefault.setBounds( -markerDefault.getIntrinsicWidth()/2
            ,-markerDefault.getIntrinsicHeight()/2
            , markerDefault.getIntrinsicWidth()/2
            , markerDefault.getIntrinsicHeight()/2);

When I check the lat/lon by tapping the centre of the marker image, the lat seems to be wrong by about the height of the image.

Is there a way to ensure the image is centred at the required lat/lon?

Is it possible the default mouse cursor - an arrow - isn't doing its usual behaviour of using its pointy end to interact with the emulator?

Thanks,

Geoff

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情独悲 2024-10-17 08:34:02

答案 -

我正在使用 ItemizedOverlay。添加 OverlayItem 时,您可以指定标记是以其中心位于该位置还是其下边缘位于该位置。请参阅 ItemizedOverlay。

我为我找到的 ItemizedOverlay 复制并粘贴了一些不错的代码(当然是在 stackoverflow 上),其中包括

super(boundCenterBottom(defaultMarker));

这导致了我发现的明显异常。如果您使用的是针式记号笔,那就太好了。我将其更改为

super(boundCenter(defaultMarker));

并且它按预期工作。

The answer -

I'm using an ItemisedOverlay. When an OverlayItem is added, you can specify whether the marker is positioned with its centre at the position, or its lower edge at the position. See ItemizedOverlay.

I had copy-and-pasted some nice code for an ItemizedOverlay I found( on stackoverflow of course), which included

super(boundCenterBottom(defaultMarker));

This caused the apparent anomaly I found. Its good if you're using a pin-type marker tho. I changed it to

super(boundCenter(defaultMarker));

and it works as expected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文