Java-Android GoogleMap正方形显示矩形

Java-Android GoogleMap正方形显示矩形,第1张

概述我创建了一个GoogleMap对象,并绘制了一个具有正方形顶点的多边形,如图所示,但是正方形看起来是一个长方形.我究竟做错了什么?这是代码的一部分:@OverridepublicvoidonMapReady(GoogleMapgoogleMap){mMap=googleMap;//AddamarkerinSydneyandmovetheca

我创建了一个GoogleMap对象,并绘制了一个具有正方形顶点的多边形,如图所示,但是正方形看起来是一个长方形.我究竟做错了什么?

这是代码的一部分:

@OverrIDepublic voID onMapReady(GoogleMap GoogleMap) {    mMap = GoogleMap;    // Add a marker in Sydney and move the camera    LatLng enIDh = new LatLng(38.6925785, -9.2955145);    mMap.addMarker(new MarkerOptions().position(enIDh).Title("Marker in ENIDH"));    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(enIDh, 10.0f));    mBoats[0] = mMap.addpolygon(new polygonoptions()            .add(new LatLng(38.680026, -9.2846651),                    new LatLng(38.690026, -9.2846651),                    new LatLng(38.690026, -9.2946651),                    new LatLng(38.680026, -9.2946651),                    new LatLng(38.680026, -9.2846651))            .fillcolor(color.CYAN)            .strokecolor(color.BLUE)            .strokeWIDth(5));

This is the square (rectangle) appearance in android app emulator

解决方法:

您已使用LatLng指定了多边形的坐标.但是,以1个经度和1个纬度表示的距离(即公里)为not the same:

Each degree of latitude is approximately 69 miles (111 kilometers)
apart. The range varIEs (due to the earth’s slightly ellipsoID shape)
from 68.703 miles (110.567 km) at the equator to 69.407 (111.699 km)
at the poles. This is convenIEnt because each minute (1/60th of a
degree) is approximately one mile.

A degree of longitude is wIDest at the equator at 69.172 miles
(111.321) and gradually shrinks to zero at the poles. At 40° north or
south the distance between a degree of longitude is 53 miles (85 km).

因此,即使您创建的多边形的边长具有相同的无单位值,您也会得到一个不是正方形的矩形.

总结

以上是内存溢出为你收集整理的Java-Android GoogleMap正方形显示矩形全部内容,希望文章能够帮你解决Java-Android GoogleMap正方形显示矩形所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1090310.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存