【发布时间】:2014-11-08 21:28:24
【问题描述】:
我正在尝试在 GoogleMaps 中添加多个标记。我正在使用 Google Map Android API v2。在问这个问题之前,我阅读了this 和this 链接以及更多链接。请看我的代码:
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