谷歌地图v2没有显示多个标记

时间:2014-09-15 11:03:25

标签: android google-maps-android-api-2

我正在尝试在GoogleMaps中添加多个标记。我正在使用Google Map Android API v2。在提出此问题之前,我先阅读thisthis个链接以及更多链接。请看我的代码:

for (PostList post : postList) 
{       Log.d("location", "latitude" + post.latitude);
        Log.d("location", "longitude" + post.longitude);
        double latitude = Double.parseDouble(post.latitude);
        double longitude = Double.parseDouble(post.longitude);
        //LatLng postPosition = new LatLng(latitude, longitude);
        LatLng postPosition = new LatLng(Float.parseFloat(post.latitude), Float.parseFloat(post.longitude));
        Log.d("location", "LatLng = " + postPosition);
        String title = "latitude = " + post.latitude + ", longitude = " + post.longitude;
        mMarkers.add(map.addMarker(new MarkerOptions(.position(postPosition).title(title)));
        Log.d("location", "Marker was added ");
}

和日志:

09-15 14:44:47.080: D/location(2859): begin
09-15 14:44:47.080: D/location(2859): postSize = 10
09-15 14:44:47.080: D/location(2859): latitude55.74144460699403
09-15 14:44:47.080: D/location(2859): longitude37.669780254364014
09-15 14:44:47.090: D/location(2859): LatLng = lat/lng: (55.7414436340332,37.66978073120117)
09-15 14:44:47.100: D/location(2859): Marker was added 
09-15 14:44:47.100: D/location(2859): latitude55.75222
09-15 14:44:47.100: D/location(2859): longitude37.61556
09-15 14:44:47.100: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.100: D/location(2859): Marker was added 
09-15 14:44:47.100: D/location(2859): latitude55.75222
09-15 14:44:47.100: D/location(2859): longitude37.61556
09-15 14:44:47.100: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.120: D/location(2859): Marker was added 
09-15 14:44:47.120: D/location(2859): latitude55.75222
09-15 14:44:47.120: D/location(2859): longitude37.61556
09-15 14:44:47.120: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.120: D/location(2859): Marker was added 
09-15 14:44:47.120: D/location(2859): latitude55.75222
09-15 14:44:47.120: D/location(2859): longitude37.61556
09-15 14:44:47.120: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.130: D/location(2859): Marker was added 
09-15 14:44:47.130: D/location(2859): latitude55.75222
09-15 14:44:47.130: D/location(2859): longitude37.61556
09-15 14:44:47.130: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.130: D/location(2859): Marker was added 
09-15 14:44:47.130: D/location(2859): latitude55.75222
09-15 14:44:47.130: D/location(2859): longitude37.61556
09-15 14:44:47.130: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.130: D/location(2859): Marker was added 
09-15 14:44:47.130: D/location(2859): latitude55.75222
09-15 14:44:47.130: D/location(2859): longitude37.61556
09-15 14:44:47.130: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.140: D/location(2859): Marker was added 
09-15 14:44:47.140: D/location(2859): latitude55.75222
09-15 14:44:47.140: D/location(2859): longitude37.61556
09-15 14:44:47.140: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.140: D/location(2859): Marker was added 
09-15 14:44:47.140: D/location(2859): latitude55.75222
09-15 14:44:47.140: D/location(2859): longitude37.61556
09-15 14:44:47.140: D/location(2859): LatLng = lat/lng: (55.752220153808594,37.61555862426758)
09-15 14:44:47.150: D/location(2859): Marker was added 

在GoogleMap中,我看到2个标记,但必须有10个标记。我究竟做错了什么?谢谢。

1 个答案:

答案 0 :(得分:1)

你会看到2个标记,因为你可以在logcat中看到,在第二个标记之后,所有标记都有相同的刻度和经度。

相关问题