繁体   English   中英

Android Maps V2 meterToEquatorPixels新地图中的等效位置/什么地方?

[英]Android Maps V2 metersToEquatorPixels where/what is the equivalent in new maps?

Android Maps在地图投影上有一个很好的小方法,即MetersToEquatorPixels,它使您可以在赤道之间在像素和米之间进行转换,然后将该结果与*(1 / Math.cos(Math.toRadians(latitudeofmap )会告诉您多少像素代表该纬度的等效像素。

Maps V2中的等效功能是什么? 如果我想说一个图例,以显示距离,我必须知道每个像素在纬度/经度距离中所代表的距离,并且由于这种方法现在已经不复存在,因此我不知道该如何实现。 ..那么V2中的等效项是什么?

也许可以为您提供帮助:我取自以下网址https//gist.github.com/amay077/6879638

public static int metersToEquatorPixels(GoogleMap map, LatLng base, float meters) {
final double OFFSET_LON = 0.5d;

Location baseLoc = new Location("");
baseLoc.setLatitude(base.latitude);
baseLoc.setLongitude(base.longitude);

Location dest = new Location("");
dest.setLatitude(base.latitude);
dest.setLongitude(base.longitude + OFFSET_LON);

double degPerMeter = OFFSET_LON / baseLoc.distanceTo(dest); // 1m は何度?
double lonDistance = meters * degPerMeter; // m を度に変換

Projection proj = map.getProjection();
Point basePt = proj.toScreenLocation(base);
Point destPt = proj.toScreenLocation(new LatLng(base.latitude, base.longitude + lonDistance));

return Math.abs(destPt.x - basePt.x);
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM