gpt4 book ai didi

java - Android GoogleMap 一个正方形出现一个长方形

转载 作者:太空宇宙 更新时间:2023-11-03 13:16:57 27 4
gpt4 key购买 nike

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

这是一段代码:

@Override
public 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 指定了 Polygon 的坐标。然而,由 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 一个正方形出现一个长方形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34580607/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com