简体   繁体   English

Android Map v2:标记位置错误

[英]Android map v2: marker in a wrong position

I've got problems in setting markers into my app. 在将标记设置到我的应用程序时遇到问题。 I create my LatLng object and add it to the map; 我创建了LatLng对象,并将其添加到地图中; latitude and longitude have 6 digits after comma. 纬度和经度在逗号后有6位数字。 The problem is the following: where i get the position of each marker on my map (with myMarker.getPosition.latitude and myMarker.getPosition.longitude), values have much more than 6 digits after comma (about 15 digits), and the values differ from input ones. 问题如下:我在地图上获取每个标记的位置(使用myMarker.getPosition.latitude和myMarker.getPosition.longitude),逗号后的值远超过6位(约15位),而值与输入的不同。 (ie. input latitude is 40.254874, output latitude is 40.25487358741045). (即输入纬度为40.254874,输出纬度为40.25487358741045)。

Does anyone can help me?? 有人可以帮我吗?

You cannot represent arbitrary floating point numbers in Java. 您不能在Java中表示任意浮点数。 My guess is that the difference is due to this. 我的猜测是差异是由于此。

Note that the discrepancy is at most 11 centimeters (111.321km / 1e6). 请注意,差异最大为11厘米(111.321km / 1e6)。

Hi Sotiris try this code. 嗨,Sotiris尝试此代码。

     map.addMarker(new MarkerOptions().position(new LatLng(53.551, 9.993)).title("Test"));

It will be better if you round the values after decimal. 如果将这些值四舍五入为十进制,那会更好。

This is a bug in the implementation. 这是实施中的错误。 You may see / star it on gmaps-api-issues . 您可能会在gmaps-api-issues上看到/ 加注 I guess the reason might be double values are stored in some other way when transported to Google Play Services and back. 我猜想原因可能是在将双精度值传输到Google Play服务并返回时以其他方式存储的原因。

Basically this blocks comparing Markers via position LatLng , so you should use a different way to compare them (eg Marker.equals ). 基本上,这会阻止通过位置LatLng比较Markers ,因此您应该使用其他方式进行比较(例如Marker.equals )。

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

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