通过 Zoom 缩放地图标记,Android

发布于 2024-09-15 09:38:48 字数 83 浏览 2 评论 0原文

我的地图上有很多标记。放大每个标记会显示一个位置。但缩小标记会相互重叠,确定标记的位置会更加困难。

有没有办法根据缩放系数缩放标记图像?

I have lot of markers on my map. Zooming in each marker shows me a position. but zooming out the markers are overlapping each other and it is more difficult do determine the position of a marker.

Is there a way to scale the marker image depending on the zoom factor?

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

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

发布评论

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

评论(3

陪我终i 2024-09-22 09:38:48

取决于你如何绘制标记。如果您的标记只是位图/可绘制对象,只需使用matrix.postScale()

Matrix matrix = new Matrix();
matrix.postScale(2f, 2f); // douple the size
canvas.drawBitmap(mBitmap, matrix, mPaint);

Depends on how you draw your marker. If your marker is just a bitmap/drawable, simply use matrix.postScale()

Matrix matrix = new Matrix();
matrix.postScale(2f, 2f); // douple the size
canvas.drawBitmap(mBitmap, matrix, mPaint);
不气馁 2024-09-22 09:38:48

标记不会根据缩放而改变大小。如果您需要这种效果,请使用 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 了解更多信息

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

棒棒糖 2024-09-22 09:38:48

一个简单的形式是。

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

A simple form is.

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.raw.ic_car_1);
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap); 
        googleMap.addGroundOverlay(new GroundOverlayOptions()
             .image(bitmapDescriptor)
             .position(latLng,100));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文