如何在“地图视图”上设置合适的缩放级别?

发布于 2024-12-27 05:18:04 字数 259 浏览 2 评论 0原文

        mMapController.animateTo(mAllSpots.get(0));
        mMapController.setCenter(mAllSpots.get(0));
        mMapController.setZoom(getZoomSize(mAllSpots));

有 11 个不同的点,我想在“地图视图”上显示它们,同时,我想在“地图视图”上看到所有 11 个点。那么合适的缩放级别是多少?谢谢。

        mMapController.animateTo(mAllSpots.get(0));
        mMapController.setCenter(mAllSpots.get(0));
        mMapController.setZoom(getZoomSize(mAllSpots));

There are 11 different points and I want to show them on the 'mapview',meanwhile,I want to see all of the 11 points on the 'mapview' .So what is the appropriate zoom level? Thanks.

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

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

发布评论

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

评论(2

好久不见√ 2025-01-03 05:18:04

您可能应该使用 ItemizedOverlay 实现来展示您的观点。如果您这样做,您还可以使用这些方便的方法来为您完成所有工作:

// Sets zoom to a level that will show all of your points.
mapView.getController().zoomToSpan(itemizedOverlay.getLatSpanE6(),
    itemizedOverlay.getLonSpanE6());

// Animates to center (mean, mean) of points.
mapView.getController().animateTo(itemizedOverlay.getCenter());

You should probably be using an ItemizedOverlay implementation to show your points. If you do, you can also use these handy methods to do all the work for you:

// Sets zoom to a level that will show all of your points.
mapView.getController().zoomToSpan(itemizedOverlay.getLatSpanE6(),
    itemizedOverlay.getLonSpanE6());

// Animates to center (mean, mean) of points.
mapView.getController().animateTo(itemizedOverlay.getCenter());
装纯掩盖桑 2025-01-03 05:18:04
mMapController.animateTo(mAllSpots.get(0));

这 1 代表点到意味着在给定参数的特定/定义位置上平移地图,

mMapController.setCenter(mAllSpots.get(0));

这 1 代表基于给定参数作为位置值的居中地图,

mMapController.setZoom(getZoomSize(mAllSpots));

这 1 代表设置缩放级别,您需要

mMapController.zoomToSpan(latSpan, longSpan);

在此处 使用此方法latSpan 和 longSpan 是由 maxlat-minlat 和 maxlng - minlng 定义的,首先你需要找到 minlat,minlng 和 maxlat,maxlng 然后将其添加到你必须传入的值中这,这将作为缩放,动画,居中一起

编辑

你需要找到从地图视图中获取这将为你提供maplatspan,就像假设你的点一样,

p1 = 20.212323,68.803209;
p2 = 20.222342,68.889898; 
p3 = 22.212232,68.802093;

现在获取minlat,minlng和maxlat,maxlng然后减去它,该点被绑定为矩形的矩形点,并找到该矩形的中心点

minlat = 20.212232,minlng = 68.802093,maxlat = 22.212232, maxlng = 68.889898

latspan = maxlat - minlat, lngspan = maxlng - minlng

您还需要转换为地理点以与 1e6 相乘,如 latspan*1e6 和 lngspan*1e6,现在传递给函数

mMapController.animateTo(mAllSpots.get(0));

this 1 is for the point to means pan the map on specific/define location as given argument,

mMapController.setCenter(mAllSpots.get(0));

this 1 is for centered map based on the given argument as location value

mMapController.setZoom(getZoomSize(mAllSpots));

this 1 is for set the zoom level you need to use this method

mMapController.zoomToSpan(latSpan, longSpan);

here the latSpan and longSpan was define by maxlat-minlat and maxlng - minlng, first of all you need to find minlat,minlng and maxlat,maxlng and than sustract it whatever the value getting that you have to pass in this, this will work as zoom,animate, center together

Edited

you need to find to get from the mapview this will give you the maplatspan like suppose your points,

p1 = 20.212323,68.803209;
p2 = 20.222342,68.889898; 
p3 = 22.212232,68.802093;

now get the minlat,minlng and maxlat,maxlng and then substract it, this point was bound rect point as rectangle and find as center point of this rectangle

minlat = 20.212232, minlng = 68.802093, maxlat = 22.212232, maxlng = 68.889898

latspan = maxlat - minlat, lngspan = maxlng - minlng

also you need to convert into the geopoint to multiply by with 1e6 like latspan*1e6 and lngspan*1e6 and now pass to the function

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