出于某种原因,LatLng 的构造函数将纬度值更改为 -90.0,但经度值没问题。
for (DealMarker m : markers.getMarkers()) {
Log.d("map " , "pre - lat " + m.getmLatitude() + " " + m.getmLongitude());
LatLng latlng = new LatLng(m.getmLatitude(), m.getmLongitude());
Log.d("map " , "post lat " + latlng.latitude + " " + latlng.longitude);
Marker deallocation = mMap.addMarker(new MarkerOptions().position(latlng).title(m.getTitle()).snippet(m.getSnippett()));
}
这会生成如下日志文件: 09-28 19:26:50.212: D/map(17784): pre-lat -121.6176785 39.1417939 09-28 19:26:50.212: D/map(17784): post lat -90.0 39.1417939
对于每个标记.. 我不知所措地为此工作了几个小时。谢谢你们。
最佳答案
只需查看 LatLng constructor 的文档即可.它说:
public LatLng (double latitude, double longitude)
Constructs a LatLng with the given latitude and longitude, measured in degrees.
Parameters:
latitude : The point's latitude. This will be clamped to between -90 degrees and +90 degrees inclusive.
longitude : The point's longitude. This will be normalized to be within -180 degrees inclusive and +180 degrees exclusive.
我认为这应该可以回答您为什么将纬度限制在 -90 到 90 之间的疑问。
关于android - LatLng 构造函数将纬度值更改为 -90.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19073841/