当用户放大/缩小时缩放 Android MapView 标记

发布于 2024-09-16 21:25:21 字数 278 浏览 6 评论 0原文

我看到了一些与此相关的问题,但没有可靠的答案。

我有一个 MapView,它可以根据用户放大或缩小的距离在地图上生成多达 1600 个位置。到目前为止,我只是将标记设置为应用程序中的可绘制对象。如何检测用户是否放大/缩小,然后相应地缩放标记。我不关心缩放部分,而是关心缩放聆听部分。有没有人为这个小问题开发出解决方案,或者可以为我指明创建自己的解决方案的正确方向?

另外,据我所知,Android 没有提供默认标记。我的说法正确吗?如果 Android 有一个内置标记可以根据缩放级别为您处理缩放,那就太好了。

I've seen a few questions about this but no solid answers.

I have a MapView that can generate up to 1600 locations on the map, based on how far the user zooms in or out. As of now, I have my marker simply set to a drawable within my application. How can I detect if a user has zoomed in/out, then scale the marker accordingly. I'm not concerned with the scaling part, but with the zoom listening part. Has anyone developed a solution to this little issue, or can point me in the correct direction to create my own?

Also, as far as I know, there is not a default marker that Android supplies. Am I correct about this? It would be nice if Android had a built in marker that handles the scaling based on zoom levels for you.

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

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

发布评论

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

评论(2

傻比既视感 2024-09-23 21:25:21

标记不会根据缩放而改变大小。如果您需要这种效果,请使用 GroundOverlays。 src

 GoogleMap map = ...; // get a map.
 BitmapDescriptor image = ...; // get an image.
 LatLngBounds bounds = ...; // get a bounds
 // Adds a ground overlay with 50% transparency.
 GroundOverlay groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
     .image(image)
     .positionFromBounds(bounds)
     .transparency(0.5));

地面叠加层是固定在地图上的图像,随地图缩放而缩放。请参阅API 了解更多信息

请参阅相关帖子:通过 Zoom 缩放地图标记,Android

Markers do not change size based on zoom. Use GroundOverlays if you desire this effect. src

 GoogleMap map = ...; // get a map.
 BitmapDescriptor image = ...; // get an image.
 LatLngBounds bounds = ...; // get a bounds
 // Adds a ground overlay with 50% transparency.
 GroundOverlay groundOverlay = map.addGroundOverlay(new GroundOverlayOptions()
     .image(image)
     .positionFromBounds(bounds)
     .transparency(0.5));

A ground overlay is an image that is fixed to a map and scales with the map zoom. Please see the API for more info

See related post: Scale Map Markers by Zoom, Android

独守阴晴ぅ圆缺 2024-09-23 21:25:21

我正在使用

LatLng latLng = new LatLng(-16.50881576338701,-68.13492067606603);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.raw.ic_car_1);
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap); 
        googleMap.addGroundOverlay(new GroundOverlayOptions()
             .image(bitmapDescriptor)
             .position(latLng,100));

google 地图文档 GroundOverlayOptions 中的文档

I'am use

LatLng latLng = new LatLng(-16.50881576338701,-68.13492067606603);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.raw.ic_car_1);
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap); 
        googleMap.addGroundOverlay(new GroundOverlayOptions()
             .image(bitmapDescriptor)
             .position(latLng,100));

The docs in google maps docs GroundOverlayOptions

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