【问题标题】:google maps v2 not showing multiple markers谷歌地图 v2 没有显示多个标记
【发布时间】:2014-11-08 21:28:24
【问题描述】:

我正在尝试在 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 个标记。我究竟做错了什么?谢谢。

【问题讨论】:

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


    【解决方案1】:

    您会看到 2 个标记,因为正如您在 logcat 中看到的那样,在第二个标记之后,所有标记都具有相同的纬度和经度。

    【讨论】:

    • 哦,对不起,我很愚蠢。我联系上了我的服务器程序员,谢谢!
    猜你喜欢
    • 2014-05-01
    • 2015-03-14
    • 1970-01-01
    • 2014-01-07
    • 1970-01-01
    • 2016-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多